title: How to order posts by meta_value and title

text: How do you order products in WooCommerce so that products are random, but at the same time featured products show first? Here is my code:               $args = array(         'post_type' => 'product',         'showposts' => $show_posts,         'meta_key' => '_featured',         'orderby' => 'meta_value',         'order' => 'desc',         'post_status' => 'publish',         'paged' => $paged     );               $all_products = new WP_Query( $args );      I have tried adding `rand` after `meta_value`, but it just randomizes products (in other words the featured ones don't display first). Thanks in advance


title:
How to display the content for given page ID withot the

 wrapper?

text: How to display the content for given page ID withot the `<p></p>` wrapper? The method I'm currently using is:               <?php      $id=21;      $post = get_page($id);      $content = apply_filters('the_content', $post->post_content);      echo $content;       ?>      For example `page ID = 21` has the following content: `Some content` What the wordpress echo is `<p>Some content</p>` Any suggestion much appreciated.


title: Editing wp-config.php

text: I need to add the line `define('WP_POST_REVISIONS', false);` to my config.php , so that post revisions are disabled. I don't have access to wp-config.php, I have permission to edit my theme and plugins. Is their any way i could add this code to my theme's function.php, or is their any hook to achieve it. also, Is their anyway to override the function which has been defined in wp- config.php for eg:               define( 'BP_DEFAULT_COMPONENT', 'profile' );      can i override the above line of code without accessing wp-config.php.


title: Podcast Guest List

text: So what I want to do is too have a function similar to a category or tag, but a little more robust. It's **for a podcast** to _list of guests for each episode_. Ideally this would do a few things: ### Guest Data For _each_ guest (added to an episode), display their:   * name,    * photo,    * twitter id,    * url.  ### Guest Page Clicking on their photo or name would the visitor to a page _like the authors page_ , where more info on that guest could be stored:   * a short bio,    * all the episodes that guest has appeared on,   * etc... ### Meta Box on pod cast edit screen: The management of this would ideally be managed like categories are now, through checkboxes and names listed on the write page to select from. Further management, (adding bio, photos, ect) would be done in another panel like posts are. My first thought was custom post types or custom taxonomies, but I'm not sure which method is more feasible. Any ideas? Thanks.


title: Get link to a specific template file

text: I was planning on creating a custom "Archives" template to create a detailed Archives page for my blog, including lists of posts by category, tag, date and author. Rather than use a static link though, is there a way within WordPress to get a link to a specific template file? I want the link to work regardless of the page's URL—is this possible?


title: How to force one column layout on custom post type edit page?

text: I've created a plugin using custom post types and I need to force the default two column post page to a single column. At the same time, the **Publish** metabox must move to the bottom. I need to do this via the functions some how. I have some solutions from WPSE, but the only solution I've found actually hides the "Publish" metabox. I can't seem to figure out why. Any ideas of how to do this?


title: How could a .htaccess with authentication suddenly appear or change?

text: When trying to mark a comment as spam, I was presented with a basic-htaccess login. I couldn't login and then I remembered I do not have a basic login: the only thing my `.htaccess` in the `wp-admin` folder does is white-list the allowed IP's. When checking out the files I found that   * I now have a couple of new lines on top of my `wp-admin/.htaccess` setting a basic authetication (with, for some reason, the user/password files located at /dev/null)   * I also have extra lines in my root access file (`/.htaccess`) containing another basic authentication line, pointing to a password file in the root. Both these files are created/modified on the 5th, but not by me.   * The passwordfile contains one entry for a user called 'admin' (a user I do not use), with a password hash. To be safe until I have time to remedy this, I changed that password-hash so if something was using that as an access-method, they can't anymore (It does seem like a bit of a strange thing to do when you are already able to write to my `.htaccess`. My thoughts currently are that it is probably not a hack, as it seems very little is changed while what is changed is quite hard to do: that would be strange. What I can think of that maybe this is   * an update either gone bad (temporary limiting access to the wp-admin to only the admin user and not finishing / reverting that)    * or an update that is too paranoid about security and 'decided' to add a basic login (but I've not found anyone outraging about that, so doubtfull). Does anyone know if there is a process in the automatic update that does things like this, and maybe scenarios that can happen (and maybe even I can check) that would keep these files in place? I do not specifically need tips to remove the files or remedy the situation, I mostly really want to find out how this would happen. Specifically if this is something the automatic updater could do.


title: Walker_Nav_menu access parent menu name

text:
I extended **Walker_Nav_Menu** with the code below and I would like to replace [TITLE HERE] with the name of the parent menu... In my menu I only display one depth of the navigation at a time. So I would like to display the name of the submenu's parent. How could I achieve that ?                function start_lvl( &$output, $depth = 0, $args = array() ) {         $indent = str_repeat("\t", $depth);             $output .= "
";             $output .= "
**[TITLE HERE]**
";             $output .= "Close";             $output .= "\n$indent
\n";         }      Thanks in advance. J.


title: Get ID of featured image using "get_post_thumbnail_id(the_ID())" - without printing to screen?

text: I'm using the code:               get_post_thumbnail_id(the_ID())      to get the ID of a post thumbnail image, but whenever I call this it outputs the ID to screen. I just want to get the value to use in another function, without it echoing anywhere. How do I do this?


title: Injecting a custom sql query into a page/theme

text: I have written a custom sql query for our WordPress website (fairly elaborate and not achievable with the standard wordpress code) and I've got it to run via `$pageposts = $wpdb->get_results($query, OBJECT);`, it yields the results I expect. Now I would like to integrate this query via a hook (ideally), so that I don't have to update the theme page so that we can still update the theme. I know that the hook `pre_get_posts()` allows you to adjust the main query, but from what I've found it seems to **only** allow you **adjust**. E.g. `$query->set( 'year', $today['year'] );`. I however, want to replace the query completely. Is this doable using a hook so that I can utilize the main theme code using a hook from my child theme code? Or will I need to clone the full page from the main theme to the child theme and use the code like this:               <?php      $pageposts = $wpdb->get_results($q, OBJECT);     if ($pageposts):         global $post;         foreach ($pageposts as $post):             setup_postdata($post);     ?>


title: How to display posts by vote count and if no value continue with latest posts with no votes?

text: Maybe someone can help me with this. I want to display posts by votes. Users can only vote up. So what I want is - the most voted posts by vote count on top and then latest posts with no votes. The problem with this code below is that the post is displayed only if it has at least one vote (+1). I have tested it and it sort only voted posts the way I want, but how to continue loop if no vote value?               $args = array(          'post_type' => 'topic-post',          'posts_per_page' => -1,          'order' => 'DESC',          'meta_key' => '_topic_post_votes',          'orderby' => 'meta_value_num',          'meta_query' => array(          array(          'key' => '_topic',          'value' => array( $topic_id ),          'compare' => 'IN',          )          ),          'post_status' => $status          );


title: Load JS/CSS of shortcode in post

text: I try the The Jedi Master way http://scribu.net/wordpress/optimal-script-loading.html               class My_Shortcode {         static $add_script;              static function init() {             add_shortcode('myshortcode', array(__CLASS__, 'handle_shortcode'));                  add_action('init', array(__CLASS__, 'register_script'));             add_action('wp_footer', array(__CLASS__, 'print_script'));         }              static function handle_shortcode($atts) {             self::$add_script = true;                  // actual shortcode handling here         }              static function register_script() {             wp_register_script('my-script', plugins_url('my-script.js', __FILE__), array('jquery'), '1.0', true);         }              static function print_script() {             if ( ! self::$add_script )                 return;                  wp_print_scripts('my-script');         }     }          My_Shortcode::init();      when [myshortcode] in widget, the js file is loaded. But when [myshortcode] in a post , the js file is not loaded. Could you tell me the problem ?


title: Options Framework options not being output

text: I am using the Options Framework. In my theme's options.php, I have the following code:               function optionsframework_options() {              $options = array();              $options[] = array(             'name' => __('Footer Navigation', 'options_framework_theme'),             'type' => 'heading');              $options[] = array(             'name' => __('Button 1 URL', 'options_framework_theme'),             'desc' => __('Enter the URL clicking on the button takes you to.', 'options_framework_theme'),             'id' => 'footer-nav1_URL',             'std' => '',             'type' => 'text');              $options[] = array(             'name' => __('Button 1 Text', 'options_framework_theme'),             'desc' => __('Enter the text you see underneath the button.', 'options_framework_theme'),             'id' => 'footer-nav1_text',             'std' => '',             'type' => 'text');      In my theme's footer.php, I have the following code:               <?php if (of_get_option('footer-nav1_URL', '') !== '') { ?>         <a href="<?php echo of_get_option('footer-nav1_URL', '');?>">                                       <?php echo of_get_option('footer-nav1_text', '');?>              <?php }?>      Those options are not being output in the footer. The footer is working normally otherwise. Other options called in front-page.php are working okay. Why won't these options work?


title: Display edit link if post author is current user

text: I am creating an author.php page and listing all the posts from an author. Although admins can see the posts' edit links i want to echo the link if logged in user is the current user for example if testuser is logged in and current page is /author/testuser he can see edit post links but if testuser is logged in and current page is /author/theee he cant see the links currently i have               $curauth = (isset($_GET['author_name'])) ? get_user_by('slug', $author_name) : get_userdata(intval($author));     $th = $curauth->nickname;      $cu = $current_user->user_login;     if ( $th = $curauth ) {       edit_post_link('edit', '', '');      } else {          }      but still only admins can see the links.


title: different categories (using the same category labels) for different post types

text: I'm trying to build a multimedia aggregation website with 6 different custom post types and I would like each post type to have 12 categories, the same 12 category labels that the other 5 have, only I would like each to have its own archive, not to share category archives with the others. Here is a link to the website in its current form: http://www.collectivelyconscious.net/test2 (check navigation to see categories) A simplified structure of the website is as follows:               1. root/         A. news/           i. politics/           ii. economics/           iii. health/            ...etc.            B. videos/           i. politics/           ii. economics/           iii. health/            ...etc.            C. documentaries/           i. politics/           ii. economics/           iii. health/          ...etc.      So what I want is for people to be able to click on a category tag, say "Political", for news and have the archive show only the recent news posts that have been sorted into the category "Political" with the URL preferably in the following format: `root/news/political/` Or if that is not possible then for them at least to be found at: `root/category/political-news/` I have been messing around with the plugin Custom Post Type UI and if I add either the normal tags or normal categories they use the same categories/tags of course and feed into a single archive. So then I tried creating custom taxonomies but (1) am forced to change the taxonomy slug for each custom post type, (2) I am unable to find the archive page for custom post type posts in custom taxonomies, and (3) it is acting really buggy for some reason. I have no idea where to go from here... Any help would be greatly appreciated!


title: WP Code Highlight :'=>' replaced by '&gt'

text: I use WP Code Highlight on my blog, but if I input the characters `=>` between `<pre>#code here...</pre>`, it changes into `>`. For instance, `'access arguments' => array('admin turen module')` will be changed to `'access arguments' =>array('admin turen module')`.


title: Dynamic Sidebars & Echo

text:
I can sucesfully get my dynamic sidebar to work like so:

             <?php dynamic_sidebar( 'pop-photos-sidebar' ); ?>

      Now, I'm trying to get the sidebar to work with a different code that is inside a php code. I tried using the above `< ?php dynamic_sidebar( 'pop- photos-sidebar' ); ? >` code and it broke my site since the php dynamic_sidebar code is inside another php code. So I tried making a $ function like so:               $newssidebar = dynamic_sidebar( 'pop-news-sidebar' );                 echo '

                     '.$newssidebar.'

';      This sucesfully displayed the dynamic side bar "pop-news-sidebar" but.. it is not inside the ul class widget-area first, or inside the div class sidebar sidebar-first. How would I make my dynamic sidebar to properly be displayed in the ul class and div class listed above like it should be? Would I even use echo? I didn't think it was necessary to paste the full code, but here it is anyways:               <?php         if( fake if code ) {             if( another fake if code ) {                 $newssidebar = dynamic_sidebar( 'pop-news-sidebar' );                 echo '

                     '.$newssidebar.'

';             }else if( fake else ) {                 echo 'some other code';              }         }          ?>      Any help would tremendously be appreciated! :)


title: Advanced author permalinks

text: I'm trying to build permalink structure for author archives that would allow me to display different custom post types posts in 'subpages/subarchives' of author archive. So the idea is to change this: /%author_base%/%user_name%/ Into this: /%author_base%/%user_name%/%CPT_slug%/ I'd be greatful for suggestions.


title: How to check if the product is in a certain category on a single-product.php in Woocommerce?

text: How in the world can I check if a product is in a certain product category on the _single-product.php_?               <?php if (is_product_category('audio')) {                echo 'In audio';                    woocommerce_get_template_part( 'content', 'single-product' );                } elseif (is_product_category('elektro')) {                      echo 'In elektro';                 woocommerce_get_template_part( 'content', 'single-product' );              } else {                 echo 'some blabla'; }  ?>      **is_product_category('slug')** does not have an effect on the **single- product.php**. I want to have the upper conditionals. Any solution for this on a single-product page?


title: Query not returning CPT posts

text:
Ouch, banging my head against a wall! I am trying to query my post type 'clips' in index.php but it's returning only posts from the default 'post'. I need some insight! What am I doing wrong? My post type:               $args = array(          'labels' => $labels,         'supports' => $supports,          'hierarchical' => false,         'menu_position' => 4,         'publicly_queryable' => true,         'show_ui' => true,         'public' => true,         'query_var' => true,         'capability_type' => 'clip',         //'map_meta_cap' => true,         //'capabilites' => $capabilities,     );           register_post_type( 'clip', $args );       My query (index.php):               <?php query_posts(array('posts_per_page' => 17, 'post_type' => array('clip'))); ?>          <?php if (have_posts()) : ?>
            <?php while (have_posts()) : the_post(); ?>
           <?php the_title();?>
<?php the_permalink(); ?>           <a id="post-<?php the_id(); ?>" class="videolink" title="Click to view" href="">           <?php if ( has_post_thumbnail() ) {               the_post_thumbnail();              } else {              echo "No thumbnail";              } ?>
             <?php endwhile; ?>
                   <?php else: ?>
Sorry, but this content is not available.
              <?php endif; ?>      Note there are no other loops in the template file.


title: Create second custom 404 page for selected post type

text: I created a new custom post type called `event`, which works fine. I also created a custom `404` page template, which is shown if a event/page/post is not found. But now the hard part, i want to create a custom 404 page for event post type. So this 404 page is only shown if a event is not found. But the default 404 page should still work with posts or pages. Thanks


title: How to find the post_id of a post on a wordpress blog that uses pretty URLs?

text: The only trick here: It is not my blog, I know how to do it using php in my blog. I want to find the id of a post on another wordpress blog through the internet. Does this information 'leak' somewhere, is it possible to be found by a third party?


title: Comments: Approve when admin Replies, from the Front end

text: Thank you for reading, In the admin panel, when a comment is awaiting moderation, you can "Approve and Reply" in the same action. However, in the front end, if you show the awaiting comments to the admin, and she hits Reply, the comment wont approve. Does anybody know how to get the proper link, or where modify the code, to auto-approve comments when the admin replies ? **Why:** I'm creating the site for a client, and trying to make it as easy as posible so she won't need to learn WP's admin panel.


title: Build a rss powered website network

text: I'm trying to build a website network on my site that is rss powered. It should be similar to http://network.smashingmagazine.com/ in scope except I want the new content posted automatically. It should work off a cron job perhaps every hour or so and it needs to fit the current template on my site at http://www.theliverpoolview.com/ Is there any free or open source plugin that does an easy job of this?


title: Correct syntax for retrieving custom field in CPT

text: I don't understand when to use $post->ID or $post->post->ID with CPTs. I have :               $event = get_post( $event_id );     $event_pre_register = get_post_meta($event->post->ID, "Event Pre-register deadline", true);       Or is it : get_post_meta($event->ID ... ?


title: Will these plugins work with wp multisite?

text: I just created my first network of sites with wordpress and I was installing plugins, I installed these: > Platinium SEO Pack (http://techblissonline.com/platinum-seo-pack/) > > TubePress (http://www.tubepress.net) > > Contact Form 7 (http://contactform7.com/) > > Social Bookmarks (http://wordpress.org/extend/plugins/social-bookmarks/) > > Strictly Auto Tags (http://wordpress.org/extend/plugins/strictly-autotags/) > > SEO Smart Links (http://wordpress.org/extend/plugins/seo-automatic-links/) > > SEO Friendly Image (http://wordpress.org/extend/plugins/seo-image/) > > Google XML Sitemaps (http://wordpress.org/extend/plugins/google-sitemap- > generator/) I "network activated" all the plugins and then I went to one of the sites dashboards, and I saw a msg from Google XML Sitemaps saying that the plugin doesn't work on multisite. Now my problem is that I don't know if the other plugins will work. Will I have to test each feature of all the plugins or is there an easier way to know if they work on multisite?


title: How to get the depth of a category's subcategories

text: I'm looking to get the depth a category's subcategories. Suppose I have a category 'grandparent' which has a subcategory 'parent' which in turn has a subcategory 'child'. How do I get to integer 2? I suppose I could check if 'grandparent' has subcategories and if it does, check if they have subcategories, etc, until I hit 0. But that seems like a lot of unnecessary processing. Isn't there a more elegant way?


title: Guest Author - How can I use custom fields to create guest author link?

text: We are posting articles authored by guest authors. The guest authors will not be logging in to the site, and we don't want to create users for these guest authors. We are also not interested in any of the guest blogger plugins for MANY reasons.. To display the guest authors name in the guest posts, I've added a function to my theme's functions.php file so that using a custom field, my guest authors name will appear in place of the name of WordPress user who posted the article.. This function is outlined here: http://www.wpbeginner.com/wp- tutorials/how-to-rewrite-guest-author-name-with-custom-fields-in-wordpress/ Using this, I am able to change the name of the author to display the guest author's name.. However the author link still points to the author page of the WordPress user who posted the article. So now I'd like to do something similar with the author link. What I would like to do is for the author link to go to a URL that I will enter in a custom field like I enter the guest author's name. This is the code I'm using, but it's not working. The author link still takes you to the author page for the WordPress user who posted the article.               add_filter( 'the_author_posts_link', 'guest_author_link', 10, 3);     add_filter( 'get_author_posts_url', 'guest_author_link', 10, 3);     add_filter( 'the_author_link', 'guest_author_link', 10, 3);     add_filter( 'get_author_link', 'guest_author_link', 10, 3);          function guest_author_link($link, $author_id, $author_nicename) {       global $post;       $url = get_post_meta( $post->ID, 'guest-url', true );         if( $url ) {             $link = $url;         }         return $link;     }


title: How to remove the automated code posted in functions.php?

text: There is a theme hack or a worm circulating online which adds this code to all functions.php files. It happened to me on my local server. Here's the code - http://pastebin.com/AUsHUng1 How do I find the theme hack that creates it? Or the worm? **UPDATE:** I have found that this line:               $elem == substr(__FILE__,-13)){      checks for the **functions.php** file (as it's the only one having 13 letters and using file) and by using the `fputs()` functions writes itself on all **functions.php** files. I have deleted all the instances of the code, and, hopefully, it will not replicate itself on another theme activation. I have a local server with about 60 themes. I still haven't found the original theme that carried the code. **UPDATE AND SOLUTION:** Clean all the malicious code (see my PasteBin link above) from all **functions.php** files (best to check globally using a text editor like Notepad++) and you're done. Check all downloaded themes for the code in **functions.php** file. There are more themes infected with this code online.


title: Removing Shortcodes from Child Theme

text: I'm trying to remove the shortcodes from a child theme. In my functions.php file (for the child theme), I've put:               function my_remove_shortcode(){         return '';     }     add_shortcode('entry-twitter-link', 'my_remove_shortcode');      Where entry-twitter-link is a shortcode created in the parent. However, the entry still shows up on my posts. Ideas on what's wrong?


## This issue is now finally resolved by myself. Find the solution in the end of this post. Question was in short: **How can i ask in my WP template, IF the whole array of have_posts contains any post from a certain category** I programmed my tag page so that the output is seperated into three styled boxes according to the categories. The loop is done three times and with an IF i sort out the categories. This is a _simplified!_ draft of the working structure:

     <?php if (have_posts()) : while (have_posts()) : the_post(); ?>       <?php if (in_category('cat1')) : ?>
...     <endif>

     <?php if (have_posts()) : while (have_posts()) : the_post(); ?>       <?php if (in_category('cat2')) : ?>
...     <endif>

     <?php if (have_posts()) : while (have_posts()) : the_post(); ?>       <?php if (in_category('cat3')) : ?>
...     <endif>

      Here you can see the output: http://imlichte.net/tag/interdependenz/ Now my point is to avoid emtpy boxes when no posts are found in a category. The boxes (divs) should then not be rendered at all. For this i thought to put an IF condition for the div and ul, which are outside of the loop. So i want to actually ask this thing: **IF have_posts contains posts from a certain category** The div and ul that creates the box on the page will only be shown if the result is not zero, thus the result of suppressing empty boxes is reached. I hope i could explain my request well enough to be understood and hope for a solution from the experts, since i am just a hobby programmer. Thanks for help Sofian Edit: to make it very clear, here comes the whole code that generates my category structured tag list:

Artikel

                     <?php if (have_posts()) : while (have_posts()) : the_post(); ?>       <?php if (in_category('wissen')) : ?>
              <?php if (has_post_thumbnail()): ?>             <a href="<?php the_permalink();?>"><?php the_post_thumbnail(array(150,150));?>         <?php else: ?>

         <?php endif; ?>                    <a class="postlisttitle" href="<?php the_permalink();?>"><?php the_title(); ?>
               <?php the_excerpt();?>

         <?php endif; endwhile; endif; ?>

Empfehlungen

                   <?php if (have_posts()) : while (have_posts()) : the_post(); ?>       <?php if (in_category('empfehlungen')) : ?>
              <?php if (has_post_thumbnail()): ?>             <a href="<?php the_permalink();?>"><?php the_post_thumbnail(array(150,150));?>         <?php else: ?>

         <?php endif; ?>                    <a class="postlisttitle" href="<?php the_permalink();?>"><?php the_title(); ?>
               <?php the_excerpt();?>

         <?php endif; endwhile; endif; ?>

Seminare

                   <?php if (have_posts()) : while (have_posts()) : the_post(); ?>       <?php if (in_category('seminare')) : ?>
              <?php if (has_post_thumbnail()): ?>             <a href="<?php the_permalink();?>"><?php the_post_thumbnail(array(150,150));?>         <?php else: ?>

         <?php endif; ?>                    <a class="postlisttitle" href="<?php the_permalink();?>"><?php the_title(); ?>
               <?php the_excerpt();?>

         <?php endif; endwhile; endif; ?>

      The solution: I run through the whole loop once just to set a variable to true if it comes across a post in that category. If there is no post, the var stays false and the Div Box around the actual loop will not be output.               <?php $categoryexisting = false;        if (have_posts()) : while (have_posts()) : the_post();       if (in_category('articles')) :         $categoryexisting = true;                    endif; endwhile; endif; ?>            <?php if ($categoryexisting): ?>

Articles

          <?php endif; ?>      ... Actual loop ...


title: How to dynamically change theme's slogan from admin?

text: how can achieve this functionality. That I can change the themes "slogan" from admin and I don't have to go edit the themes source files. I think that there is some theme options functionality. But how to use it and maybe somebody can point me to the correct path. Added screenshot to clarify what I mean under slogan: ![enter image description here](http://i.stack.imgur.com/ALjqI.png)


title: Understanding Post Formats/Custom Post types Etc

text: I don't understand what "Adding Post Type Support" is for when we have "Adding Theme Support"? For different post-formats this is the way I was shown before. This is then how I did it for the project I was working on, is this a correct/good way to do it? here is whats in my `functions.php` file:               <?php add_theme_support( 'post-formats', array('image', 'video', 'gallery')); ?>      and here is what is in my `index.php` file:               <?php get_template_part('content', get_post_format()); ?>      I also want to know if I should "custom post type" for what I describe below: Lets say I have a page called "giftshop" with posts (also trying to figure that part out now) and I want to use the `image` format for each post but then I have a page that I'm only going to show one post called "newsletter" and I also want to use the `image` format but have it styled a little different, is that possible?


title: TinyMCE buttons that launch Ajax-generated forms

text:
if i follow the tutorials on how to add tinyMCE buttons for shortcodes ( for instance: http://www.garyc40.com/2010/03/how-to-make-shortcodes-user- friendly/ ) if i create a button that launches a form in a thickbox there is always this bit of code to create the launched form:               // executes this when the DOM is ready         jQuery(function(){             // creates a form to be displayed everytime the button is clicked             // you should achieve this using AJAX instead of direct html code like this             var form = jQuery('

\
\                     Columns	\                     <input type="text" id="mygallery-columns" name="columns" value="3" />
\                     specify the number of columns.	\
\
\
\                 <input type="button" id="mygallery-submit" class="button-primary" value="Insert Gallery" name="submit" />\
\
');                  var table = form.find('table');             form.appendTo('body').hide();      but i am curious about this part in particular : **// you should achieve this using AJAX instead of direct html code like this** i've seen this on other tutorials, and in other plugins.... but all i've seen continue to do it this hard-coded way. does anyone have any insight into how to do this via ajax? i'd like to popular a select drop-down with values from get_options().. which i cannot do in jquery/java and the js file can't process the php either, so i figured ajax is the solution i'm just not sure how to start


title: URL Rewrite + Page + Custom Post Type = Unusual Redirect

text: Yet another URL rewrite issue :) ## The Problem I have a URL rewrite rule that should work, but against all logic it redirects without passing the query var. ## The Juicy Details The site has a page structure set up like so: > **/our-firm/shareholders** and I have a Custom Post Type named " _shareholder_." My goal is to have the structure work like this: > **/our-firm/shareholders/awesome-shareholder-name** ...and for the Shareholders page to do a custom query for the Shareholder posts. I normally would use the rewrite slug for the Shareholder posts, but I want the content to be shown in the context of the original Page structure ( **our-firm/shareholders** ). In order to achieve that, I added this code in functions.php (and have since gone to Permalinks and saved to refresh the rules):               add_action( 'init', 'my_custom_rewrites' );     function my_custom_rewrites(){         add_rewrite_rule(             'our-firm/shareholders/([^/]+)/?',             'index.php?pagename=shareholders&shareholder_name=$matches[1]',             'top' );     }          add_filter( 'query_vars', 'my_custom_query_vars' );     function my_custom_query_vars( $query_vars ){         $query_vars[] = 'shareholder_name';         return $query_vars;     }      All that in place, if I go to **/our-firm/shareholders/awesome-shareholder- name** it redirects me to the Shareholders page without passing the query var and actually changes the URL to **/our-firm/shareholders/**. The weird part is if I change the redirect pagename to anything else, it works and effortlessly passes the query var along. To further test it, I used the handy Rewrite Analyzer plugin and got this: Rewrite Analyzer Test Screenshot ## Additional Notes   * I am running WP **3.2.1** , testing locally, and have not fiddled with .htaccess   * My Shareholders Page template isn't doing anything unusual, but let me know if you need to see it   * _Does Wordpress take into account the label of a Custom Post Type when figuring out URLs?_ The plural label of "shareholder" is, naturally, "Shareholders."   * I am adding the "shareholder" CPT via the **Custom Post Type UI** plugin. I can manually add it with code if anyone feels that would help. These are the CPT settings: > rewrite = true, slug = 'shareholder', with_front = true, query var = true, > and hierarchical = true.   * I previously had the "shareholder" post type ID as "shareholders," then quickly realized that would cause issues being the same name as the page I was attempting to redirect to. I then changed the post type to "shareholder," which unfortunately didn't resolve the issue. _Could the fact that there one was a post type of "shareholders" be affecting this?_ Maybe there's a secret magical cache somewhere that I could clear out...   * I know there are at least 5 bajillion WP URL rewrite posts across the web, but I can't seem to find one that pertains to my specific issue. Sorry if I missed one :) I'm at my wit's end – I _know_ that this should work, but it doesn't. Hopefully I missed something painfully obvious and it's an easy fix. Please let me know if I can provide any more details/code/etc. Any help would be appreciated, thanks!


title: Automatically adding post and pages to new blog setups

text: I'm using the ThreeWP Broadcast plugin to add and control post and pages from the main blog to all my sub-blogs in the network. Is there anyway i can automatically add all of my post and pages from my main blog to new blogs I set up without having to go in each individual post and page and adding it manually?


title: pull data from a remote wordpress database

text:
I am trying to pull some data from a remote wordpress database. Here is the code I have:               $server = "my server code";     $user = "my username";     $password = "my password";     $db = "mydb";     $con = mysql_connect($server,$user,$password);      if (!$con) {         die("database connection error");          } else {          mysql_select_db($db, $con);          function dp_get_user_liked_posts($user_id, $fields = '') {              global $wpdb;              $tempDB = $wpdb;          $wpdb = new wpdb($user, $password, $db, $server);              // Get user settings         $settings = get_option('dp_post_likes');                  $login_required = !empty($settings['login_required']) ? true : false;                      if($login_required && !is_user_logged_in()) {                          echo '
'.sprintf(__('You must register and login to view your liked videos.', 'dp'),  site_url('wp-login.php?action=register', 'login'), wp_login_url()).'
';                      } else {              $settings = get_option('dp_post_likes');         $user = get_current_user_id();         $user_id = 2;         $likes=query_posts(array(                                 'post_type' => 'post',                                 'ignore_sticky_posts' => true,                                 'filter_type' => 'user_liked',                                 'filter_user' => $user_id                             ));                          global $wp_query;                      $likes= array();                      while (have_posts()) :                                  $likes[]=the_post() ;                             endwhile;          }}}               mysql_close($con);          $wpdb = $tempDB;      but it is not display `$likes`. What is did wrong?


title: gallery image size

text: I have been looking for a couple of days for a filter for the WordPress gallery. I have tried many different codes but nothing seems to work for it. I am not using a plugin. I am talking about the stock gallery I created a 2 column WordPress gallery and inserted it into a page. This did make a 2 column gallery but it also made the image sizes to 128 x 49. The site is responsive and the image sizes should be around 400 by 200. So I thought that if I could get WordPress to take out the inline height and width that the responsive part would take over and fill the available space. The filters that I have tried have worked on other images just not the gallery. I am using the 2014 theme and it's media queries. Is there a specific filter for the gallery? Here is the filter I am using for other images                add_filter('wp_get_attachment_link', 'remove_img_width_height', 10, 1);          function remove_img_width_height($html) {         $html = preg_replace( '/(width|height)=\"\d*\"\s/', "", $html );         return $html;     }


title: Storing Custom Post Type Data in a Custom Table

text: I am working on a custom job board for a client that wants to deploy this job board on a multi-site network. Here is my problem, I need to store certain jobs in a table that would be accessible to all sites in the network (e.g. a nationwide listing) instead of just locally (e.g. local listing). My question: can data from a custom post type be stored in a custom table? Edit: Perhaps more clarification is needed. My client has a multi-site network job board. There are job boards for specific regions (e.g. San Diego, Austin, Denver, etc.). Right now, a user posts a job for Denver on the Denver site but if he has a job he wants to advertise nationwide, he would have to post the job on all sites in the network. We want to create a custom post type for jobs that gives the user the opportunity to select a nationwide category and upon saving the job, have it show up on all the sites in the network. The one way we could see making this work would be to have a job tagged as 'nationwide" save its data in a separate table outside the typical wp_1_posts table so that we could query that table for nationwide jobs and list them on ALL the sites in the network automatically as a part of the theme.


title: Multiple Rows in a <table> using wp_query

text:
I am displaying posts in a grid (4 posts wide by 2 posts high). I am using a table. In order to get the content to display on the second row, I am using two wp_queries (one on each row) because I can't figure out how to make the second row while being inside the loop. I'm trying to figure out if I can achieve this same layout with a single query instead of having to do two of them. How could I achieve this? Here is the part of my code I'm referring too:

             <?php                 $args = array (                     posts_per_page => 4,                     post_type => 'post',                     orderby => 'meta_value_number',                     meta_key => 'episode',                     order => 'ASC',                     post_status => array('publish, future')                     );                 // The Query                 $query = new WP_Query( $args );                      // The Loop                 if ( $query->have_posts() ) {                     while ( $query->have_posts() ) {                         $query->the_post();                          $pID = $post->ID ?>                                              <form id="episode-<?php echo $pID; ?>" name="episode-<?php echo $pID; ?>" method="post" action="">
                                 <a onclick="document.getElementById('episode-<?php echo $pID; ?>').submit();"><?php the_post_thumbnail(); ?>
                             <input type="hidden" name="pID" value="<?php echo $pID; ?>" />                         </form>
                             Episode <?php the_field('episode'); ?>
                             "<?php the_title(); ?>"
                             <?php                              if (get_post_status() == 'publish') {                                 echo get_the_time('M d, Y');                             } else {                                 echo 'Premieres '; echo get_the_time('M d');                                 }                             ?>
                     	                    <?  }                 } else {                     // no posts found                 }                 /* Restore original Post Data */                 wp_reset_postdata();                 ?>

                 <?php                 $args = array (                     posts_per_page => 4,                     offset => 4,                     post_type => 'post',                     orderby => 'meta_value_number',                     meta_key => 'episode',                     order => 'ASC',                     post_status => array('publish, future')                     );                 // The Query                 $query = new WP_Query( $args );                      // The Loop                 if ( $query->have_posts() ) {                     while ( $query->have_posts() ) {                         $query->the_post();                          $pID = $post->ID?>                                              <form id="episode-<?php echo $pID; ?>" name="episode-<?php echo $pID; ?>" method="post" action="">
                                 <a onclick="document.getElementById('episode-<?php echo $pID; ?>').submit();"><?php the_post_thumbnail(); ?>
                             <input type="hidden" name="pID" value="<?php echo $pID; ?>" />                         </form>
                             Episode <?php the_field('episode'); ?>
                             "<?php the_title(); ?>"
                             <?php                              if (get_post_status() == 'publish') {                                 echo get_the_time('M d, Y');                             } else {                                 echo 'Premieres '; echo get_the_time('M d');                                 }                             ?>
                     	                    <?  }                 } else {                     // no posts found                 }                 /* Restore original Post Data */                 wp_reset_postdata();                 ?>


title: Why enqueue styles on hook

text: Why do we need to enqueue styles on a hook, why not just enqueue them straight in like this?               wp_enqueue_style( $handle, $src);      the codex page gives an example of using a hook but doesn't explain why (or if) it's important.


title: Update User Meta after Registration

text: After a user registers, I am creating two pages of two different custom post types, and then need to store a custom meta value in their user data to assist with redirects later. I've found that if I specify custom meta values during registration (on registration form), I can retrieve these values later with :               global $current_user;         get_currentuserinfo();         $theirRedirectKey = $current_user->rpr_redirect_key;      However, in the following functions.php snippet, I can't the meta value to save for retrieval later.               function after_registration($user_id){         // Get the Newly Created User ID         $the_user = get_userdata($user_id);              // Get the Newly Created User Name         $new_user_name = $the_user->user_login;              // Create a unique Tour Code Prefix from User ID         $tourPrefix = $the_user->ID;              // Check for Tour Code Key if entered into registration form         $enteredKey = $the_user->rpr_redirect_key;              if($enteredKey == ''){             //Create the first Tour Builder Page             $tourBuilder = array();             $tourBuilder['post_title'] = $new_user_name . '| Custom Educational Tour';             // Next line may not be important after hubpages are set up.             $tourBuilder['post_name'] = 'builder-' . $tourPrefix;             $tourBuilder['post_type'] = 'builder';             $tourBuilder['post_content'] = 'This is the content by Christian!';             $tourBuilder['post_author'] = $user_id;             $tourBuilder['post_status'] = 'publish';             $tour_id = wp_insert_post( $tourBuilder );                  // Build hubpage             $hubpage = array();             $hubpage['post_title'] = $new_user_name . '\'s Hubpage';             // URL must be unique             $hubpage['post_name'] = $new_user_name;             $hubpage['post_type'] = 'hubpages';             $hubpage['post_author'] = $user_id;             $hubpage['post_status'] = 'publish';             $hub_id = wp_insert_post( $hubpage );                  //Update User with proper redirect keys for some reason this line doesn't work.             add_user_meta($the_user, 'rpr_redirect_key', '/hubpage/' . $new_user_name, true);         }          }     add_action('user_register', 'after_registration');      Help would be much appreciated.


title: Permission denied in template-loader .php

text: Oh man. I tried to create a custom page template for a page on my site page-cumberland-principles.php When I go to view that page, the page showed up completely blank. I used wp_debug, and found the following:               Warning: include(/src/cpwmweb/htdocs/wp-content/themes/striking/page-cumberland-principles.php): failed to open stream: Permission denied in /src/cpwmweb/htdocs/wp-includes/template-loader.php on line 43          Warning: include(): Failed opening '/src/cpwmweb/htdocs/wp-content/themes/striking/page-cumberland-principles.php' for inclusion (include_path='.:/usr/share/php:/usr/share/pear') in /src/cpwmweb/htdocs/wp-includes/template-loader.php on line 43      I tried changing the permissions to 755 and even testedon 777 but I can not seem to find a solution. Any help Greatly appreciated. Thank you


title: How to use widget on page or post?

text: I am just using Random image Widget, it's for image gallery. Please anybody tell me that how can I use this widget functionality on my website page or post?


title: send email to all registered users when post expires

text: I have a function which, when a post is published inside a CPT after three days the page is redirected to another URL/PERMALINK. This is the code:               add_action('template_redirect', 'check_the_date_for_stats');          function check_the_date_for_stats() {       if ( is_singular('debate') ) { // adjust myCPT with your real cpt name         $pl = get_permalink( get_queried_object() ); // permalink         $is_stats = array_key_exists( 'stats', $GLOBALS['wp_query']->query ); // is stats?         $is_cm = array_key_exists( 'comments', $GLOBALS['wp_query']->query ); // is comments?         $ts = mysql2date('Ymd', get_queried_object()->post_date_gmt ); // post day         $gone = ($ts + 3) < gmdate('Ymd'); // more than 3 days gone?         if ( $gone && ( ! $is_stats && ! $is_cm ) ) {            // more than 3 days gone and not is stats => redirect to stats            wp_redirect( trailingslashit($pl) . '/stats' );            exit();         } elseif( ! $gone && ( $is_stats || $is_cm ) ) {            // we are in 3 days frame and trying to access to stats => redirect to post            wp_redirect( $pl );            exit();         }       }     }      Is it possible, after 3 days are gone to send an email with a standard message to all registered users, if so how can I do this ? I know this function: `<?php wp_mail( $to, $subject, $message, $headers, $attachments ); ?>` but I don't know how can I link this with my function to send an email to all registered users after three days have passed. Can someone give me some hints on how can I achieve this ? Thanks !


title: Include Post Format in permalink

text: I'm running the latest version of WordPress with pretty permalinks enabled. I'm looking for a way to include the Post Format type (eg: link, status, quote) in the post's permalink. When the post has no format assigned, or uses the 'standard' format, I want that part of the permalink to empty. Example using the link post format:               http://example.com/link/look-at-this-cool-site/      Example using the quote post format:               http://example.com/quote/example-quote-post      Example using no post format:               http://example.com/just-another-post      **Edit:** See my answer for progress


title: How to get parent category ID in single page template

text: How can I get parent category ID in single page template, outside of loop?               $category = get_the_category();      echo $category[0]->term_id;      The code isn't working outside loop correctly.


title: How Do I Set the Page Title Dynamically?

text: Is it possible to change the page title with code? For example, let's say the page's name is "Book your Order", but I want to change it to "Book Order #123". I Google'd a bit and looked here and didn't see anything. Anyone know of a plugin or hack? wp_title returns the page title but doesn't allow setting the page title: http://codex.wordpress.org/Function_Reference/wp_title


title: Only retrieve posts where post_excerpt has been filled out

text: I'm trying to use get_posts to only return posts that have an excerpt. Done lots of searching and have been trying to use "posts_where" filter on the query but my SQL is lacking. This is what I'm using which in theory I think should work, but really I have no idea on the sql and can't work out how to print the sql string for this query to debug...               $args = array(         'post_type' => 'testimonial',         'numberposts'     => 1,         'orderby'         => 'rand',     );          add_filter( 'posts_where' , 'posts_where_excerpt_not_empty' );          $post = get_posts($args);          remove_filter( 'posts_where' , 'posts_where_excerpt_not_empty' );          [...]          function posts_where_excerpt_not_empty( $where ) {         $where .= " post_excerpt NOT NULL";         return $where;     }


title: Extra Meta Data for Wordpress Multisite Taxonomy

text:
I'm using a custom taxonomies across a Wordpress multisite install (same taxonomies on all sites) and i'm trying to add some custom meta boxes to each of these (same meta boxes on all sites). I'm using the following plugin to activate a global meta tags and add the appropriate table in the database: http://wordpress.org/extend/plugins/simple- meta-tags/ So far I also have the following code:               add_action('taxonomyname_add_form_fields', 'taxonomyname_metabox_add', 10, 1);     add_action('taxonomyname_edit_form_fields', 'taxonomyname_metabox_edit', 10, 1);              function taxonomyname_metabox_add($tag) { ?>
Meta Box Info Title

             <?php _e('Extra Field 1') ?>             <input name="extrafield1" id="extrafield1" type="text" value="" size="40" aria-required="true" />

             <?php _e('Extra Field 2') ?>             <input name="extrafield2" id="image2" type="text" value="" size="40" aria-required="true" />
     <?php }               function taxonomyname_metabox_edit($tag) { ?>
Meta Box Info Title

                              <?php _e('Extra Field 1'); ?>             	                              <input name="extrafield1" id="extrafield1" type="text" value="<?php echo get_term_meta($tag->term_id, 'extrafield1', true); ?>" size="40" aria-required="true" />

                              <?php _e('Extra Field 2'); ?>             	                              <input name="extrafield2" id="extrafield2" type="text" value="<?php echo get_term_meta($tag->term_id, 'extrafield2', true); ?>" size="40" aria-required="true" />

     <?php }                    add_action('created_taxonomyname', 'save_taxonomyname_metadata', 10, 1);         add_action('edited_taxonomyname', 'save_taxonomyname_metadata', 10, 1);          function save_taxonomyname_metadata($term_id){     {              if (isset($_POST['extrafield1']))              update_term_meta( $term_id, 'extrafield1', $_POST['extrafield1']);                       }     {         if (isset($_POST['extrafield2']))              update_term_meta( $term_id, 'extrafield2', $_POST['extrafield2']);                       }     }      The meta boxes display fine across all sites, and save ok on the main site, but on sub-sites no inputs will save. I assume this is because no blog_id or global variable is declared in the save function, but i'm a bit confused how to add/do this. Can anyone assist please?


title: Contact form 7 dynamic text extension - populate form with title from previous page

text: I've looked through the documentation but i can't work out how i'm meant to do this. I've got a form on a product page which is just a few labels. I want to link them to a contact form and populate the form it goes to with the post title of the product, the page it came from. So i've got a product page, click on a link, goes to a contact form page with the product (post) title populating one of the fields. I've looked every where but can't figure out how i'm meant to do this. I found this page which is supposed to explain how to do this but it doesn't really. http://sevenspark.com/tutorials/how-to-create-a-dynamic-wordpress-contact-form **Update** I've got the contact form set up with a CF7_GET key to retrieve the value in the url but i don't know how i get the post title in the url to pass it to the contact form. Also all of a sudden in the url that goes to my contact form it's putting the current page before the url i define. Does anyone know why it's doing that? How do i get the post title in the url?


title: Assign multiple roles , overlapping capabilities

text: What happens if i assign let's say 2 different (custom) roles to a user that both of which have the same (custom) capability?


title: Load stylesheet in edit category page?

text: I have a plugin that I want to add a stylesheet to each "edit category" page because I added additional custom fields into those pages. Is there a simple way of doing this or do I have to use the URL and add it individually using `add_action()`?


title: Theme not calling Jquery properly

text: I am developing a theme and I have called jquery along with other JS files from a theme-enqueue.php file. For some reason only the Jquery file that is hosted on googles servers is adding the theme URL into the URL path so it is not loading it and causing other JS files to not load properly. The hook is done properly and it is pointed only to their server and does not include a get_bloginfo or get_template_uri. The file it is adding my theme URL to is:                   'http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js', '', '1.4.2', true);      Here is the full function within my enqueue file. Can anyone see any issues?               function init_scripts() {     wp_deregister_script( 'jquery' );     wp_deregister_script( 'comment-reply' );     // Register Scripts     wp_register_script( 'jquery', 'http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js');     wp_register_script( 'comment-reply', get_bloginfo('url') . '/wp-includes/js/comment-reply.js?ver=20090102');     // Queue Scripts     wp_enqueue_script('modernizr', get_bloginfo('template_url') . '/js/modernizr-1.5.min.js', '', 1.5, false);     wp_enqueue_script('jquery', 'http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js', '', '1.4.2', true);          if ( get_option( 'thread_comments' ) ) wp_enqueue_script( 'comment-reply',  get_bloginfo('url') . '/wp-includes/js/comment-reply.js?ver=20090102', 'jquery', '', true );     }


title: Disable WordPress password reset via mails,instead notify admin about the reset request

text: How can I disable password resets via mail and notify the admin via mail about the password reset request the user has made so that he can reset it manually? So what I'm looking here,the user enters his username/email id in the lost reset form,now here instead of a password reset link being mailed to him,I want the administrator to get an notification email that the user XYZ has requested to reset the password,which the administrator can do it manually after confirming up with the user. Is there a plugin already that achieve this? I could find lot of plugins that only disable password reset for users.


title: Return Taxonomy Name for Each Term

text:
I am returning a list of the terms from three different taxonomies.               $terms = get_terms(array("air-categories","web-categories","ink-categories"));      I get the list and I need each to link to a different section of my site based on what taxonomy they are in but I can't seem to think of a way to return an if statement for which taxonomy each term is in.               global $post;     $published_posts = wp_count_posts()->publish;     $terms = get_terms(array("air-categories","web-categories","ink-categories"));         $count = count($terms);         if ( $count > 0 ){             echo "
";             foreach ( $terms as $term )             {                 $c = $term->count;                 $term_percent = log($c)*5;                                                         echo "
" . $term->name . "". $term->count ."
";             }             echo "
";                                                      }         wp_reset_query();


title: Limiting the amount of posts retrieved by the loop

text: I'm using a theme which has its own homepage which is created using the theme options (i.e. so can't add content under Pages) so I'm trying to add the latest posts on the page, I have copied the code from the blog themed page which is working great but its displaying all of the posts and I only wanted to display a pre-defined amount, probably 3 but I want to test it out. I'm assuming the function I've attached below is retrieving every post I've made but I don't know much about PHP so I don't know how to only retrieve x amount of posts.               <?php if ( have_posts() ) : $count = 0; ?>     <?php while ( have_posts() ) : the_post(); $count++; global $post; ?>


title: Change language for each website using multisite

text: I am using wordpress multisite and have three different sites setup; Default (English) German Japanese I've got all the sites working seperately which is fine. My theme has the .mo and .po files for german and japenese in it and I have loaded the text domain in my functions.php file like so:               function custom_theme_setup() {          // Retrieve the directory for the localization files     $lang_dir = get_template_directory() . '/languages';          // Set the theme's text domain using the unique identifier from above     load_theme_textdomain('mac', $lang_dir);          } // end custom_theme_setup     add_action('after_setup_theme', 'custom_theme_setup');      How do I change the language for each site though so that the front end of the german site uses the german PO files and the front end of the japanes site uses the japanese PO files? I want the admin area to remain in english for all three sites its just the front ends that need to change


title: Modifying navigation menu classes with a Walker

text: I did a class that extends Walker_Nav_Menu to modify the default classes of my < li >s but also to modify the default classes of my < ul >s. It seems that only the sub-menus are affected by the Walker. I would like to remove the classes and id of the first < ul > (the menu itself), but the walker won't let me do that. There are some arguments in "wp_nav_menu( array $args )" that will let me change the < ul >'s class and id, but nothing to remove them. I don't want to do:               'menu_class' => '',     'menu_id' => '',      and i'm guessing there is a solution to completely remove the class and id.


title: Add image caption to frescojs

text: I want to add the image caption to the frescojs popup. The following code is in the functions.php:               add_filter( 'wp_get_attachment_link', 'sant_prettyadd', 10, 6);     function sant_prettyadd ($content, $id, $size, $permalink, $icon, $text) {     if ($permalink) {         return $content;         }     $content = preg_replace("/<a/","post_excerpt) ) {             $output .= "                 <{$captiontag} class='wp-caption-text gallery-caption'>                 " . wptexturize($attachment->post_excerpt) . "                 </{$captiontag}>";         }      So my question is, how can I place an image caption in the pop-up? * * * Update! Edited the filter with the following code:               $args = array( 'post_type' => 'attachment', 'orderby' => 'menu_order', 'order' => 'ASC', 'post_mime_type' => 'image' ,'post_status' => null, 'numberposts' => null, 'post_parent' => $post->ID );              $attachments = get_posts($args);         if ($attachments) {             foreach ( $attachments as $attachment ) {                 $caption = $attachment->post_excerpt;             }                  if ($permalink) {                 return $content;                 }             $content = preg_replace("/<a/","ID\"", $content, 1);             return $content;         }     }      The result is that it place an caption in the popup, but from the wrong image. On every image it place the caption of 1 image. Somebody know how to loop it so it get the right image id and caption?


title: Need help setting default setting value for radio button in theme customizer

text: I need help figuring out how the radio button saves it's value in the theme settings. In my theme I added Radio buttons in the theme customizer. So far they are working great. Although I have one issue. I can't seem to set a default setting for them, so if I install my theme on a new install, or someone else does. Than whatever the radio buttons are for doesn't appear. I am not talking about the default value of the radio button itself, I am talking about the default theme customizers settings value. Here is how I create the radio buttons:                       /** Header button options */              $wp_customize->add_setting(         'header_btn_options',         array(             'default' => 'duplicatebtn',         ) );          $wp_customize->add_control(         'header_btn_options',         array(             'type' => 'radio',             'priority'   => 30,             'label' => 'Header buttons type',             'section' => 'mytheme_header',             'choices' => array(             'duplicatebtn' => 'Use hero settings',             'createcustom' => 'Use custom settings(modify below)',             'hidebtn' => 'Do not display button',              ),         )     );        Here is how I set my theme setting defaults. I do this so that when a new install is done the theme looks okay.               function mytheme_get_theme_mods() {         $defaults = array(             'mytheme_header_btn_options'     => 'duplicatebtn'     );              return $defaults;      So this is my confusion. Even though I tried setting my default to a choice from the array, it does not work. Although when I save a new value from the radio buttons on the theme customizer it works like that. So it clearly has some value just not "duplicatebtn", or maybe it is and I am doing it wrong. Can anyone please help me figure this out?


title: Add new custom field for custom taxonomy - print_r field not found

text:
Thanks to this website, I succeeded in adding a field for my custom taxonomy (my taxonomy is called "ptype"), but when I try to use the function to save the data, I don't have my custom field in the $_POST variable. Here is my code, do you see where I failed?               <?php          add_action('ptype_add_form_fields','category_edit_form_fields');     add_action('ptype_edit_form_fields','category_edit_form_fields');     add_action('ptype_add_form','category_edit_form');     add_action('ptype_edit_form','category_edit_form');          function category_edit_form_fields() {         wp_enqueue_style('wp-extends-css', plugins_url() . '/wpmarketplace/css/extends_page.css');     ?>
             <?php _e('Image de la catégorie', ''); ?>             <input type="file" id="visual" name="visual" />
          <?php      }          function category_edit_form() {     ?>              <?php      }               add_action('created_ptype','wpse_created_term',10,3);     function wpse_created_term($term_id, $tt_id) {         echo "
";         print_r($_FILES);         echo "
";              echo "
";         print_r($_POST);         echo "
";         die();     }          // On ajoute la colonne visuel au tableau des catégories     add_filter('manage_edit-ptype_columns', 'ptype_columns');     function ptype_columns($columns) {         unset($columns['description']);         $columns['visual'] = "Visuel";         return $columns;     }          // On récupère l'image ajouter à la table wp_terms()     add_filter('manage_ptype_custom_column', 'add_post_tag_column_content',10,3);     function add_post_tag_column_content($i,$column_name,$id){         wp_enqueue_style('wp-extends-css', plugins_url() . '/wpmarketplace/css/extends_page.css');         switch($column_name) {             case 'visual':                 $term = get_term($id,'ptype');                 $image = WP_CONTENT_URL."/uploads/wpmp_terms/".$term->visual;                 $str = (strlen($term->visual) > 1) ? "" : "
Nada
";                 $content .= $str;                 break;         }         return $content;     }          ...           ?>      And here is the result of the print_r function :               Array     (     )     Array     (         [action] => add-tag         [screen] => edit-ptype         [taxonomy] => ptype         [post_type] => wpmarketplace         [_wpnonce_add-tag] => 1bfcd0a2e1         [_wp_http_referer] => /gc/wp-admin/edit-tags.php?taxonomy=ptype&post_type=wpmarketplace         [tag-name] => rzer         [slug] => eferg         [parent] => -1         [description] => efgr     )      Last but not least, when I inspect the form, it has the enctype on it. So please if you can help me, I'd appreciate it ^^ ! Best regards, zed13


title: Transient Loop Not working as expected

text: So I created a transient object that used `get_posts()` to get a series of posts based on some argument. Well the transient was stored - it was created - YAY - now I tried to write this loop:               public function transient_loop($transient_name){         global $post;         if(false !== get_transient($transient_name)){             foreach(get_transient($transient_name) as $post){                 setup_postdata($post);                 $this->_loop_content();             }         }     }      This looks for the transient name, if it exists, loops over it - sets up the post data and then from there calls a method that goes through and does typical loop stuff, like images, title, links and more - all your typical jazz, Now what came back was: `Notice: Trying to get property of non-object in /var/www/wordpress/wp-includes/query.php on line 3645` The stack trace sais the last thing called was the `setup_postdata($post)` so I var dumped `$post` and got `int 1` Not sure if that's normal. So I decided to var_dump the transient - maybe a post or set of posts is not coming through at all. **Note:** I am using xdebug - thats why the object is all formatted nicely. But I did: `var_dump($transient_name)` and got back:               object(WP_Post)[259]       public 'ID' => int 1       public 'post_author' => string '1' (length=1)       public 'post_date' => string '2013-08-16 22:57:23' (length=19)       public 'post_date_gmt' => string '2013-08-16 22:57:23' (length=19)       public 'post_content' => string 'Welcome to WordPress. This is your first post. Edit or delete it, then start blogging!' (length=86)       public 'post_title' => string 'Hello world!' (length=12)       public 'post_excerpt' => string '' (length=0)       public 'post_status' => string 'publish' (length=7)       public 'comment_status' => string 'open' (length=4)       public 'ping_status' => string 'open' (length=4)       public 'post_password' => string '' (length=0)       public 'post_name' => string 'hello-world' (length=11)       public 'to_ping' => string '' (length=0)       public 'pinged' => string '' (length=0)       public 'post_modified' => string '2013-08-16 22:57:23' (length=19)       public 'post_modified_gmt' => string '2013-08-16 22:57:23' (length=19)       public 'post_content_filtered' => string '' (length=0)       public 'post_parent' => int 0       public 'guid' => string 'http://localhost/wordpress/?p=1' (length=31)       public 'menu_order' => int 0       public 'post_type' => string 'post' (length=4)       public 'post_mime_type' => string '' (length=0)       public 'comment_count' => string '1' (length=1)       public 'filter' => string 'raw' (length=3)       public 'format_content' => null      So what's with the error?


title: Efficiently manage a huge number of blogs given server-side restrictions

text: I work in a company that is built around selling the customers WordPress blogs for a monthly fee plus some up-front money for design work. The boss envisions that we will have several thousand customers, each paying something to the tune of twenty EUR per month, all handled by a single IT person working normal hours and a few salespeople/designers. We currently have about 500 active blogs in a single WordPress installation on a moderately powerful managed server. We're running on SharDB because MySQL doesn't like having 20.000 tables in the same database. Since the server's admin interface (Plesk 11) doesn't allow us to associate more than one database with a database user, SharDB has been modified so that each database uses its own separate connection with its own user credentials. This creates problems when an admin user tries to do anything. The admin interface calls `get_blogs_of_user()` on every page load, which in turn connects to each database to get the blog options etc. This means that the active connection is repeatedly closed and replaced with a different one, which means that a single page call results in 1.600 database connections being opened (vs. 60 for a normal user). This degrades performance heavily. One solution would be to split our WordPress installations. This would limit the number of database connections neccessary and thus speed things up a bit. Unfortunately it would also mean that we'd have to manage each WordPress installation separately. For instance, since we don't have shell access to the server we'd have to make any changes to files via FTP, repeating the process for every WordPress installation. Another solution would be to get a shell server and roll our own MySQL installation so we can avoid the one-DB-per-user issue but unfortunately we can't have any non-managed servers due to legal concerns – ie. in case of downtime we need to be able to shift the blame to the hosting provider, which a shell server won't allow us to do. (Blame shifting is important becaue the boss is afraid that our customers (mostly SMEs) would hit us with huge lawsuits over lost business if our server went down and we were responsible. This way we can deflect the blame to our provider and apparently that makes us safe.) Are there any other options I have overlooked? Here are **the limits** which they'd have to adhere to:   1. Must be scalable. The boss envisions a final customer base of approximately 20.000, which should be reachable with the given solution (excluding additional hardware purchases etc).   2. Can't cost serious money. Let's say that about 1 EUR per month per customer is okay.   3. Can't involve a self-administered server. Anything that requires even shell access is a no-no. We must still be able to blame the hosting provider if any downtimes occur.   4. Must be able to be administered by a single person. The business plan apparently doesn't work out if we have to pay more than one IT person full-time.   5. Must still be based on WordPress. We can't migrate our existing customers to something else; they're confused enough as it is. (We don't exactly market to the tech-savvy crowd.) That's about it.


title: How to show in search results posts with a particular tag in a particular category?

text: As the home page of my blog I've a static page. There I want to show the navigation of the site. Category1   * Sub-Category1      * tag1, tag2, tag3 Category1   * Sub-Category2      * tag1, tag2, tag3 Category2   * Sub-Category1      * tag1, tag2, tag3 Category2   * Sub-Category2      * tag1, tag2, tag3 All the above words are hyperlinks. Now what I need is, when a user clicks on tag1 under subcategory1 in category2, all the posts of category2, in subcategory1 having tag1 shall be returned. is it possible to have a URL like domain.com/category2/subcategory1/tag1 for this purpose?


title: Meta Box Not Showing up in The Admin Page

text:
Using WordPress 3.7.1 and PHP 5.4.12 I am trying to add a Meta box - text field to my Custom Post Type. My custom Post Type name is "news" and this is my code:               <?php     /* Custom Meta Boxex */     add_action('add_meta_boxes', 'my_cmbox_add');     add_action('save_post', 'save_options');     function my_cmbox_add()     {         add_meta_box(             "prodInfo-meta",             "News Source ",             "news_source",             "news",             "normal",             "low"         );     }     function news_source()     {         global $post;         $custom = get_post_custom($post->ID);         $source = $custom['source'][0];          ?>

       <?php echo 'News Source :'; ?>	       <?php echo '<input name="source" value="'. $source . '" style="width:250px;" />'; ?>

     <?php     }     function save_options()     {         global $post;         if (!isset($_POST['source']) || $post->post_type != 'news')         {             return $post;         }         update_post_meta($post->ID, "source", $_POST['source']);          }      I am not getting any error but as I said nothing show up in the page. Can you please let me know what I am doing wrong here?


title: When localizing a theme do I create the .mo and .po

text: I'm creating a theme and I want to add internationalization. I have the theme itself set up with the appropriate functions and and textdomain. What I'm curious about is the creation of .pot, .po and .mo files. Most of the tutorials I read involve creating all 3 but twentythirteen/twelve/eleven only include a POT file in the languages directory. Am I supposed to only create the .pot or am I supposed to make the .po and .mo as well? (note: this theme will not be for myself but one that I will be distributing).


title: List Post Attachments Conditionally Based on File Name

text:
I am trying to display the attachments of a custom post type based on their file name (numbering at the end) and then assign it to a title. I have 10 pre-defined titles that I want to link to a specific attachment if it's available (meaning the file is currently attached to the post), and if it can't find the file, the title won't display. So I have a ul of links with the same titles for each post of the CPT: Title 1 --> FileName-01.jpg or pdf   Title 2 --> FileName-02.jpg or pdf   Title 3 --> FileName-02.jpg or pdf   etc. HTML would be something like:

Pre-defined Title 1

Pre-defined Title 2

      If it can't find the specific file in the attachments, the title won't be displayed. So if attachment 2 is missing, Title 2 wont be displayed. Title 1 --> FileName-01.jpg or pdf   Title 3 --> FileName-02.jpg or pdf   I can do this to find the attachments minus featured image: List Post Attachments - Remove Image Thumbnails Not sure how I would filter and match the attachments though. Thanks! More info: Basically they have a library with 200+ data pages on different scientific methods/research. The data pages include different sections with research info, tables, formulas, etc (which I have set up a template for using the advanced custom fields plugin), and list with links to up to the 10 jpg/pdf files (charts, diagrams,etc). The hyperlink titles for those are always the same, just the filenames change. So, I am trying to achieve the above so that I can (and later the client) just copy the text, tables, etc into the appropriate sections of the template, and then upload all the attachments (jpg,pdf) at once (once meaning all files for each post). Then the function would list the 10 or less hyperlinks to the attached jpg,pdf files. This way I, and later the client, don't have to create the hyperlinks manually for each file. Currently I can list all attachments, but I'm not exactly sure how I would set up the array so that it automatically checks how many files have been uploaded, matches the last 2 digits of the file name to the correct title, omits the titles that don't have a matching file, and finally outputs the generated links to attached files within the post.


title: How to customize woocommerce related products?

text:
I have the following lines of code in my website that will display the **_related products_** at the bottom of my single product page in WooCommerce... **functions.php:**               // display upsells and related products within dedicated div with different column and number of products     remove_action( 'woocommerce_after_single_product_summary', 'woocommerce_output_related_products',20);     remove_action( 'woocommerce_after_single_product', 'woocommerce_output_related_products',10);     add_action( 'woocommerce_after_single_product_summary', 'woocommerce_output_related_products', 20);          function woocommerce_output_related_products() {         $output = null;              ob_start();         woocommerce_related_products(4,4);          $content = ob_get_clean();         if($content) { $output .= $content; }              echo '

' . $output;     }      As it displays 4 products that have been categorized under the same name, how would I modify the above, to display the **_related tags_** instead? For example, I have a product category called 'Automotive' and within this category, are a few tags - 'Holden', 'Ford', 'Toyota', 'Nissan' etc. I would like it to display 4 products at the bottom, related to the tag of the product the user is currently viewing.


title: Get user info on sub domain from WordPress installed on main domain

text: I have WordPress installed at **www.mainsite.com**. When visiting the sub domain **subdomain.mainsite.com** , I would like to grab the user's email address if he or she is logged in on the main site. Otherwise print NULL. I have done this using JSONP as described here but cannot authenticate the user without an ugly page refresh. I would prefer to be able to use cURL or file_get_contents. I examined the REST API but cannot get even the most rudimentary examples to work. When I try this code I get an error that says, "The OAuth2 token is invalid." My latest thinking is to use something like the Root Cookie plug in but I'm not sure how to proceed. Would need to query the user's email based on a system-wide cookie. Here is my code:               require('wp-blog-header.php');              if ( is_user_logged_in() )          {             global $current_user;             get_currentuserinfo();             $currentUserEmail = $current_user->user_email;         }          else          {             $currentUserEmail = "NULL";         }     echo $currentUserEmail;      This code works on the main domain but I need to get it working from a sub domain. Any thoughts?