How can I create a permalink with two categories, with the order based on the parent category?

Basically, I'd like to create a category permalink like example.com/books/adventure without having to make adventure a child-category because it will apply to other categories as well. So the end result is: example.com/books/adventure example.com/movies/adventure example.com/toys/adventure The order is based on the two parent categories, with "items" going first, and "genre" going second. And you could also search the categories separately to see all of the books, or all of the adventure items. How can I do this? Thanks!


custom post type upcoming post and past post

I want to retrieve inside my **archive-CPT.php** most recent upcoming post ( post with status of `future`) and past post (oldest published post). This is how my archive-CPT.php is looking like:                <?php          get_header(); ?>
              <?php if($layout == 'left_side'){ ?>                          <?php dynamic_sidebar( 'sidebar_left'); ?>                  <?php } ?>           <?php if($layout == 'both_side'){ ?>                          <?php dynamic_sidebar( 'sidebar_left' ); ?>                  <?php } ?>
         <?php                   if( have_posts() ){                  // normal blog layout                     $x = 1;                     while ( have_posts() ){                         the_post();                          if ( 0 === (int) $post->post_parent ) {                         get_template_part( 'inc/post-format/content-debate');                     }                              $x++;                     }                 }                  else{ ?>

<?php _e('Post not found', 'outbox'); ?>

<?php _e('We could not find that post you were looking for.', 'outbox'); ?>

<?php _e('Try searching', 'outbox') ?>
                 <?php echo get_search_form(); ?>                 <?php get_template_part( 'inc/recent-posts' ); ?>

             <?php }                   kriesi_pagination();                   ?>

UPCOMING DEBATES
                 <?php                 $query = new WP_Query( array(                  'post_status' => 'future',                  'orderby' => 'date',                   'order' => 'ASC',                   'posts_per_page' => 1                 ) );                   if( $query->have_posts() ) {              while( $query->have_posts() ) {              $query->the_post();              echo the_title();         }        }            ?>

         <?php if($layout == 'right_side'){ ?>                          <?php dynamic_sidebar( 'sidebar_right' ); ?>                  <?php } ?>               <?php if($layout == 'both_side'){ ?>                          <?php dynamic_sidebar( 'sidebar_right' ); ?>                  <?php } ?>
      and this code is from the **functions.php** which is for retrieving the most recent published post for the main loop :               function wpse124228_alter_ppp_order_for_mycpt( $query ) {     if ( ! $query->is_main_query() || is_admin() )         return;     if ( is_post_type_archive( 'debate' ) ) {         //Only display 1 post on mycpt archive         $query->set( 'posts_per_page', 1 );         //Most recent/current         $query->set( 'orderby', 'date' );         $query->set( 'order', 'DESC' );      }       }     add_action( 'pre_get_posts', 'wpse124228_alter_ppp_order_for_mycpt' );      Any suggestions on how can I retrieve the upcoming post and the last post titles and thumbnail images ? Eric Holmes Edit: fixed a typo in the code.


Plugins and user roles

Alot of plugins only allow for Admins to edit, and i want other roles to edit those as well. I have a wp site running WooCommerce which has a user role "shop manager" and i have a plugin that users need to be approve first before they can login. But the "shop manager" can't edit this plugin it is getting "You do not have sufficient permissions to access this page." How do i change a plugins permission?


Query set using tax_query with relation 'OR' modifies category object?

_( **Update:** Please see the edits far below.)_ The code:               function itsme_better_editions( $query ) {         if ( $query->is_category() && $query->is_main_query() ) {             $query->set( 'post_type', array( 'post' ) );             $query->set( 'tax_query',                 array(                     'relation' => 'OR',                     array(                         'taxonomy' => 'category',                         'field' => 'slug',                         'terms' => 'intl',                         'operator' => 'IN'                     )                 )             );         }         return $query;     }     add_filter( 'pre_get_posts', 'itsme_better_editions' );      I am using this function to display posts assigned to 'International (intl)' category under all categories i.e. in all category archives. (In my case categories represent _Editions_ as common with a news site, for example.) The problem is, with the function in place, it appears as though the term object of all archives gets set to 'International (intl)', be it a category archive, tag archive, custom taxonomy archive, etc. So, **for example** , if I visit the 'UK (uk)' category archive, the `<?php single_cat_title(); ?>` displays 'International' instead of 'UK'. ( **NOTE:** `single_cat_title()` is just an example, and only one of the problems caused by the change in term object.) Why is this happening? (Despite me setting `'relation' => 'OR'`.) What should I do to fix this? **PS:** Surprisingly this used to work (very positive), and I don't know in which version of WordPress this broke. **EDIT:** The problem, I just realized, appears to be that `$tax_query = $query->get( 'tax_query' );` is empty or not an array. I am not really sure why this is happening, and what's wrong with my code. **Related Question:** When/why does `'$query->get( 'tax_query' );'` return empty?


Problem with Search Results in WP (not displaying the full posts)

In this momment, in search results appear the post but without categories (I think are hidden) and with the links from posts broken. I have a piece of code in this theme that i think is responsible for this. Here is the code:               <?php $post_format = get_post_format() or $post_format = 'default'; ?>          <?php if (get_post_type() != 'post' || is_single() || !Website::getThemeOption("format_post/{$post_format}/content/hide")): ?>
<?php                 if (is_search()) {                     $sq = preg_quote(get_search_query(), '/');                     printf('
%s
', preg_replace("/\b{$sq}\b/i", '\0', get_the_content()));                      } else {                     if (has_excerpt() && !is_singular()) {                         the_excerpt();                     } else {                         the_content(Website::getThemeOption('post/readmore'));                     }                     if (is_singular()) {                         $pages = wp_link_pages(array(                             'before' => '',                             'after'  => '',                             'echo'   => false                         ));                         if ($pages) {                             printf('
%s
', preg_replace('/ ([0-9]+)/', ' \1', $pages));                         }                     }                 }             ?>
     <?php endif; ?>      I want to display in search results the full post untouched, as he is, without any restriction. This code might be the problem or something else? This theme don't have `category.php` or `search.php` and this code is from `content.php`. Is possible to fix this (maybe with a plugin)?


custom post type for custom talbe

Where would I start if I want to have a custom post created each time data was submitted from a form on the front page for non-logged in users? I have the script set up to send the data to a custom table, and to retrieve the data. I would like to put a function into a conditional that would create a post of the data that is submitted. again, the constraints would be a form on the front page or any user-facing page for non-logged in users.


Query custom taxonomy for category including children

I've using the Events Manager plugin which creates a custom post type of 'event' and a custom taxonomy called 'event-categories'. I have the category 'courses' which has an ID of 43. I also have a number of child categories under courses e.g. 'science', 'english' etc. I'm creating an autocomplete search and need to query courses based on the search term but only on posts that appear in the the post type of event, taxonomy of 'event-categories' and are tagged with the 'courses' category or any of its children. Here is what I have so far:                  global $wpdb, $table_prefix;        $em_suggestions = $wpdb->get_results("           SELECT post_name as value, post_title as label           FROM {$table_prefix}posts            WHERE post_type = 'event'            AND post_status = 'publish'            AND post_title LIKE '%$term%'            ORDER BY post_title ASC           LIMIT 0, 10        ");      I'm just struggling to apply the taxonomy filter to it.


How to check if a stylesheet is already loaded?

I was wondering how to check if a css file is already loaded. For example, I have in my theme Font Awesome `font-awesome.min.css` and I have a plugin that make use of Font Awesome too. So, I ended up with two `font-awesome.min.css` stylesheets loaded. Is there a way to check if a CSS sheet is already loaded before I enqueue it.


How to create and use Custom hooks

I am newbie in wordpress. I have just created contact us plugin for my own project. In my plugin I have used many functions you can take a look of my code. I want to make this plugin based on custom hooks instead of only PHP functions. I don't want simple plain php functions. Can you suggest me where can I add custom hooks and how to use it? I know how to add custom hooks and use it i have referred this document.. so I am clear with hooks (how to create it and use it)


Modifying the markup in the Tag Cloud widget?

I need to modify the markup of the tag cloud widget. Can someone tell me how to go about doing this without modifying any of the files outside of the theme directory so my changes don't get overwritten when updating WordPress?


custom post types, pre_get_posts, wp_list_categories

So, I know I can make this work in a roundabout way, but I think I am doing something wrong in the first place. Essentially, the situation is like this. I have a custom post type, the posts of which - depending on some conditions (time actually) should or should not show . This one I can get to work quite nicely like so (somewhat abbreviated to make this less messy)               add_action( 'pre_get_posts', array( $this, 'my_tm_pre_get_posts'));          function my_tm_pre_get_posts($query){         if (isset($query->query_vars['post_type']) && $query->query_vars['post_type']=='my_post_type') {             $array2exclude=array(1, 2, 3); /**a conditional array depending on time of day etc)**/             $query->set( 'post__not_in', $array2exclude );         }         return $query;       }      however, I also have a navigation of categories of this post type like so:               <?php          // some_args .....         'hide_empty'   => 1,         'show_count'   => 1,         // some more args...         echo wp_list_categories( $args );      ?>      which displays all the right categories of this custom post type / taxonomy. So far so good. However, if I end up excluding all post of a specific category in my_tm_pre_get_posts I would also expect (well, hope - that's what I'm trying to get to) that that particular category in wp_list_categories also gets excluded or, if the number of posts is just reduced but >0 , the count would also be reflected appropriately in the show_count.... In short, the problem that I cannot seem to figure out , is a way that reflects the excluded posts in the navigation. may that be just the count or in fact excluding a whole category if the count==0 after the pre_get_posts action Sure, when getting the "$array2exclude" above, i could also check if that means a category would be empty and then just exclude the category from the navigation. But that doesnt really address the count in the navigation, nor do I have the feeling that's the right or most elegant way to go about this one... Any help/hints/pointers appreciated. Happy to provide more code if required fo course. just trying to keep it simple


How do I override the Message-ID header of wp_mail function?

I have a custom notification function for our comments editor, who prefers to have all comments from one article threaded together in her email client. To achieve this, I'm creating a custom message-ID for the first comment on an article, then setting that as the In-Reply-To for future comment notifications. This is working to some extent - I can see the additional headers in the mail client - however, the first message is being created with TWO Message-IDs. In other words, the one I passed into the headers is NOT overriding the one Wordpress is autogenerating. Therefore, the threading doesn't work. Is this a bug with Wordpress? I don't want to resort to hunting down the actual WP_mail function and editing core code; and I'm not sure that would even work. Is this something more fundamental with PHP Mail function that I can't change perhaps?               $messageIDtoCreate = $post->ID.".".time(); // post ID, and current timestamp     add_post_meta( $post->ID, 'messageID', $messageIDtoCreate);     // add to the email headers     $message_headers .= "Message-ID: <".$messageIDtoCreate."@test.com>\n";      Thanks in advance.


Multisite: How to define and limit a Custom Post Type to specific sites?

I have 2 sites on a Multisite network: A) Primary.com B) Secondary.com The primary site has a custom post type called, "primary_site_employees." I do not want the Secondary site to have access to the "primary_site_employees" custom post type. (The Secondary employees do not work at the Primary.) I'm prepared to create a new custom post type called, "secondary_site_employees." How can I have custom post types show up only on a specific site? Thanks in advance!


Combining custom post type and post category

How can I query all the posts from either the custom post type ('videos') or with a post category ('video') in a loop? I've managed to create a query that combines the posts from a custom post type and the normal posts using the code below, but am struggling with achieving the same with a custom post type and a post category.               <?php $args = array_merge( $wp_query->query, array( 'post_type' => array( 'post', 'videos', ) ) ); query_posts( $args ); ?>          <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>      Any help would be appreciated! This is what my slides look like:               if($query->have_posts()){     while ( $query->have_posts() ) {         $query->the_post();         $carousel_slide = '
                    <a href="<?php the_permalink(); ?>">
<?php the_post_thumbnail('tile-small-thumb'); ?>

Video

<?php the_titlesmall('', '...', true, 55); ?>

';         $found_posts[] = $post->ID;         $slides[] = $carousel_slide;     }     wp_reset_postdata();      } First off, I get a `Parse error: syntax error, unexpected T_STRING` on `<?php the_post_thumbnail('tile-small-thumb'); ?>` and a `Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING` on `<h5><?php the_titlesmall('', '...', true, 55); ?></h5>`. Removing these loads the page fine, but doesn't render the links as links, but instead as `<?php the_permalink(); ?>`. If I'm just doing everything wrong here please let me know and I'll go ahead and close this question. Thanks again for you time.


Wordpress multiple user roles accessing on their information on one site?

I intend to use Wordpress for the proof-of-concept of a cloud-based SaaS application I am building. My research into multi-tenancy and Wordpress only sheds insight into multiple sites sharing the same back-end, however, I would like to have a single site but the admin section should have different user roles that can only access their relevant content and dashboard to manage and or make requests to certain data. The dashboard will be different for 3 user roles so they can achieve they desired functions effectively. Is it in any way possible for me to create new user role and assign the aforementioned rights to the specific rights (e.g. supplier, agent, tour operator)?


Custom Search Query – include only custom fields and title

I have a custom post type and I also need a custom search. I want the post title and two custom fields to be indexed/queried. I found solutions for title only and for custom fields but not for both so I tried to combine. Why doesn't this work?               function custom_search( $search, &$wp_query )     {         global $wpdb;         if ( empty( $search ) )             return $search; // skip processing - no search term in query         $q = $wp_query->query_vars;         $n = ! empty( $q['exact'] ) ? '' : '%';         $search =         $searchand = '';         foreach ( (array) $q['search_terms'] as $term ) {             $term = esc_sql( like_escape( $term ) );             $search .= "{$searchand}($wpdb->posts.post_title LIKE '{$n}{$term}{$n}')";             $searchand = ' AND ';         }         $searchand = ' OR ';         foreach ( (array) $q['search_terms'] as $term ) {             $term = esc_sql( like_escape( $term ) );             $search .= "{$searchand}(($wpdb->m.meta_key = 'wpcf-kurzbeschreibung') AND (m.meta_value  LIKE '{$n}{$term}{$n}'))";             $searchand = ' AND ';         }              if ( ! empty( $search ) ) {             $search = " AND ({$search}) ";             if ( ! is_user_logged_in() )                 $search .= " AND ($wpdb->posts.post_password = '') ";         }         return $search;     }     add_filter( 'posts_search', 'custom_search', 500, 2 );


Creat new admin url for custom post type

I have a custom post type called newsletter. Once the newsletter is created I want to create a link to download the newsletter from the admin section (the newsletter post type is not accessible from the front end of the wordpress site). When the download link is clicked it will run a function in my plugin. The question is how do I register a url with wordpress that will do such a thing? I'm sure this is something pretty simple and I'm just missing it.


Wrong IP address in comment section

I have noticed that the last few times in which I have linked to an old post of mine from my latest post, my IP address in the Comments section is wrong (sometimes my IP address appears in the form 192.x.x.x). Since I am not proxied or anything, why does this happen?


VT-resize (great alternative to timthumb) : Errors cropping (litespeed, centos 6.3)

I'm using from several months wt-resize, a script to resize images on the fly. It works very well until now... I've changed hosting provider. I'm using now Centos 6.3 (no control panel) + Litespeed (php 5.4.11) and i have following errors:               Warning: getimagesize() expects parameter 1 to be string, object given in     /home/*****/***/      Warning: basename() expects parameter 1 to be string, object given in /home/      According source page where i see this error it seems that this script isn't able anymore to return the name of the file. Do you have any workaround ? I'm asking about this script because Wordpress doesn't resize images on the fly. If you add to functions.php a new size, for example               add_image_size( 'archivio', 250, 140, true );       you resize every single image you upload online to the size 250x140 and i'm interested only to resize what i want Here's the error i have on the source page where i'm using this script                Warning:  getimagesize() expects parameter 1 to be string, object given in       /home/***/public_html/wp-content/themes/***-v16/functions.php on line 139

      Warning:  basename() expects parameter 1 to be string, object given in      /home/***/public_html/wp-content/themes/***-v16/functions.php on line 140
                 For reference: https://gist.github.com/seedprod/1367237/raw/acf4a2987ff07da6135ac2a91df5532b855ccb46/vt_resize.php More details: Previous server configuration was Centos 6.3 + Nginx + PHP 5.3.2.1. I can confirm this script was working well :(


Detecting $_GET parameters from any page + Cookie

I'm trying to create a basic affiliation system plugin that for now, will do the following:   * If it exists, read a $_GET URL parameter in _any_ page (for instance http://mysite.com/about/?affid=1234). If not skip the following two steps.   * Save it in a cookie   * Redirect to a clean URL (http://mysite.com/about/) My issue lies with the first and last parts (reading the parameter and redirecting). I don't think that add_query_var is the correct way to go with, since I just want to track the referral and not se the parameter in a query. Any thoughts? Edit: here's what I have until now:               add_action( 'template_redirect', 'test_redirect' );     function test_redirect() {       global $wp;       $wp->add_query_var('aff_id');       //cookie related stuff goes here       $current_url = add_query_arg( $wp->query_string, '', home_url( $wp->request ) );       //strip the URL parameter aff_id from $current_url???       wp_redirect( $current_url ); exit;     }      **Edit: Working code, thanks to all of you and specifically @Max who helped a lot.**               <?php add_action('init', 'affiliate_redirect');     function affiliate_redirect() {       $varname = 'aff_id';       $weeks = '4';         if( isset($_GET[$varname]) && '' != $_GET[$varname] ) {         setcookie('wp_affiliate', $_GET[$varname], time()+648000*$weeks, '/');         $pageURL = 'http';         if ( isset( $_SERVER["HTTPS"] ) && strtolower( $_SERVER["HTTPS"] ) == "on" ) {           $pageURL .= "s";         }         $pageURL .= "://";         if ($_SERVER["SERVER_PORT"] != "80") {           $pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];         } else {           $pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];         }         $url = preg_replace('/([?&])'.$varname.'=[^&]+(&|$)/','$1',$pageURL);         $last = $url[strlen($url)-1];         if ($last == '?') {           $url = substr_replace($url ,"",-1);         }         wp_redirect($url);         exit;       }     } ?>


Advanced Custom Fields - Check multiple Empty Fields

I'm building a Directory in Wordpress, and using Advanced Custom Fields for the client to populate the directory entries. One of the sections is for Social Media icons. Using the following code, I can check to see if any of the three fields (twitter / facebook / linked-in) is empty, and if empty to not show an icon:
<?php if(get_field('twitter') != ""): ?><a href="<?php the_field('twitter'); ?>" class="twitter">Twitter
     <?php else: ?><?php endif; ?>
<?php if(get_field('facebook') != ""): ?><a href="<?php the_field('facebook'); ?>" class="facebook">Facebook
     <?php else: ?><?php endif; ?>
<?php if(get_field('linked_in') != ""): ?><a href="<?php the_field('linked_in'); ?>" class="linked">Linked In
     <?php else: ?><?php endif; ?>      I need help in working how to check to see if all 3 fields are empty to show additional text. (E.g There are no social icons to display). I currently have:               <?php if(get_field('linked_in') && get_field('twitter') && get_field('facebook') != ""): ?>     There are no Social Media links to display<?php endif; ?>      However, using this code shows nothing when all 3 fields are empty - but shows the text 'There are no social...' when all 3 fields **have** values instead! I'd be very appreciative if anyone can send me in the right direction on this one. I'm pretty much still a newbie, but trying hard to learn so please be gentle!


wordpress admin security

![enter image description here](http://i.stack.imgur.com/SIklq.png) I scan my website using different tool but it shows no malicious script. But when i see in admin dashboard i see strange symbol square below body tag. i tried to check admin index file,root index file but there is nothing there.Some one place this script. Also when i tried to take backup its not allowing me to take.using backupwordpress plugin. how ever all other things working but still some thing wrong in admin. HOw to detect and remove this.


Automatically deactivate link for attachments

It's probably super easy. I know it can be done when uploading stuffs to WP but I wonder if there is a simple snippet or setting to automatically deactivate link on attachment. For example : I do not want : `<a href=""><img src="" /></a>`but I want `<img src="" />` I've veen thinking about a regex to do this but maybe there's a less tricky way to do that. Hope this is not a duplicate, I've been searching on wpse, found nothing related. Thanks in advance.


Function that get ACF fields value before saving

Rewrited question: There is a similar question HERE but I don't know how to combine it with my code. I have a function that relay on acf checkbox field. It is working fine but I have to update the post twice, because get_field(‘checkbox_field’) returns the data after the other content. Here is an example:               add_filter('wp_insert_post_data', 'my_func');     function my_func($post) {         $pageID = 123; // certain page id         $cp_field = get_field("custom_field", $pageID);         if ($post['post_type'] != 'my_post_type'             || $post['post_status'] == 'trash'         )             return $post;              if(!get_field('checkbox_field')) { // The problem field             // ... do something here             return $post;         } else {             return $post;         }     }      Any help would be greatly appreciated. Thanks.


Is there a built in method to protect pages?

I'm working on a site that seems to have page protection enabled on it, but I have no idea how it has been implemented. There doesn't appear to be a plugin installed that is doing it, and the `mu-plugins` folder does not contain anything. I was wondering if this is a built in function of WordPress that needs to be enabled somehow. Could someone please enlighten me? Here is a screenshot, if it will help, when a new page is being added or edited: ![enter image description here](http://i.stack.imgur.com/xqoaS.png)


Can't figure out why a jquery file is not loading!

I have a piece of PHP code that's supposed to load 3 jquery files. For some reason, I can only see 2 of them in the source. I can't figure out why - can anyone help me please? Website: www.goinspire.com My code:               add_action( 'wp_print_scripts', 'add_my_jquery', 1 );          function add_my_jquery(){      //Custom function to load a jquery script called smoothscroll.js that puts a smoothscroll on our site          wp_enqueue_script( 'smoothup', get_template_directory_uri() . '/js/smoothscroll.js', array( 'jquery' ), '',  true );          //end          /*This part is to move the Subscribe button above the Submit button */     wp_enqueue_script( 'submitbutton', get_template_directory_uri() . '/js/submitbutton.js', array( 'jquery' ), '',  true );          //include jqueryfunctions.js, for some functions (including hotel landing page filters)     wp_enqueue_script('jqueryfunctions', get_template_directory_uri() . '/js/jqueryfunctions.js', array('jquery'), '', true);     }      Thanks in advance! Update: the one that doesn't load is jqueryfunctions.js. Thanks! Updated code:                add_filter( 'image_size_names_choose', 'custom_in_post_images' );          //END          add_action( 'wp_enqueue_scripts', 'add_my_jquery', 1 );          function add_my_jquery(){      //Custom function to load a jquery script called smoothscroll.js that puts a smoothscroll on our site          wp_enqueue_script( 'smoothup', get_template_directory_uri() . '/js/smoothscroll.js', array( 'jquery' ), '',  true );          //end          /*This part is to move the Subscribe button above the Submit button */     wp_enqueue_script( 'submitbutton', get_template_directory_uri() . '/js/submitbutton.js', array( 'jquery' ), '',  true );          //include jqueryfunctions.js, for some functions (including hotel landing page filters)     wp_enqueue_script('customjqueryfunctions', get_template_directory_uri() . '/js/customjqueryfunctions.js', array( ), '', true);     }


JQuery is only applying to first post in loop

I have a JQuery script that creates 'arrows' that allow for my textbox to be scrollable, the problem is JQuery is only apply it to the first post (you can see none of the other posts have the arrows). I think JQuery believes there is only one case (post) of the div#scroll_links so it isn't appending the up and down controls to all the 'scroll_links' id's. I have tried a couple different options but I cannot come up with a solution. Any help is appreciated thanks. Check out the link: http://dthudson.com/ccr/archive-genres/ Here is my code for the loop:               <?php              $my_query = new WP_Query( $args );                   if ($my_query->have_posts()) : while ($my_query->have_posts()) : $my_query->the_post();?>

                             <a class="hover-color" href="<?php echo get_permalink(); ?>">
<?php the_field('release_season'); ?> <?php the_field('release_year'); ?>

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

                                 <a href="<?php echo get_permalink(); ?>"><img src="<?php the_field('issue_image_cropped'); ?>" alt="photo of issue <?php the_field('issue_number'); ?>" />
poetry

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

                    <?php the_content(); ?>         <?php endwhile; endif; ?>      Here is my javascript in the footer:


First Attempt at AJAX and it keeps getting Canceled. Can't Get Results to Show

This is my first attempt at Ajax. I've got it working in the fact that the database gets the record inserted properly, however, once that's done it won't return the response that I've set up. Its as if AJAX isn't being called at all. Any help would be greatly appreciated. Here is my code:               //Enqueue Scripts     add_action( 'init', 'my_script_enqueuer' );     function my_script_enqueuer() {        wp_register_script( "growwell_script", WP_PLUGIN_URL.'/growwell_activities/js/growwell_script.js', array('jquery') );        wp_localize_script( 'growwell_script', 'myAjax', array( 'ajaxurl' => admin_url( 'admin-ajax.php' )));         wp_enqueue_script( 'growwell_script' );          }      This part is in a content filter (but outputs as expected):                   $link = admin_url('admin-ajax.php?action=gw_add_activity&wp_user_id='.$wp_user_id.'&activity_post_id='. $activity_post_id.'&nonce='.$nonce);         $content .= 'Add to My Activities';      My AJAX PHP:               add_action("wp_ajax_gw_add_activity", "gw_add_activity");     add_action("wp_ajax_nopriv_gw_add_activity", "my_must_login");          function gw_add_activity() {             if ( !wp_verify_nonce( $_REQUEST['nonce'], "gw_add_activity_nonce")) {           exit("No naughty business please");        }                $wp_user_id = $_REQUEST['wp_user_id'];        $activity_post_id = $_REQUEST['activity_post_id'];        $activity_added = current_time('mysql', 1);        global $wpdb;            $wpdb->insert(             'my_table',                 array(                 'wp_user_id' => $wp_user_id,                 'activity_post_id' => $activity_post_id,                 'date_added' => $activity_added,                 'activity_status' => 'active'                   )              );                      if(!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest') {       $result_add = json_encode($result_add);         echo $result_add;      }        else {           header("Location: ".$_SERVER["HTTP_REFERER"]);             }             exit();           }          function my_must_login() {        echo "You must be logged in to add to your activities.";        exit();     }      And Finally, my jQuery:                  jQuery(document).ready( function() {        jQuery("#add-to-activity").click( function() {             nonce = jQuery(this).attr("data-nonce")               wp_user_id = jQuery(this).attr("wp_user_id")           activity_post_id = jQuery(this).attr("activity_post_id")                jQuery.ajax({              type : "post",              dataType : "json",              url : myAjax.ajaxurl,              data : {              action: "gw_add_activity",               "wp_user_id" : wp_user_id,               "activity_post_id" : activity_post_id,               "nonce" : nonce              },          success: function(response) {                            jQuery("#gw_feedback").html('It worked...' )           }       })                })          })


Login members using web services

I want a login system which authenticate user from web services.The steps should be as follows:   1. we have few member web sites (Outside of wordpress server). Each member website have its corresponding blog which are hosted on different server.    2. We have the web service to fetch the correct authentication from member web sites.   3. I want the functionality so that when someone not logged in member web site and try to access of corresponding blog then he should be redirect to a custom login page.   4. If someone already logged in member web site then he can access the blog.   5. The wp-admin will work as it is. so someone goes to http://www.mysite.com/wp-admin then he can login with their Wordpress database credentials.   6. I am trying to create a plugin. The code which I tried so far:              add_action('wp_head', 'load_login_page');     function load_login_page(){          if(!isset($_COOKIE['login_token'])) {     echo $_COOKIE['login_token'];     wp_redirect(home_url('login'));     //exit;     }           }     // this action is executed just before the invocation of the WordPress authentication process     add_action('wp_authenticate','checkTheUserAuthentication');          function checkTheUserAuthentication() {           if ( ! is_admin() ) {               $username=$_POST['log'];      $password=$_POST['pwd'];     echo $_COOKIE['login_token'];     // try to log into the external service or database with username and password     //$ext_auth = try2AuthenticateExternalService($username,$password);     //echo "
"; print_r($ext_auth); echo '
';      // if external authentication was successful     $ext_auth[0] = 'success';     if($ext_auth[0]=='success') {               // find a way to get the user id          $uname = explode('@',$username);          $user_id = username_exists($uname[0]);           // userdata will contain all information about the user          //$userdata = get_userdata($user_id);          //$user = wp_set_current_user($user_id,$username);               // this will actually make the user authenticated as soon as the cookie is in the browser         //wp_set_auth_cookie($user_id);         $path = parse_url(get_option('siteurl'), PHP_URL_PATH);         $host = parse_url(get_option('siteurl'), PHP_URL_HOST);         //$expiry = strtotime('+1 month');         $expiry = time() + (60 * 1);         setcookie('login_token', $ext_auth[0], $expiry, $path, $host);          // the wp_login action is used by a lot of plugins, just decide if you need it         do_action('wp_login',$userdata->ID);         //determine WordPress user account to impersonate              // you can redirect the authenticated user to the "logged-in-page", define('MY_PROFILE_PAGE',1); f.e. first         header("Location:http://executiveboard/audit-blog");         return 'success';          }     }      else{     echo 'I am at admin';     header("Location:http://executiveboard/audit-blog/login");     return 'fail';         }                }      function try2AuthenticateExternalService($username, $password){      require_once realpath (__DIR__ . '/sbws.php');      $lSbws = new SBWS\Sbws (__DIR__ . '/use/config.ini');     $svcLogin = $lSbws->getwebservice ('login');      try      {         $post_data = array ('user_name' => 'sumsood@executiveboard.com', 'password' => 'gudda@123', 'remember_login' => false);         $result  = $svcLogin->setdata ($post_data)->loginUsingUsrPwd ();      }      catch (SBWS\Sbws_Login_Exception $e)     {        echo "received " . $e->getMessage () . PHP_EOL;        $result = false;     }          //echo __FILE__ . ' ' . __LINE__ . '
';       print_r( $result); print '
'; // DEBUG-HANS      return $result;           }


Download button for wp audio player

I'd like to add a download button to the core wp audio player (mediaelement.js). How can I do that simply? Any suggestions?


Wrong loop results with a several category queries

Here is the code of my category.php page:               <?php get_header(); ?>          <?php get_sidebar(); ?>
     <?php     $category = get_category( get_query_var( 'cat' ) );$cat_id = $category->cat_ID; ?>     <?php               query_posts('cat='.$cat_id.'order=rand&numberposts=-1'); ?>     <?php if (have_posts()) : ?>         <?php while (have_posts()) : the_post(); ?>              <div class="post" id="post-<?php the_ID(); ?>">

<a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?>
                                                                    Posted <?php the_time('F jS') ?> by <?php the_author() ?> in <?php the_category(', ') ?>
                  <?php echo "ID, "image", true) . "' />"; ?>

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

           <?php $posts = get_posts('orderby=rand&numberposts=5'); foreach($posts as $post) { ?>         <div class="menu-list-item" id="post-<?php the_ID(); ?>">
                 <a class="menu-item"href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>">                 <?php echo "ID, "image", true) . "' />"; ?>
             <a class="menu-item" href="<?php the_permalink() ?>" ><?php the_title(); ?>

     <?php } ?>
          <?php get_footer(); ?>      **Here are the wrong results in html source:**               <?php get_header(); ?>          <?php get_sidebar(); ?>

Off The Path
                      Posted décembre 26th by admin in On the Side

The Market
                      Posted décembre 26th by admin in On the Side

The Potato Patch
                      Posted décembre 26th by admin in On the Side

California Roll [Crab Stick, Cucumber, Avocado, Caviar]
                      Posted décembre 26th by admin in From Japan

Sushi Plate [8 pcs)
                      Posted décembre 26th by admin in From Japan

Shrimp Biryani [Prawns Cooked with Garam Masala, Ginger and  Saffron Flavored Basmati Rice]
                      Posted décembre 26th by admin in From India

Thai Shrimp Curry [+White Rice]
                      Posted décembre 26th by admin in From India

Indian Shrimp Curry [+White Rice]
                      Posted décembre 26th by admin in From India

Yellow Seafood Rice [Shrimp, Calamari, Mussel]
                      Posted décembre 26th by admin in Rice

Sayadieh with Seafood [Shrimp, Calamari, Mussel]
                      Posted décembre 26th by admin in Rice

Kids Menu

Drink Menu

Full Menu

Gluten Free Menu

Nutritionals

             Shrimp Cocktail [Shrimp with our in-House Sauce]

             Shrimp with Garlic & Chili [Shrimp, garlic, chili, Parsley]

             DaVinci Cocktail [Shrimp Tossed in a Zesty Hot Sauce]

             Shrimp Biryani [Prawns Cooked with Garam Masala, Ginger and  Saffron Flavored Basmati Rice]

                                  loading ...

                 © 2013 Ignite Restaurant Group

Menu

Locations

Shack Shots

Shop

Fresh Catch

Open Door

Connect

Careers

Media Center

Contact Us

Privacy Policy

Franchise Information

                     her is the normal results that i need:               <?php get_header(); ?>          <?php get_sidebar(); ?>

Salmon Tartar Cocktail [Salmon on Cucumber Slices]
                                                                                Posted décembre 6th by admin in Get Started

Lady Fingers Fish [Ginger, Chili, Garlic and Olive Oil]
                                                                                Posted décembre 6th by admin in Get Started

Fried / Grilled Calamari [with Spicy Mayonnaise]
                                                                                Posted décembre 6th by admin in Get Started

Portuguese-Style Mussels [Garlic Braised Mussels]
                                                                                Posted décembre 6th by admin in Get Started

Chili Potato [Cubes of Potatoes with Chili and Parsley]
                                                                                Posted décembre 6th by admin in Get Started

                 Salmon Tartar Cocktail [Salmon on Cucumber Slices]

                 Off The Path

                 California Roll [Crab Stick, Cucumber, Avocado, Caviar]

                 Lady Fingers Fish [Ginger, Chili, Garlic and Olive Oil]

                 Sizzling Seafood Fajitas [Onion, Green & Red Pepper Mixed with Shrimps, Calamari & Fish]

                                          loading ...

                     © 2013 Ignite Restaurant Group

Menu

Locations

Shack Shots

Fresh Catch

Open Door

Connect

Careers

Media Center

Contact Us

Privacy Policy

Franchise Information


How to style the post previews/links without it affecting the main posts?

I am a beginner but have spent a lot of time in trying to figure this out and to no avail. Using the developer tool in Chrome I have tried to find a particular class that's unique to the posts that show as previews in the homepage of a new WP site I am creating. But all of them are also applied to the _main post_ that arrives when you click the link to the post. So, what's the solution? I want to make the home page links look most like _featured posts_ that many sites have with a rectangular shape, with the posts main image as background or something.


How to make an image of a YouTube video appear as a thumbnail in the list of blog posts

How do I post a YouTube video so that an image of the video also appears as a thumbnail in the list of posts. Here's the blog in case that helps: http://wordfruit.com/blog


Conditional tags inside a class

I have a couple of functions that I now combined in a class. The reason for that was that all these functions go towards one goal, and it is more appropriate way to use the globals between these functions. The class consists of three main sections, section one to add my meta boxes, section two adds a options page where sidebars are created, and section three which actually register the sidebars. My problem now is, section one and two only needs to run on admin side. I know how to achieve that on normal functionality. My problem is how do I achieve that inside a class. I know that you can wrap the complete class inside the `is_admin()` tag, but that doesn't work here as my sidebars are not displayed then on the front end. How can I only wrap the first two sections in the `is_admin()` tag. Here is my class               class PieterGoosen_Custom_Sidebars {         private $sdwas;              public function __construct() {                  add_action( 'add_meta_boxes', array( $this, 'add_cspp' ) );             add_action( 'save_post', array( $this, 'save_cspp' ) );             add_action( 'admin_init', array( $this, 'init' ) );             add_action( 'admin_menu', array( $this, 'add_page' ) );             add_action( 'widgets_init', array( $this, 'sidebars_register' ) );              }              /*----------------------------------------------------------------------------------          *          *      Create and add meta box to page edit screen          *          *---------------------------------------------------------------------------------*/              public function add_cspp() {                  //Meta box in page screen             add_meta_box(                  'custom_sidebar_per_page',                  __( 'Sidebar options', 'pietergoosen' ),                  array( $this, 'cspp_link' ),                 'page',                  'side',                  'high'             );                  // Meta box in post screen             add_meta_box(                  'custom_sidebar_per_page',                  __( 'Sidebar options', 'pietergoosen' ),                  array( $this, 'cspp_link' ),                 'post',                  'side',                  'high'             );         }              public function cspp_link( $post ) {                  wp_nonce_field( 'cspp_meta_nonce', 'cspp_nonce' );                  $custom = get_post_custom($post->ID);                  if(isset($custom['_custom_sidebar_per_page']))                 $val = $custom['_custom_sidebar_per_page'][0];             else                 $val = "default";                  // The actual fields for data entry             $output = '
'.__( 'Choose a sidebar to display', 'pietergoosen' ).'
';             $output .= '<select name="custom_sidebar_per_page">';                  // Add a default option             $output .= '<option';             if($val == "default")                 $output .= ' selected="selected"';             $output .= ' value="default">'.__( 'No Specified Sidebar', 'pietergoosen' ).'</option>';                  // Fill the select element with all registered sidebars             if(!empty($this->sdwas))                 foreach($this->sdwas as $sid => $sdwa) {                       $output .= '<option';                       if($sdwa == $val)                           $output .= ' selected="selected"';                       $output .= ' value="'.$sdwa.'">'.$sdwa.'</option>';                   }                    $output .= '</select>';                    echo $output;           }               public function save_cspp($post_id){                  // Check if our nonce is set.             $nonce = filter_input(INPUT_POST, 'cspp_nonce', FILTER_SANITIZE_STRING);                  // Verify that the nonce is valid.             if ( empty($nonce) || ! wp_verify_nonce( $nonce, 'cspp_meta_nonce' ) )                 return $post_id;                  // If this is an autosave, our form has not been submitted, so we don't want to do anything.             if ( defined('DOING_AUTOSAVE') && DOING_AUTOSAVE )              return $post_id;                  // Check the user's permissions for pages.             if ( !current_user_can( 'edit_page', $post_id ) )                 return;                  // Check the user's permissions for posts.             if ( !current_user_can( 'edit_post', $post_id ) )                 return;                   /* OK, its safe for us to save the data now. */             $custom = filter_input(INPUT_POST, 'custom_sidebar_per_page', FILTER_SANITIZE_STRING);                  if(!empty( $_POST['custom_sidebar_per_page'] )) {                 update_post_meta($post_id, '_custom_sidebar_per_page', $custom);             }else{                 delete_post_meta( $post_id, '_custom_sidebar_per_page');             }         }              /*----------------------------------------------------------------------------------          *          *      Register and add a options screen under the "Appearance" menu screen.          *          Sidebars are created/deleted here.          *          *---------------------------------------------------------------------------------*/              public function init() {                  register_setting(                  'set_fields',                  'cspp_get_option',                  array( $this, 'sanitation' )             );                  add_settings_section(                  'general',                   __( 'Custom sidebars per page', 'pietergoosen' ),                  '__return_false',                  'theme_options'              );                  add_settings_field(                  'custom_sidebar_per_page',                  __( 'Custom sidebars', 'pietergoosen' ),                  array( $this, 'settings_field' ),                  'theme_options',                  'general'              );              }              public function add_page() {             add_theme_page(                 __( 'Custom Sidebars', 'pietergoosen' ),                      __( 'Custom Sidebars', 'pietergoosen' ),                      'edit_theme_options',                                        'theme_options',                                              array( $this, 'render_page' )                             );         }              public function render_page() {             if (! current_user_can('edit_theme_options') )                  return;              ?>

<?php _e( 'Custom Sidebars Per Page Options', 'pietergoosen' ); ?>

                     <?php                      _e( 'Create or remove custom sidebars that can be individually used on posts and pages', 'pietergoosen' )                     ?>
                 <form method="post" action="options.php">                 <?php                     // This prints out all hidden setting fields                     settings_fields( 'set_fields' );                      do_settings_sections( 'theme_options' );                     submit_button();                  ?>                 </form>
             <?php         }              public function sanitation( $input ) {                  $output = array();                  if ( isset( $input['_custom_sidebar_per_page'] ) ) {             $output['_custom_sidebar_per_page'] = $input['_custom_sidebar_per_page'];             }                return $output;         }              public function settings_field() {                  $option1 = get_option( 'cspp_get_option' );                  // A bit of jQuery to handle interactions (add / remove sidebars)             $val1 = '';                  $val1 .= '
';                  $val1 .= '
<input type="text" id="new_sidebar_name" />

<input class="button-primary" type="button" id="add_sidebar" value="'.__('Add', 'pietergoosen').'" />
';                  $val1 .= '
';                  // Display all custom sidebars             if(isset($option1['_custom_sidebar_per_page']) ? esc_attr($option1['_custom_sidebar_per_page']) : '') {                 $csppval = $option1['_custom_sidebar_per_page'];                 $i = 0;                      foreach($csppval as $sdwa) {                     $val1 .= '
'.$sdwa.' '.__( 'Delete', 'pietergoosen' ).'<input type="hidden" name="cspp_get_option[_custom_sidebar_per_page][]" value="'.$sdwa.'" />
';                     $i++;                 }             }                  $val1 .= '
';                  $val1 .= '
';                  echo $val1;         }              /*----------------------------------------------------------------------------------          *          *      Register the custom sidebars if a value is entered in save in the options          *          screens. Also create a sidebar ID from this value          *          *---------------------------------------------------------------------------------*/              public function sidebars_register() {                  $option2 = get_option( 'cspp_get_option' );                 if( isset($option2['_custom_sidebar_per_page']))                     $this->sdwas = $option2['_custom_sidebar_per_page'];                  if( isset($this->sdwas) && sizeof($this->sdwas) > 0) {                   foreach($this->sdwas as $sid => $sdwa) {                          register_sidebar(                         array (                             'name'          => $sdwa,                             'id'            => sanitize_title($sdwa),                             'description'   => __( 'Page specific sidebars that can be chosen per page', 'pietergoosen' ),                             'before_widget' => '',                             'after_widget'  => '',                             'before_title'  => '
',                             'after_title'   => '
',                         )                     );                 }             }         }     }          $pgsidebar = new PieterGoosen_Custom_Sidebars();      **EDIT** As @isNaN suggested, I have tried that.               public function __construct() {         if (is_admin()) {             add_action( 'add_meta_boxes', array( $this, 'add_cspp' ) );             add_action( 'save_post', array( $this, 'save_cspp' ) );             add_action( 'admin_init', array( $this, 'init' ) );             add_action( 'admin_menu', array( $this, 'add_page' ) );         }              add_action( 'widgets_init', array( $this, 'sidebars_register' ) );         }      I'm not sure if that is the correct way. All functions are still executed by using this method. It is just the hooks that are not executed as they are inside the conditional tag. I really think that there should be a way to completely wrap all relevant functions in the `is_admin()` conditional tag, not just the action hooks


Use custom posttype archive template for its related taxonomy term page?

I have a custom posttype "Mypost" which has taxonomies tax1, tax2. I want to use the "Mypost" archive template for the tax1 and tax2's term page. How can I do this?


Checking 2 dates against todays date

I am trying to display data from a custom post type, based on the date that the event will occur. The date is set in a meta box in the cpt. My code so far is:               $today = date('d/m/Y');     $p_date = get_post_meta($post->ID, '_cmb_training_date', true);     $p_date2 = get_post_meta($post->ID, '_cmb_training_start_date', true);     if($p_date > $today) {      // stuff     }      This works fine (only shows events after todays date) but I want to add in another event type (`$p_date2`) as well but if I do:               if($p_date > $today || $p_date2 > $today) {      // stuff     }      It displays all the posts from the CPT The date formats are all the same, so it's got to be with my if statement any ideas?


Any reason to be concerned by a wave of "zombie" blog signups?

I maintain a blog for a friend of mine. It's basically an aggregater of videos from other embeddable video sites, and provides a way for users to comment on those videos. Not really high-value content, but it's a suitable placeholder until we come up with a better concept for what to do with what is arguably a pretty-valuable domain name. Commenting is open without registering ... but for the most part commenting activity is very, very low. Over the past week the site has seen a spike in Wordpress new-user enrollment. These new users haven't commented on any of the videos, or interacted with the site in any other noticeable way, but they're all enrolling with .pl (Poland) email addresses, and not a single one of them has commented after enrolling. I also haven't noticed anything in my analytics that leads me to believe this is due to a referral link. So what gives? Why would users register with a blog only to not do anything with that account? Has anybody had this experience with a coordinated wave of user- registrations that led to something malicious? I've locked down commenting so that they'll only show up on the site after approval, but I'm just trying to plan ahead for what may be a coordinated attack, and would like to know if anybody has experienced this trend with sites they've operated.


Custom query_posts() parameter

I'm adding voting features to a theme. Visitors can vote posts Up or Down. I created a table for storing number of votes for each post and that works fine. Now I'm trying to sort posts by their votes. I have "voted up" and "voted down" links. For instance, when you click on "voted up" a new parameter `sort=up` is passed in the URL. In the loop if the parameter exists and is = "up" I want to loop posts with votes up.               wpdb->get_results("SELECT post_id, FROM $wpdb->votes WHERE up > 5");      This is where I want to use something like `query_posts('sort=up')` before the loop. My question is, how to I create the custom "sort" parameter?


Why doesn't remove_action work in my plugin?

Using a WordPress multisite network with Buddypress. In order to modify the top nav bar, I've written a function to replace part of the menu. Calling it thus:               add_action('bp_adminbar_menus', 'new_adminbar_blogs_menu', 6);          remove_action('bp_adminbar_menus', 'bp_adminbar_blogs_menu', 6);      Works perfectly in my functions.php, but when I try to move the above code to the plugin file, the remove_action fails to fire, but the add_action works as expected. **As a temporary solution, renaming the function folder to something appearing after Buddypress alphabetically solved the issue.**


Plugin could not be activated because it triggered a fatal error?

**Warning: Invalid argument supplied for foreach() in /.../ipn_res.php on line 28** **Warning: Invalid argument supplied for foreach() in /.../ipn_cls.php on line 30** From line 28 is a foreach loop:               foreach ($paypal_ipn->paypal_post_vars as $key=>$value) {         if (getType($key)=="string") {             eval("\$$key=\$value;");         }     }      From line 30 is also a foreach loop:               foreach($this->paypal_post_vars AS $key => $value) {         if (@get_magic_quotes_gpc()) {             $value = stripslashes($value);         }         $values[] = "$key" . "=" . urlencode($value);     }      And I think the root cause of the errors is this:               //This is located before foreach loop in ipn_res.php     require_once("ipn_cls.php");          $paypal_info = $HTTP_POST_VARS;     $paypal_ipn = new paypal_ipn($paypal_info);      The constructor of class paypal_ipn is passed with a non-array var because nothing has been sent yet that would fill out `$HTTP_POST_VARS`. Wordpress runs the code which is not the case when not in it. How do I get away from this?


Prevent WordPress from loading comments

I'm displaying the comments for a post my way, using `$comm = get_comments()` and then passing `$comm` to `wp_list_comments()` (this is the reason why). How to disable WordPress from loading comments from the database into `$wp_query`, when the comment template is being displayed ? I'm asking this because I want to avoid this extra database call, since I'm getting the comments myself using the above method. PS: I also noticed the `$comments` global variable is a array containing ALL the comments for a post, not just the ones from the current comment page. If I have a post with 10K comments, WP will load all these at once? Seems ridiculous...


How to merge two queries together

I am trying to order the posts in a category by showing the posts with images first and then posts without images last. I have managed to do that by running two queries and now I want to merge the two queries together. I have the following:               <?php     $loop = new WP_Query( array('meta_key' => '_thumbnail_id', 'cat' => 1 ) );     $loop2 = new WP_Query( array('meta_key' => '', 'cat' => 1 ) );     $mergedloops = array_merge($loop, $loop2);          while($mergedloops->have_posts()): $mergedloops->the_post(); ?>      But when I try and view the page then I get the following error:                Fatal error: Call to a member function have_posts() on a non-object in...      I then tried casting array_merge to an object, but I got the following error:               Fatal error: Call to undefined method stdClass::have_posts() in...      How can I fix this error?


How to stop PHP code running when in a child theme

I understand you can add extra CSS on top of the parent theme, but how do you remove PHP code from functions.php? I want to remove the `Masonry plugin` in `twentyfourteen` theme, and have located the piece of code on `line 254`.                   if ( is_active_sidebar( 'sidebar-3' ) ) {         wp_enqueue_script( 'jquery-masonry' );         }      If I'm editing the parent theme, I can just comment this block out `/* */`. But I'm not aware of a way to change this is my child theme.


Archives for each category on WP Multisite

I'm working on a multilingual site for a client. The easiest way to do this (for free) I found was to use WordPress Multisite Language Switcher (http://lloc.de/msls). I've been working on this site for a while and it's been working fine. I've had a requirement to include a generic template, to allow the client to set various pages as a list page. I do this by getting the category ID on the basis of the title. From here, I list the relevant posts of that category. So far so good. At the top of the page, I've to include a year dropdown for an archive of that category. This was included early in design without consultation and the client is adamant they want this in place. I've used a plugin called 'kwebble' (http://kwebble.com/projects/wp-plugin- afac) before, which, even though no longer supported, does work well and solves many problems, and definitely works on a standard single site install. My problem now is that on my archive page, I need to detect the category relating to the category of origin. I have tried outputting the category on the page and it makes no rhyme or reason. If I select 2014, I get one category (unrelated to the current). If I select 2013, I get a different category (again unrelated). All the while, these archive pages are under the URL: domain.com/blog/2014 etc. I can't seem to get it to work without the /blog/ in the URL either. I'm completely lost as to how to continue. Unfortunately I can't show the site as it's client privacy protected, but I can give samples of any code if it helps. Any help would be much appreciated.


How to declare a JS variable in an AJAX call

I'm using: `wp_localize_script( $handle, $namespace, $variables );` to declare some variables before the initial AJAX call is made, but I imagine I can't do the same thing again within a callback function? I need to declare a newly created ID for use in another function, what's the best way?


How to access custom pages

This should be a simple question. On websites like themeforest where you can buy themes others have built, when you preview the themes almost all the themes will have seperate pages for you to view seperate functionality For example if a theme has a portfolio, a blog with sidebars, a blog without sidebar, a blog with 2 sidebars. They will link you to different pages to see what each looks like. How do you do this? I mean if I just build a file called portfolio.php and put all my code to build that page, if I go to portfolio.php in the URI it isn't going to load that page, so how can I access a separate file, like portfolio.php


How to display future posts - modified query still yields 404

I have a very strange problem and I am stuck. I want the single page to display posts with the post_status of publish and future. So I added this code to my functions.php in my theme:               function display_future_posts() {         global $wp_query;         if( !is_admin() && $wp_query->is_main_query() && $wp_query->is_single()) {             $wp_query->set( 'post_status', array('future', 'publish', 'draft') );         }     }     add_action('pre_get_posts', 'display_future_posts');      This successfully changes the query. But I still see a 404 page when I'm not logged in as admin. So I traced the db queries. Here is what I found when calling print_r($wpdb->queries); :               [16] => Array         (             [0] => SELECT   wp_posts.* FROM wp_posts  WHERE 1=1  AND ( ( YEAR( post_date ) = 2014 AND MONTH( post_date ) = 9 ) ) AND wp_posts.post_name = 'my-life' AND wp_posts.post_type = 'post' AND (wp_posts.post_status = 'publish' OR wp_posts.post_status = 'future')  ORDER BY wp_posts.post_date DESC              [1] => 0.000303030014038             [2] => require('wp-blog-header.php'), wp, WP->main, WP->query_posts, WP_Query->query, WP_Query->get_posts         )          [17] => Array         (             [0] => SELECT post_id FROM wp_postmeta, wp_posts WHERE ID = post_id AND post_type = 'post' AND meta_key = '_wp_old_slug' AND meta_value = 'my-life' AND YEAR(post_date) = 2014 AND MONTH(post_date) = 9             [1] => 0.000878095626831             [2] => require('wp-blog-header.php'), require_once('wp-includes/template-loader.php'), do_action('template_redirect'), call_user_func_array, wp_old_slug_redirect         )          [18] => Array         (             [0] => SELECT ID FROM wp_posts WHERE post_name LIKE 'my-life%' AND post_type IN ('post', 'page', 'attachment') AND YEAR(post_date) = 2014 AND MONTH(post_date) = 9 AND post_status = 'publish'             [1] => 0.00031304359436             [2] => require('wp-blog-header.php'), require_once('wp-includes/template-loader.php'), do_action('template_redirect'), call_user_func_array, redirect_canonical, redirect_guess_404_permalink         )      So my query is executed, but then the function wp_old_slug_redirect() in wp- includes/query.php is called and there the function is_404() returns true. So Wordpress tries to find an old slug (which of course doesn't exist), fails and then redirects to 404. When I call print_r($wp_query); in the header.php of my theme it seems like the query was successfully modified, but strangely doesn't return any results. At least [posts] is empty. When I run [request] directly on my MySQL server I get exactly the result I'm looking for.               WP_Query Object     (         [query] => Array             (                 [page] =>                  [year] => 2014                 [monthnum] => 09                 [name] => my-life             )              [query_vars] => Array             (                 [page] => 0                 [year] => 2014                 [monthnum] => 9                 [name] => my-life                 [error] =>                  [m] =>                  [p] => 0                 [post_parent] =>                  [subpost] =>                  [subpost_id] =>                  [attachment] =>                  [attachment_id] => 0                 [static] =>                  [pagename] =>                  [page_id] => 0                 [second] =>                  [minute] =>                  [hour] =>                  [day] => 0                 [w] => 0                 [category_name] =>                  [tag] =>                  [cat] =>                  [tag_id] =>                  [author] =>                  [author_name] =>                  [feed] =>                  [tb] =>                  [paged] => 0                 [comments_popup] =>                  [meta_key] =>                  [meta_value] =>                  [preview] =>                  [s] =>                  [sentence] =>                  [fields] =>                  [menu_order] =>                  [category__in] => Array                     (                     )                      [category__not_in] => Array                     (                     )                      [category__and] => Array                     (                     )                      [post__in] => Array                     (                     )                      [post__not_in] => Array                     (                     )                      [tag__in] => Array                     (                     )                      [tag__not_in] => Array                     (                     )                      [tag__and] => Array                     (                     )                      [tag_slug__in] => Array                     (                     )                      [tag_slug__and] => Array                     (                     )                      [post_parent__in] => Array                     (                     )                      [post_parent__not_in] => Array                     (                     )                      [author__in] => Array                     (                     )                      [author__not_in] => Array                     (                     )                      [meta_query] => Array                     (                     )                      [post_status] => Array                     (                         [0] => future                         [1] => publish                     )                      [ignore_sticky_posts] =>                  [suppress_filters] =>                  [cache_results] => 1                 [update_post_term_cache] => 1                 [update_post_meta_cache] => 1                 [post_type] =>                  [posts_per_page] => 7                 [nopaging] =>                  [comments_per_page] => 50                 [no_found_rows] =>                  [order] => DESC             )              [tax_query] =>          [meta_query] => WP_Meta_Query Object             (                 [queries] => Array                     (                     )                      [relation] =>              )              [date_query] =>          [request] => SELECT   wp_posts.* FROM wp_posts  WHERE 1=1  AND ( ( YEAR( post_date ) = 2014 AND MONTH( post_date ) = 9 ) ) AND wp_posts.post_name = 'my-life' AND wp_posts.post_type = 'post' AND (wp_posts.post_status = 'publish' OR wp_posts.post_status = 'future')  ORDER BY wp_posts.post_date DESC          [posts] => Array             (             )              [post_count] => 0         [current_post] => -1         [in_the_loop] =>          [comment_count] => 0         [current_comment] => -1         [found_posts] => 1         [max_num_pages] => 0         [max_num_comment_pages] => 0         [is_single] =>          [is_preview] =>          [is_page] =>          [is_archive] =>          [is_date] =>          [is_year] =>          [is_month] =>          [is_day] =>          [is_time] =>          [is_author] =>          [is_category] =>          [is_tag] =>          [is_tax] =>          [is_search] =>          [is_feed] =>          [is_comment_feed] =>          [is_trackback] =>          [is_home] =>          [is_404] => 1         [is_comments_popup] =>          [is_paged] =>          [is_admin] =>          [is_attachment] =>          [is_singular] =>          [is_robots] =>          [is_posts_page] =>          [is_post_type_archive] =>          [query_vars_hash] => 7ce0208af83c782976286abc2d021484         [query_vars_changed] => 1         [thumbnails_cached] =>          [stopwords:WP_Query:private] =>      )      I'm out of wit. What am I doing wrong? What am I missing. I hope this question isn't too specific and it is helpful for someone else out there. Thanks! Ole


Specific folder and no thumbnail generation for media_sideload_image

I am using media_sideload_image function in WordPress to upload images automatically from another location on the web. I want to add two more pieces of functionality.   1. Add these images to a particular folder in my system, which I will specify once within the code.   2. No thumbnails should be generated for these images, just import the image and put it in the folder, and attach to the post. How can I achieve points 1 and 2? Thanks


Multiple Paginations on one Page

I have a page template which aggregates multiple CPT's in different areas of the page and displays the first post from each CPT. I'd like to add a separate pagination for each of them. Is it possible with or, preferably, without a plugin? ![enter image description here](http://i.stack.imgur.com/hxu1a.png)


How to test the outcome of a wpdb query?

I want to get all the data with the meta key of "project_id" from post meta table. I wrote a query, it should work in thoery, but I have no way to see what I get, and inject this query to my plugin doesn't generate anything. Please take a look at this query, and help me understand if it is correct, what's the formate of the outcome, How can I echo it to see what I get:               function mp_all_ids( ){     global $bp, $wpdb, $post;          $query = <<<QUERY     SELECT      project_id.post_id     FROM        $wpdb->postmeta project_id     LEFT JOIN  $wpdb->postmeta height                  on height.post_id = project_id.post_id                 and height.meta_key = 'height'     LEFT JOIN  $wpdb->postmeta width                  on width.post_id = project_id.post_id                 and width.meta_key = 'width'      WHERE       project_id.meta_key = 'project_id'     ORDER BY    project_id.meta_value+(0) ASC     QUERY;     $data = $wpdb->get_results( $query );          return apply_filters( 'mp_ids', $data );     }      Edit: the var_dump gets the following result:               array(3) {       [0]=>       object(stdClass)#457 (1) {         ["post_id"]=>         string(3) "385"       }       [1]=>       object(stdClass)#458 (1) {         ["post_id"]=>         string(3) "451"       }       [2]=>       object(stdClass)#377 (1) {         ["post_id"]=>         string(3) "453"       }     }      How can I access the 3 strings in each object?


Subscribe2 Configuration

I am trying to configure Subscribe2 to have the user select which categories they want rather than the "all or nothing" approach it seems to have. Essentially I am using WP as a CMS as opposed to a blog roll, but I currently have 2 "blogrolls" represented by displaying the most recent post on the page (they are page length posts). I would like to send an email when Cat 1 OR Cat 2 is updated, likewise with future categories, but have the user be able to select only Cat 1 emails. I have read the FAQ to no avail, is this actually supported?


Automatically send an email to list when blog is updated

I am trying to implement a system where a user makes a blog post (to a set category) and as part of that sequence, or in addition to, it does the following:   1. Create a new email based on a template   2. Populate the email with a snippet, or the excerpt text   3. Send to a predefined list To labour the point; it isn't to email everyone, just the people in the aforementioned list. Does anybody know of a plugin or email system to do this? We currently use aweber but I cannot find the functionality to dynamically insert content from the post. It seems to only be able to do send a "Blog Updated, go here to enjoy it's awesomeness" type deal. EDIT: Had a look at Subscribe2 as detailed here to no avail.


Error in Custom Taxonomy UI

Hi I'm running a site that makes heavy use of a custom taxonomy called 'Games' and using the Simple Term Meta plugin the metadata for these terms. Using pretty much a copy of the code from wordheavy.com it's working fine except for two things: it throws an error on the 'Game' taxonomy page (Warning: Missing argument 2 for game_form_fields() in **ommitted** /functions.php on line 32) and when you add a 'game' the form doesn't clear. You can find a copy of my code here. I'm not quite where to start (apart from line 32!) so any direction would be appreciated.


Multiple endpoints to same page

I'm doing a bit of AB testing, and am looking for a way to point multiple endpoints to the same page in wordpress. My site is using wordpress as it's CMS tool.               http://mysite.com/test/link1     http://mysite.com/test/link2     http://mysite.com/test/link3      I want the above URL's to point to the about page generated through wordpress               http://mysite.com/about      The specific use case is to track hits through google analytics. I've tried doing 301 redirects, but searching through referrers for your site doesn't always work. Any idea's?


Looking for a photo management solution

I need a good solution to manage a lot of photos (several thousand+). My ideal scenario is to rip my camera card onto an FTP, then, a single gallery is created from that card rip. Someone can go in to the backend to delete rejects and queue up some photos that need post processing. I'd also like to tag and categorize them for easy search-ability. I kinda thought about it and wordpress has this functionality built in if I upload the pictures as posts. It's hard to manage them because you can't see the thumbnail in the default post view. Any suggestions?


Remove admin menu, admin header and admin footer for authors

I would like to remove everything except the “form” in wp-admin/post.php I would like to do this for user role "author" only. The reason for all this: I want the wp-admin/post.php to be a page where the author only can edit the content, clean from everything else (the will be linked to the page from the mainpage...) Today I have slowed this using CSS. But that loads all unnecessary HTML, js and CSS files. Now I wonder if there’s a way to do this using PHP? Thanks in advance! edit: Se this link: http://i.stack.imgur.com/ziCg9.jpg (new users aren't allowed to post images...) I want the admin panel to only show this when authors press the "edit-post- link".               if ($current_user->user_level < 8){code here...}


paginate_links() don't properly work in search.php?

I'm using this in my search.php template …
         <?php echo get_pagination_links(); ?>
      And this is the function …               function get_pagination_links() {         global $wp_query;         $big = 999999999;              return paginate_links( array(             'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ),             'format' => '?paged=%#%',             'current' => max( 1, get_query_var('paged') ),             'total' => $wp_query->max_num_pages,             'prev_next'    => false         ) );     }      - The output works: So if I search for "test" and there are more then 10 results and the pagination shows `1 2` where `2` is a link. When clicking page `2` the address bar correctly updates to `mysite.com/search/test/page/2` but the resulting page is still number `1`. There are still the same results as on page number `1` and the pagination links are still the same - `2` is the still the link and `1` is the current page. Any ideas why that could happen? **Update** Here is where the custom function is called in the template:               <?php     /**      * The template for displaying Search Results pages      */          get_header(); ?>          <?php if ( have_posts() ) : ?>         <hgroup class="section-heading wrapper">
Results
         </hgroup>
             <?php while ( have_posts() ) : the_post(); ?>
                     <?php get_template_part( 'inc/search', 'result' ); ?>
             <?php endwhile; ?>

             <?php echo get_pagination_links(); ?>
              <?php else : ?>

Nothing found

     <?php endif; ?>          <?php get_footer(); ?>      ### Edit Using recommended code from the answer below:               /**      * Pagination links for search and archives      */          function get_pagination_links() {         global $wp_query;         $wp_query->query_vars['paged'] > 1 ? $current = $wp_query->query_vars['paged'] : $current = 1;         $big = 999999999;              return paginate_links( array(             'base' => @add_query_arg('paged','%#%'),             'format' => '?paged=%#%',             'current' => $current,             'total' => $wp_query->max_num_pages,             'prev_next'    => false         ) );     }      The pagination is working now however the "permalinks" are not exactly what I want them to be. I use `custom_pagination_base()` to have the this permalink structure:   * `mypage.com/search/term/seite/2` (where seite is the german word for page).  Is it possible to keep the permalinks working like that. The paginaton works with your code, just the permalinks look like this:   * `mypage.com/search/term?paged=2`


paginate_links issue with keyword search results

I am using paginate_links but it is building the URL in the wrong order when on a search results page with a keyword. Because of the structure of my site I am using GET for the search with a custom post type passed to the URL. Instead of               http://localhost/site/page/2/?s=s&post_type=product      It is building               http://localhost/site/?s=s&post_type=product/page/2      If I use the default previous_post_link next_post_link it works fine. Here is my pagination function. Let me know if you can figure out how I can re-order it so that it creates the proper URL.               function dl_pagination( $args = array() ) {              global $wp_query;              $total_pages = $wp_query->max_num_pages;              if ($total_pages > 1){                $current_page = max(1, get_query_var('paged'));                echo '';           echo paginate_links(array(               'base' => get_pagenum_link(1) . '%_%',               'format' => '/page/%#%',               'current' => $current_page,               'total' => $total_pages,               'prev_text' => '',               'next_text' => '',               'type' => 'list'             ));           echo '';         }     }


Plugging into the Media Library to upload images (NOT associated with any post)

**My Old Question:** > _I made a Theme with rotating banner, common thing. So I want a way for > users to select images. I think instead of implementing my own upload, I > think its better to allow users to use the Media Library, how do I do that?_ ## The New One So far, I have something like below **functions.php**               // init wordpress media upload stuff ...     if (is_admin() && isset($_GET['page']) && $_GET['page'] == 'elem_opts') {       wp_enqueue_style('thickbox');       wp_enqueue_script('media-upload');       wp_enqueue_script('thickbox');       wp_register_script('elem_adm_js', get_bloginfo('template_directory') . '/js/admin.js', array('jquery', 'media-upload', 'thickbox'));       wp_enqueue_script('elem_adm_js');     }      **admin.js**               jQuery(document).ready(function($) {         $('#elem_upload_logo').click(function() {             tb_show('', 'media-upload.php?type=image&TB_iframe=true');             return false;         });              window.send_to_editor = function (html) {             imgurl = $('img', html).attr('src');             $('input[name=elem_opts[h_image]]').val(imgurl);             tb_remove();         }     });      The media library upload thickbox pops up, I can click select files, but when I try to upload them nothing happens. In Firebug I can see the following: ![](http://imgur.com/zEBRw.png)


Programmatically add widgets to sidebars

I would like to programmatically add widgets to my two sidebars that I've got. I couldn't find any official way of doing it? I started looking in the database. I've found that it's the 'sidebars_widgets' option which puts widgets on sidebars. When looking at the options the widget names has a number added to the end like: widget_name-6. Where does that number come from? Any idea on how to fix this?


Insert widgets after theme installation

> **Possible Duplicate:**   >  Install widget on plugin activation   >  Programmatically add widgets to sidebars I'm creating a theme and after the installation it is need put the widgets. Exists any way to setup some widgets automatically? Some specific function to make it? Thanks in advance!


Adding custom menu widget to sidebar programatically

I am trying to add custom menu widget to the sidebar. I am not working on wordpress directly, but I am using an xml-rpc calls to manage worpdress site (it is possible via http://wordpress.org/extend/plugins/extended-xml-rpc-api/ plugin). I am trying to achieve this using **wp_set_sidebars_widgets** function (I think its a proper way). First I am calling **wp_get_sidebars_widgets** to receive list of active sidebars and widgets. It gives me an array like that: > Array ( [wp_inactive_widgets] => Array ( [0] => archives-2 [1] => meta-2 [2] > => search-2 [3] => categories-2 [4] => recent-posts-2 [5] => recent- > comments-2 [6] => nav_menu-2 [7] => nav_menu-3 [8] => nav_menu-4 ) > **[sidebar-1] => Array ( )** [footer-1] => Array ( ) [footer-2] => Array ( ) > [footer-3] => Array ( ) ) Now I am adding nav_menu-2 value to sidebar-1, so array looks like: > Array ( [wp_inactive_widgets] => Array ( [0] => archives-2 [1] => meta-2 [2] > => search-2 [3] => categories-2 [4] => recent-posts-2 [5] => recent- > comments-2 [6] => nav_menu-2 [7] => nav_menu-3 [8] => nav_menu-4 ) > **[sidebar-1] => Array ( [0] => nav_menu-2 )** [footer-1] => Array ( ) > [footer-2] => Array ( ) [footer-3] => Array ( ) ) Now Im sending this array with **wp_set_sidebars_widgets** and problem is, that on wordpress Ive got 8 inactive sidebars instead of custom menu in sidebar-1. Calling **wp_get_sidebars_widgets** gives me now an array: > Array ( [wp_inactive_widgets] => Array ( [0] => archives-2 [1] => meta-2 [2] > => search-2 [3] => categories-2 [4] => recent-posts-2 [5] => recent- > comments-2 [6] => nav_menu-2 [7] => nav_menu-3 [8] => nav_menu-4 ) [1] => > meta-2 [2] => search-2 [3] => categories-2 [4] => recent-posts-2 [5] => > recent-comments-2 [6] => nav_menu-2 [7] => nav_menu-3 [8] => nav_menu-4 ) Its What Im doing wrong? Maybe someone knows another way to add custom menu to sidebar?


Install widget on plugin activation

Anyone know any resources to help me install my widget when my plugin is activated?


Change Widgets Order In Plugin - Get Array Of Sidebar Widgets

> **Possible Duplicate:**   >  Programmatically add widgets to sidebars i create front-site drag and drop layout manager. I need to change widget order, when user drag widget A over widget B, but how wordpress save widgets order? I think, that i must **get array of widgets** , that's applying to current sidebar. How can i do this?


Make metabox of custom post type fully autosave- and bulk-/quick-edit compatible

I'm trying to create a custom post type and I've had the same problem that's described here; my custom meta information was properly saved, when saving manually, but got lost as soon as the autosave ajax ran at least once. So I now use the shown solution to fix this:               function save_stationinfo($post_id) {         if((defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) || (defined('DOING_AJAX') && DOING_AJAX) || isset($_REQUEST['bulk_edit'])) return;         update_post_meta($post_id, 'station_url', $_POST['station_url']);         update_post_meta($post_id, 'station_subheadline', $_POST['station_subheadline']);         update_post_meta($post_id, 'station_streams', $_POST['station_streams']);     }      But this disables the autosave functionality for all custom metadata. What I actually want is to make my metabox fully compatible with the autosave, ajax (not sure what the DOING_AJAX mode is for, though) and bulk-edit/quick-edit functionality of Wordpress, so that custom meta fields get automatically saved and I am able to add some of the fields to the quick-/bulk-edit dialog. Can anyone please help me here, or show me where I can find a tutorial for this? (Removing the if-statement doesn't help here, as it leads me back to my first problem, of course.) Thanks in advance!


Can you use add_filter() inside other function?

I'm new to WordPress, and currently developing my first plugin and currently having difficulties. How I can insert the add_filter action inside my submit function? I want the `add_filter` action to process after the user click the submit button. I have try this but it didn't work.               if(isset($_POST['btn_submit'])) {              function addContent($content = '') {                         $content .= "My content";                  return $content;         }              add_filter('the_content', 'addContent');     }      Any help would be greatly appreciated. Thanks!


Page Navigation Outside the Loop

I have a series of pages for individual products. I'd like to page between them using a navigation that sits outside of the loop.                              |              |     ( <= prev )    |    <loop>    |    ( next => )                    |              |      I've tried `posts_nav_link`. I've tried `is_paged` conditionals within the loop. I've tried everything I can think of. Anyone know how to accomplish this without hacking the hell out of WP?


A plugin where users can comment with Facebook or Twitter or OpenID

Is there any plugin where users can comment with Facebook or Twitter or OpenID...


If Else Gravatar Author Picture

Ok so i have added a custom field inside of the WordPress edit profile field where a contributor and above can add a custom image if they do not use gravatar. Now i am trying to write a if else statement and this is what i have               <?         $hasauthorpic = (the_author_meta('author_pic'));         if (function_exists('get_avatar')) { echo get_avatar( get_the_author_email(), '80' );}         else {echo '?><? $hasauthorpic ?><? ';}     ?>      What i want to try and do is if the user does have a gravatar use it unless they have specified a link to there profile pic. Or have the author_pic become higher priority even if user has gravatar. **EDIT:**               <?     $authorpic = the_author_meta('author_pic');     $gravatar = get_avatar( get_the_author_email(), '80' );         if ($authorpic);          elseif (function_exists('get_avatar'))                  echo ($gravatar);      ?>      OK so i tried the code below and that did not quite work. Maybe because i am putting this into a single-whatever.php file. The above is what i have managed to get but the only problem is when it shows it shows both the avatar and author pic link so i know i still need to add the `<img>` tags but that will be easy later. The one thing i did read is that your cant put a `true` on `the_author_meta` so i need help. If you can come up with a code to hook into the gravatar stuff then ill take it. In other words if you have a code that i can place in my functions.php file thatll work to i and i would prefer that. the field name is `author_pic` **UPDATE:** This is my final write up with the provided code from below               <?php     $authorpic = get_the_author_meta('author_pic');     $imgtagbeg = ('');     if ($authorpic)         echo $imgtagbeg,$authorpic,$imgtagend;      else         echo get_avatar( get_the_author_email(), '80' );      ?>


WordPress Multi Site Best Practice

This question is mainly to get some clarification on best practice for setting up a WordPress Multi-Site. As I have not done this before. I have outlined the scenario below. All help is greatly appreciated. Two Sites with very similar front-ends and an almost identical press section that is managed by WordPress. Site One : US Version of the site built in WordPress templates files. Press section managed from WordPress. Site Two: UK Version of the site, some pages eliminated and a portion of the press from the US site will be the same on the UK site. I see this being the correct application for WordPress Multisite. I see this running with 2 domains (site.com, site.co.uk) and running all the press clips off of one DB in Multisite with denoting a checkbox or category to apply the US clips to the UK site. I would like to know what would be the best approach for this and if the overall consensus is that this is the proper fit for WP Multi Site. Thank you in advance! JN


Share user access between two wordpress sites

Can I share user session or cookie between two entirely different websites. I have two websites www.xxx.com and www.yyy.com(different wp installation). While logged user clicks on a link page from website1 could be redirect to website2 post details page. So user should post a comment as user. Is this possible in entirely two different hosted websites ? (Most Preferred) (or) Should I do any modification like multi-site or sub domain installation. Please suggest me your ideas on this feature.


Archive subtitles for different types of archives

I would like to display a custom subtitle for the different type of archive pages. I can easily know what type of archive page I'm in (date, category, etc.) but I have found nothing online that tells me how to get meaningful information for each of the specific, archive page types. I have the following function:               function get_the_subtitle() {         global $post;         $subtitle = '';         if (is_archive()) {             $subtitle = 'Blog posts for ';         }              if (is_date()) {             $subtitle .= '2012/03';       // Real archive date here of current page         } else if (is_category()) {             $subtitle .= 'Uncategorized'; // Real archive category here of current page         } else if (is_author()) {             $subtitle .= 'admin';         // Real archive author here of current page         } else if (is_tag()) {             $subtitle .= 'tag';           // Real archive tag here of current page         }         return $subtitle;     }      Can someone please show me how to easily create the different subtitles for the specific archive pages? Filling in this function with the means to create the values would be most beneficial.


Wordpress translation loading english file

I am trying to translate a wordpress site but whatever I do the english file is always loaded. In functions.php I've set `load_theme_textdomain('twentyeleven', get_template_directory() . '/languages');` In the template page I use `<?php _e('HOME', 'twentyeleven'); ?>` And in `wp-config.php` the language is set like this (I use the qtranslate plugin)               $enabledLanguages = qtrans_getSortedLanguages();     $uri = $_SERVER['REQUEST_URI'];     $path = explode('/', $uri);          if (in_array($path[1], $enabledLanguages)) {         define('_1D1F_LANG_', $path[1]);              if (_1D1F_LANG_ == 'en') {             define('WPLANG', 'en_US'); // exception to set en_US not en_EN ;_;         }         else {             $lang = _1D1F_LANG_.'_'.strtoupper(_1D1F_LANG_);             define('WPLANG', $lang);         }     }     else {         $defaultLang = get_option('qtranslate_default_language');         define('_1D1F_LANG_', $defaultLang);         define('WPLANG', 'en_US');     }      The `WPLANG` constant is correctly set, but the en_US.mo file is always loaded not matter what happens. Anybody has an idea what I am doing wrong? I've used the same process on another site and it worked...


Best Way to Include Scripts on a Specific Template Page

This is something that has always confused me and I could use some help. I want to do four things directly above the closing body tag:   1. include jQuery (WordPress version is fine)   2. include a jQuery plugin dependent on jQuery beneath this   3. initialize the plugin directly underneath this plugin AND avoid conflict issues using $ instead of jQuery   4. do this only on specific page templates or theme files I understand that I probably should be using wp_enqueue_script, but I'm not sure if I should use that in functions.php or just directly on the page where I want it. Regarding number 3 I have seen the workarounds such as:               jQuery(function ($) {     /* You can safely use $ in this code block to reference jQuery */     });      But I'm honestly confused as to how to implement this. What's the best way to accomplish this? Thanks very much.


Content filter won't work

I'm trying to filter my content and on matches on flow I would like to change my html structure, but my rule doesn't really apply. I have the following filter which searches the first image of posts and on rule match attaching a css container. The `preg_match_all` is working but the `str_replace` doesn't               function imageFooter($content){                global $post, $posts;                preg_match_all('/<\/a>/', $post->post_content, $matches);           $to_search = $matches[0][0];           $replacement = '
'.$matches[0][0].'
';           str_replace($to_search , $replacement, $post->post_content);           return $content;              }              add_filter('the_content',   'imageFooter');


How do I mock HTTP requests for PHPUnit?

I'm writing a plugin that makes requests to the Facebook graph API. As I don't want my unit tests to actually make these requests, how would I overcome this? My method calls both `wp_remote_get` and `wp_remote_post`. Searching there does seem to be a way to mock functions using `runkit`, here I want to avoid having contributers requiring too many dependencies so would like to avoid the above method. Is there any other options? My class extends the `WP_UnitTestCase` so I'm hoping maybe there's something from the wp unit- tests that I could use?


Is it OK combined wp-include js, jquery, css?

I have combined wp-include folder JavaScript, Jquery, CSS, jquery.ui, min.css and min.js files using W3 total. JS, jquery, jquery.ui and min.js files are combined and added before tag ( w3tc) with async. Is it give any negative effect (security or performance)? I want to reduce HTTP request.