Different Queries Return Same Results

EDIT: After fiddling with the loop a bit, it somehow corrected itself. At the end of the day the code remains the same, only now it's working. * * * http://sct.io/tt95p4 - development site. Scroll down below the slider to see the two areas in question (Featured Articles and Latest News) I have two sections in one template that are using different queries to pull post excerpts and featured images. The odd behavior here is that even though I have the two separate queries, both are returning the same result. In my template page I have:               <?php     global $post;     $myposts = get_posts('numberposts=2&offset=0&category=23');     foreach($myposts as $post) :     setup_postdata($post);     ?>     ...     <?php endforeach; ?>      and the second block:               <?php     global $post;     $myposts = get_posts('numberposts=4&offset=0&category=-23');     foreach($myposts as $post) :     setup_postdata($post);     ?>     ...     <?php endforeach; ?>      So basically wanting the Featured Articles to display the 2 most recent posts from category "23", and the second block should display the 4 most recent articles _not_ in category "23". For some reason both blocks are returning the posts from category 23. I am hoping this is a simple fix and I am just missing some small detail. Thanks in advance!


How can i add all videos from youtube playlist as post?

I want to add 200 videos from YouTube playlist to my WordPress blog. Each video iframe add as each post to particular category. I searched many plugins but that's not meet my requirement.


Editing feed for thumbnails and link

I want to display post thumbnails and hyperlinks in post on my feed page. I know in templates you can copy page template and modify it, but here i am dealing with wp-includes/feed.php or wp-includes/feed-rss . I have two question   1. what can i do get to get thumbnails of post and links of post?   2. If i edit the feed template, tomorrow when wordpress updates, it will remove my custom code, how can i make it like a child-template, so my code doesn't get disturbed, when new updates come.


How do I allow Yoast SEO plugin to recognize featured image?

I was researching this question and found this answer But (1) I don't know where to place this code (assuming it is current) and (2) would it be the same for both pages and posts.


Is there a hook or a function for multisite blog deactivate or delete?

Is there a way to detect if a blog was deleted, deactivated or archived within a Multisite installation ? Something that will be the opposite of `wpmu_new_blog` I've search google, wasn't much help. Searched here found: WPMU Hook for archive or deactivate blog? This post looks relevant however they did not cover deletion nor was it confirmed working by the 'op'. Thanks


Featured image not working, because of custom user role?

I've got a weird issue. My post thumbnails aren't working with a custom role. Images can be uploaded, and when viewing the media uploader they show as attached to the relevant post. However, when calling the thumbnail is returns nothing. I am running some PHP to filter what posts the author can see, could this be the issue? Here's the role;               add_role(         'dealer',//name of role         'Dealer',//display name of role         array(//array of capabilities              'read' => TRUE,             'edit_posts' => TRUE,             'publish_posts' => TRUE,             'upload_files' => TRUE,             'edit_published_posts' => TRUE,             'delete_posts' => TRUE //to allow media to be deleted          )     );      This is one of the filters, picked up from this forum I believe;               //filter posts for dealer user     function ik_eyes_only( $wp_query )      {          if(strpos( $_SERVER[ 'REQUEST_URI' ], '/wp-admin/upload.php' ) !== false || strpos( $_SERVER[ 'REQUEST_URI' ], '/wp-admin/edit.php' ) !== false )          { //user level 5 converts to Editor              if ( !current_user_can( 'level_5' ) )                  { //restrict the query to current user                      global $current_user;                      $wp_query->set( 'author', $current_user->ID );                  }              }      }      add_filter('parse_query', 'ik_eyes_only' );      ..and this should be the other one that might be the issue..               function ml_restrict_media_library( $wp_query_obj )      {         global $current_user, $pagenow;         if( !is_a( $current_user, 'WP_User') )         return;         if( 'admin-ajax.php' != $pagenow || $_REQUEST['action'] != 'query-attachments' )         return;         if( !current_user_can('manage_media_library') )         $wp_query_obj->set('author', $current_user->ID );         return;     }     add_action('pre_get_posts','ml_restrict_media_library');      Any ideas? This one is driving me nuts!!!


'pre_user_query' - Does not affect the SQL query?

I've got an action hook that is attempting to change the WP_User_Query object to display a specific user. In this code, I have two methods (`include` and `search`). Neither seem to do anything to the results, though, they do not even affect the SQL query.               function hide_unrelated_users( $user_query ) {         global $pagenow, $current_user;              if ( !current_user_can( 'administrator' ) ) {           // Display specific users list: include (array) - List of users to be included.           $user_query->set( 'include', array( $current_user->ID) );                // Display users based on a keyword search:           // - search (string) - Searches for possible string matches on columns           $user_query->set( 'search', $current_user->ID );           // - search_columns (array) - List of columns to matches the search string           $user_query->set( 'search_columns', array('ID' ) );                var_dump( $user_query );                return $user_query;         }     }     add_action('pre_user_query','hide_unrelated_users', 12 );      The var_dump in there displays the object, which the `query_vars` looks correct and has my changes. But the `query_where` is unaffected: `[query_where] => WHERE 1=1 AND ( wp_users.ID NOT IN ( 1,10,11,12 ) )` The ID's 1, 10, 11, 12 are administrator accounts, which the user is not able view because it is a lower level than administrator. I believe this is Wordpress' default functionality. I can achieve the "single user display" with the following code (I know I did not use $wpdb, this is just for testing): `$user_query->query_where .= ' AND ( wp_users.ID = ' . $current_user->ID . ' )';` How do I make the query vars affect the SQL query though? I don't want to manually adjust the "query_where" variable - that doesn't seem like the correct solution!


Insert custom div between posts

I'm using twenty twelve and I need to insert a div between the posts. I'm not sure how to stop the loop, insert the div, and then restart the loop. Can anyone shed some light on this? Thanks.


Linebreaks behaving oddly inside blockquotes

I'm using a vanilla up-to-date WordPress install. I've noticed that the visual editor, even in text mode, does not show `<p>` or `<br>` tags, and if you insert them it strips them out and replaces them with actual linebreaks, but the rendering still seems to work out okay. What I assume is going on is that the tags are there, but the text mode editor doesn't show them. Presumably that's why it's called "text mode", not "HTML mode". However, inside blockquotes, things behave a little differently (in both the visual mode and text mode). Here's my content (copied and pasted from the text-mode):
C.S. Lewis mistakenly wrote that Susan had turned her back on Narnia, but what it really seems is that Lewis had turned his back on Susan.     Fred Clark (Slacktivist), "Redeeming Susan Pevensie”          One queen said ‘I am not a toy’, and she never returned.     Senan Mcuire, "Wicked Girls Saving Themselves”          A god who would punish me for liking nylons and parties by making me walk through that school dining room, with the flies, to identify Ed, well . . . he's enjoying himself a bit too much, isn't he? Like a cat, getting the last ounce of enjoyment out of a mouse.     Neil Gaiman, "The Problem of Susan"     I can't find this one online legally. If you can (and I know some of Neil Gaiman's stuff is legally available online, so it's possible), please let me know in the comments.          Susan is committing Lewis's cardinal sin: getting confused about what is real and what not.     Andrew Rilstone, "Lipstick on my Scholar”          [The Last Battle is] definitely the weakest of all the books from a story perspective, because Lewis seems to have abandoned entirely such minor issues as characterization, world-building, plot, and the rest, all to hammer home a series of doctrinal points.     ...     [Lewis is] eager to punish his characters and interested in how to do it.     hapax and Kit Whitfield, "The Question of Susan”          Perhaps a very great problem with Susan is that the man who wrote her and other men who write about her consider her a vapid, egotistical, un-gentle person and assert that she is so without ever feeling the need to justify this characterization on the page, with in-character actions.     ...     Denying Narnia can be a method of self-defense against being continually walled off from the outside world of which one may want desperately to be a part.     Narnia, as a place, is deeply hostile to the idea of consent.     Ana Mardoll, "Narnia: Susan, Problems of”     (See also Ana Mardoll's full Narnia deconstruction index.)          He shows beautifully. His telling—when it works it works, but in some cases, you get this weird tug-of-war where Lewis-the-writer shows you a thing and Lewis-the-narrator tells you how to feel about it, and Lewis-the-narrator is flat-out wrong.     Ursula Vernon, "Narnian Apocalyptica”          This time an entire country doesn’t have to suffer for years upon years just to act as a backdrop to some British children’s magic adventure time.     yubishines (repent, harlequin), Narnia Deconstruction discussion          You cannot keep the death-vigil for a god and go unchanged.     Ursula Vernon, "Elegant and Fine”          Susan let her tears fall freely when she and Peter heard the news.     pukingtoreador, "The Real Reason”
          And, because not everything is necessarily Narnia (or, at least, not directly),
It reminded her of Porphylia and everything she wanted to forget.     Jo Walton, "Relentlessly Mundane”          You saved our kingdom and found your self-confidence.     Randall Munroe (xkcd), "Children's Fantasy”
      In the visual mode editor, that's all squashed up. There are no breaks between each individual quote. In preview, the first blockquote behaves exactly as I want it: the reference for each quote appears directly beneath it, with no gap, and then there's a gap before the next quote. Lovely. It took ages and a lot of faffing about to get it like that, and I had to go into text mode and delete linebreaks and replace them with `<br>` tags (which then disappeared when I went back to text mode later, but obviously were still there in effect because it worked). The post hasn't been published yet, but in preview that top section looks fine. But today I added the second blockquote, at the bottom. And I tried exactly the same trick. And this time it's not working. Still, in the visual editor, everything's squashed up. But this time, in the preview, everything's spaced out. Here's an extract of the first blockquote, showing everything aligning correctly: single linebreaks where I want them, and double linebreaks where I want them: ![Screenshot of blog preview](http://i.stack.imgur.com/fUIiA.png) And here's another screenshot, showing that the second blockquote has unwanted linebreaks: ![Screenshot of blog preview](http://i.stack.imgur.com/tZ4A2.png) The backward quotation marks are, probably, another problem for another day.


Assign specific editor with custom user meta "A" to all authors with custom user meta "A" and exclude all other author access

I am looking to do the following: Logic/layout/cores:   1. All contributors select a **school** in a custom user profile meta field    2. All contributors also select a **club** in a custom user profile meta field    3. Editors also select a **school** and a **club** (same profile fields as above) Goal: **The editor (user role) that has School A and Club B stored as custom user values can view/edit/publish posts made _ONLY_ by contributors (user role) who also have School A and Club B stored as custom user values.** All contributors should only be able to read/view their articles and media. (I currently am able to do that with this) Based on this, I believe I'll need to be working with the following:               user_has_cap     get currentuserinfo     get_user_meta      By going through the following:   * Check current logged in user ID, user role, custom meta - SCHOOL, and custom meta - CLUB. Store values.   * If logged in user is an EDITOR, allow EDITOR to see all other users' posts ONLY if the other users have identical custom meta - SCHOOL **and** custom meta - CLUB values (to the EDITOR).   * If logged in user is a CONTRIBUTOR, allow user to only see its own posts. Does anyone have any ideas about how to best tackle this? Any guidance is **much** appreciated!


Getting trackpacks/pingbacks for a post via wordpress?

Is there a way for someone to query the wordpress API of a blog in order to get the pingbacks/trackbacks for a post? E.g a blog is hosted on example.com. I want to query example.com's wordpress API to get a list of its posts, and for each post I want to query it, to get a list of the trackbacks. Is that possible?


Create a new post within another post

i'm using ACF (http://www.advancedcustomfields.com/) to create relations between my custom post types. I have a post type 'events' and another type 'dates'. So i'm able to assign one or more dates to an event. What i want to achieve is to create a new date (= new custom post type 'date') within the event editing mask, without leaving the event mask. Like a taxonomy, but with own custom post types. Ever seen something like this? I hope, this is understandable. Thanks in advance for any ideas.


Insert post into subsite using code

I have a custom post type set up on a subsite in a multisite network which the code is in a plugin to activate it only for the subsite. I have some code that inserts a post using code but I belive it is trying to insert it into the main site. it is simply a php page with require( $_SERVER['DOCUMENT_ROOT'] . '/wp-load.php' ); then some $_POST to grab some data and use that to create a post. This works fine in a standalone install of WordPress but on the multisite it does not work. Is there a way to choose the site to add the post to?


Email user on wordpress upgrade

I'm pretty new to WordPress and i'm trying to customise my theme to send an email to myself when a upgrade is required. I'd rather not use a plugin as this means I have to install it for each wordpress site. The code below is based from the update notifier plugin.               add_action('check_updates_daily', 'check_updates');          function check_updates_daily() {         if (!wp_next_scheduled('check_updates')) {             wp_schedule_event(time(), 'daily', 'check_updates');         }     }          function check_updates() {              $update_core = get_site_transient( 'update_core' );         if (!empty($update_core) && isset($update_core->updates) && is_array($update_core->updates)                 && isset($update_core->updates[0]->response) && 'upgrade' == $update_core->updates[0]->response)          {             $newversion = $update_core->updates[0]->current;             $oldversion = $update_core->version_checked;             $blogurl = esc_url( home_url() );             $message = "It's time to update the version of WordPress running at $blogurl from version $oldversion to $newversion.\n\n";                  // don't let $wp_version mangling plugins mess this up             if (!preg_match( '/^(\d+\.)?(\d+\.)?(\d+)$/', $oldversion)) {                 include( ABSPATH . WPINC . '/version.php' );                 $message = $wp_version == $newversion ? '' : "It's time to update the version of WordPress running at $blogurl from version $wp_version to $newversion.\n\n";             }                }                     //Send email         if (!empty($message)) {                       $subject = apply_filters( 'updatenotifier_subject', 'Updates are available for '.get_bloginfo('name').'.');                  wp_mail('email@email.com', $subject, $message);              }     }      I did change it to check hourly to test if it worked but I didn't recieve any emails I also secheduled it to just send an email without checking for updates and this also didn't work. Any help appreciated, thanks =D


identify and delete spam comments from 3000 pending comments

i have a wordpress site that has more than 3000 pending and 0 spam comments. i want to identify and delete only spams. there are ways to delete all pending but i want to first identify spams and then delte them. There was no spam guard plugin earlier. I have just installed akismet. using wordpress 3.2. Please guide me.


Tags in Wordpress 3.2

Why I can't add tags since Wordpress 3.2 ?! Ajax doesn't seem to work... I gonna be crazy. Any help please ?


my theme breaks WP export

I know this is a vague question, please just spend time on it if you are in the mood, I don't need to be flamed for not being more precise. I'm having a problem with a theme I'm developing, for some reason it breaks the export function of WordPress. I'm not asking for anyone to solve my problems here, but after having spend some hours on it now, I'd like to ask, if anyone recognizes this problem, and would give me a hint as to in what direction to look for the problem. Somehow I have a feeling it has to do with a nonce check failure, but not sure.. Anyway the problem is, that if i click the Export button in the page               http://www.myserver.com/wp-admin/export.php      then I get the WP Failure Notice Screen. The url I'm taking to is this:               http://www.myserver.com/wp-admin/export.php?download=true&content=all&cat=0&post_author=0&post_start_date=0&post_end_date=0&post_status=0&page_author=0&page_start_date=0&page_end_date=0&page_status=0&submit=Download+Export+File      and the page says: Are you sure you want to do this? Please try again. I think this must be coming from wp_explain_nonce() inside wp- includes/functions.php If I switch to the twenty ten theme the problem is gone. Back to my theme, and it's there, so it must be the theme.. Any advice on where to look or how to approach catching the bug in my theme is welcome.


How to enable comments for pending and draft posts?

I have a custom post type with comments enabled. The comments metabox in the admin only appears when the post is published. I'm wanting to use the comments system as more of a discussion between certain authors (it will be hidden on the front end) so I would like the commenting system to be active when the posts are draft, pending or published. Is this possible? I should note that I have tried the edit flow plugin which has the "editorial comments" feature, however it introduces more issues with capabilities etc and doesn't suit what I am trying to achieve.


Create Custom Admin Fields

I'm looking to create custom admin options/menu/fields (I'm not positive on the correct terminology) and would like some guidance. I found a post here which does speak about it in the answer: Tips for using WordPress as a CMS? I would like to create a field like the 'Attorneys' menu shown in @MikeSchinkel 's answer. If you know a page that has instructions on best practise to create this could you please link me? I have searched the net for hours on end for a solution and the best I came up with is the 'Custom Post Type UI' (https://wordpress.org/plugins/custom-post- type-ui/) plugin which does not give me the flexibility I need. Thank you in advance!


get_terms on save_post hook

Usually, if I want to check for some attribute of the post I'm about to publish, I will check like this:               $post_title = $_POST['post_title'];      post_title is the name of the title field in the edit window. I thought I'd apply the same logic to the taxonomy meta box.               $formats = $_POST['tax_input[formats][]'];      Essentially, I'm trying to check if a specific taxonomy term is being selected when I publish a post.


Plugin Not Working After Being Uploaded To Wordpress Plugin Repository

Why my wordpress plugin is not working after I uploaded it to wordpress plugin repository. Is there any requirement of what tool I should use to write it or may be something else? Here is my plugin repository http://plugins.svn.wordpress.org/ind- css3-pricing-table/


Skeleton Child Theme Add Icon Bar to Header Flex Grid

Skeleton Child Theme Version 1.6 WordPress Version 3.4.2 Child Theme installed on main Multisite: public_html, wp-content, themes. My CSS, PHP Coding skills = NOVICE **What I've done:** Using the Theme Options, Extra Header Text menu I added four text links and a 10 icon (24x24px)social media icon bar in the upper right of the 960px header. I used p on the line with the four text links. These links are above the icon bar. I used img src with float left (5px) margin right padding to space the icons on one line. I did not add to or change style.scc or header.php or functions.php.
<a href="http://.......
           I just cut and pasted the img src lines for all 10 icons. The icons are not linked to anything yet. I know there must be an elegant CSS way of styling the in-line list of icons, but I don't know how to do it. I have no idea how to call functions, open or close hooks or filters -- so if the solution involves these or similar coding skills so pease be gentle on me and explain _in what file and in what part of the file_ the new code might go. The skeleton child theme functions.php file contains a lot of comments that explain how and when functions are called but I'm not certain what is enabled and what is not, or how to figure out what templates are used, if they are being used, when they are being used, where they are located or how to alter them. Yes, I know, taking a college level course in PHP would be helpful! :-P **Problem:** When resizing or viewing on an iPhone, the four text links overlap just above the logo image (this looks okay) -- but the icon bar slides to the left to OVERLAP the logo image. The icon images are on top of the logo image -- this is NOT ok. **What I'd like to do:** On normal 960px size I'd like the four text links and the icon bar to be top right justified, or centered, _in line with the logo image._ On resizing the grid I'd like the four text links to slide above the logo image and the icon bar to slide below the logo image. (Or they can both slide below the logo image as long as the text links are stacked above the icon bar). **What I'd like NOT to do:** Add the four text links ABOVE the header in 960px, no (maybe... aligned right). Add the icon bar BELOW the header in 960px, no. **What I think might work:** Somewhere in the function st_header_open() values there must be a way to section the header grid into two parts (instead of one large 960px space) so the logo image is on the left and the four text links and icon bar is on the right; when the page re-sizes the right half of the header slides under the left half. Or perhaps three parts, one on the left with the logo image and two on the right; the top one containing the four text links, and the bottom one containing the icon bar. Ideally, I'd like to know how to section the header however I wish and be able to control how each section stacks in iPhone view. A link to a general tutorial on this would be great I haven't yet found one that a novice at my level can grasp. **Question:** Is the above possible through the Theme Options, Extra Header Text edit window or do I need to change the child theme php file(s)? An explanation and step by step (especially where the new code would go, in what file _and in what part of the file)_ for a NOVICE WP tinkerer would be most appreciated. Any clue as to how change the background color of the above header space(s) would be most appreciated as well. Thanks


How do I use a color from theme options?

I am building a theme, and in the options I have created a place for link color. I cant seem to get this into the theme in any reasonable way. The best I can do is to put it after `wp_head` ... but that doesn't seem right. The color will be a hex color so I cant just set up style sheets for a fixed number of colors and enqueue one of those conditionally. I suppose I could do this with jQuery but I really hope to not have to resort to that. I imagine all I am looking for is some way to enqueue an inline style, but does such a concept exist and if not what is the best way to go about it. I really thought link color options and the like would be commonplace and easy to implement.


password protect individual pages

Is it possible to password protect individual pages with Wordpress? What I'm trying to do is have special pages suche as somesite.com/project1 which has a username and password that I can set, but somesite.com/project2 has a different username and password. And so on and so forth, with new usernames and passwords for new pages created down the line. Thanks in advance!


Two embedded gallery in one post

I've a nice question for you. Is there an easy way, to embed two galleries in the same post? I refer to the wordpress embedded gallery. Using a plugin of-course. Is there outside a plugin other than Easy Gallery Manager that can accomplish this goals? Must I write a new plugin?


Add settings fields on options discussion admin page

## Problem description I'm searching for a way to add a settings section/settings fields to the `~/wp-admin/options-discussion.php` page exactly where Core calls…               do_settings_sections('discussion');      ## How to When I register the setting and add the settings field, nothing appears:               function register_setting()     {         register_setting(              'discussion'             ,$this->option_name             ,array( $this, 'sanitize_setting' )         );     }          public function add_settings_field()     {         add_settings_field(              $this->option_name             ,__( 'Label', 'wpse_textdomain' )             ,array( $this, 'render_field' )             ,'discussion'             ,'discussion'             ,array()         );     }      ## Debug/inspect Now I was curious why nothing appeared and dumped the global that holds the settings section right below that line in core:               var_dump( $GLOBALS['wp_settings_sections'] );      The output was a plain simple `NULL`. ## Question > How does one register a settting there, **without** registering the section > with `add_settings_section( 'discussion', __( 'Title', 'textdomain' ), > 'callback', 'discussion' );` first? ## Reason The reason why I ask for _"without registering the setting without the section"_ is plain simple: If another plugin registers the same section afterwards, it would overwrite/override the added section. **EDIT** To make it more clear what I'm asking for. I'm aware that there're two sections `default` & `avatars` already present on the page and that I can hook in there. Point is that I don't want to hook into existing core feature settings, but _below_ them, right into the settings sections that core _should_ output with `do_settings_sections( 'discussion' );`. Point also is, that the `discussion` page was never registered by core and therefore can't get used as `do_settings_section()` aborts without being able to loop through any (not) registered pages. I'm fully ok with an answer that confirms that and states: _No, doesn't work. Is a bug._ or **even better** creates or helps creating _a patch_.


How to mark a image attachment as background image?

I am trying to add a functionality to mark a post's attachment id as a background image. Basically, I would like to replicate the post thumbnail functionality: in the image attachment details, the user would click on a "Use as post background" link / button, and that image would be set as the post background. I've been googling to find something similar to custom fields but for image attachments, but have not found anything. Any ideas?


Add a reset button to the options page (using Settings API)?

How do I add a reset button using the Settings API? I use add_settings_field To add a field...is there a hook to add a reset button?


Remove "attachment/" from the URL of attachment pages

Currently, the media for a page on `/hello-world/` is shown on `/hello- world/attachment/image-name/`. Is it possible to remove `attachment` from this URL, and make it `/hello-world/image-name/`?


Sorting tags by name

I'm displaying a lit of tags when they have a description. I'd like to sort them by name instead of by post quantity. Is there a way to do this?               <?php          $tags = get_tags();         if ($tags) {           foreach ($tags as $tag) {             if ($tag->description) {               echo '
term_id ) . '" title="' . sprintf( __( "View all posts in %s" ), $tag->name ) . '" ' . '>
' . $tag->name.'

' . $tag->description . '
';             }           }         }     ?>


How to implement styling of div in the front end using plugin admin meta box settings?

I have a plugin meta box (in the Wordpress admin) with the following fields and values: Name of the div class selector= featured_content   Font family= Verdana   Font color= #000 They are stored in the Wordpress post meta table. In the Wordpress front end, one of the content template has this div:               <div class="featured_content">     The quick brown fox jumps over the lazy dog.     </div>      How would I communicate with the Wordpress front end from my Wordpress meta box settings for that div? So that when the page is loaded containing the div class selector name of "featured_content", proper styling would be implemented based on the backend meta box settings. I am thinking of running a JS code to scan all id and class selectors then query via AJAX to retrieve the settings and implement them, but I'm not sure if this is the best way. Thank you for any tips.


How to make remove display none to this div container in post meta box?

I am adding meta box via add_meta_box hook but it is not showing in the admin panel, I double check the source code and it seems hidden because of this line:               <div class="postbox-container" id="postbox-container-2" style="display: none;">      These are all my attempts to remove this display:none but all are not working: a.) Using CSS like:               #postbox-container-2 {display:block;}      b.) Using jQuery like:               $('#postbox-container-2').css('style','');      OR               $('#postbox-container-2').show();      OR               $('#postbox-container-2').css('display','block');      OR               $('#postbox-container-2').removeAttr()('display');      How to make that div appear? Thank you for any tips.


Creating a dynamic class name in my custom widget

I have been currently building a custom widget in WordPress based on the text widget as a starting point. It seems that within the `function __construct` part of the widget, the class name is a hard coded string. I would like to make this hard coded string more dynamic by calling a separate file which has a bunch of if else statements that get chosen depending on the select option chosen by the user. This would clearly change the class on the widget front end to allow for different styling.               parent::__construct('one_in_four_widget', __('LCPS Custom Widget'), $widget_ops, $control_ops);      I tried replacing the hard coded string with an include file               parent::__construct(include( get_template_directory_uri() . '/views/one-in-four-admin.php' ), __('LCPS Custom Widget'), $widget_ops, $control_ops);      However this seems to break the admin area with numerous warnings eg > Warning: include() [function.include]: http:// wrapper is disabled in the > server configuration by allow_url_include=0 in > /Users/jonbeech/Sites/lancscps 2nd site/lancscps.dev/wp- > content/themes/lancscpstheme/functions/one-in-four-widget.php on line 33 Any thoughts would be appreciated? Is it a case of my syntax being incorrect?


Select custom posts by meta_value and sort by a different meta value

I have my query set up like this:               $article_query = new WP_Query(array(                   'meta_key' => 'issue',                   'meta_value' => $post->ID ,                   'post_type' => 'article',                  'orderby' => 'order_number',                   'order' => 'desc'                   ));             I want all the articles for an issue, sorted by the custom field 'order_number' As it is, the order is ignored. I have read I need to set meta_key to 'order_number' to enable ordering by that key, but that filters by that key aswel, resulting in no results. So, how to I sort by order_number?


Can't get plugin settings page to save data

have a simple plugin that inserts text (a Google ad) partway through the content of a single post. I'm trying to create a settings page that will let users change the ad code, and change after which paragraph the ad appears. I have spent all day reading tutorials and code, and I have a lovely settings page, but I can't figure out how to get it to actually save the data. I'm mostly following the example in Professional WordPress Plugin Development. Here's what I have:               <?php     // add plugin options     add_option( 'wpa_ad_insert_paragraph', '2' );     add_option( 'wpa_ad_insert_adcode', 'ad code goes here');          // update options     update_option( 'wpa_ad_insert_paragraph', $_POST['wpa_ad_insert_paragraph'] );     update_option( 'wpa_ad_insert_adcode', $_POST['wpa_ad_insert_adcode'] );          // Add a menu for our option page     add_action('admin_menu', 'wpa_ad_insert_add_page');     function wpa_ad_insert_add_page() {         add_options_page( 'Ad Insertion', 'Ad Insertion', 'manage_options', 'wpa_ad_insert', 'wpa_ad_insert_option_page' );     }          // Draw the option page     function wpa_ad_insert_option_page() {         ?>
             <?php screen_icon(); ?>
Ad Insertion
             <form action="options.php" method="post">                 <?php settings_fields('wpa_ad_insert_options'); ?>                 <?php do_settings_sections('wpa_ad_insert'); ?>                 <input name="Submit" type="submit" value="Save Changes" />             </form>
         <?php     }          // Register and define the settings     add_action('admin_init', 'wpa_ad_insert_admin_init');     function wpa_ad_insert_admin_init(){         register_setting(             'wpa_ad_insert_options',             'wpa_ad_insert_options',             'wpa_ad_insert_validate_options'         );         add_settings_section(             'wpa_ad_insert_main',             'Ad Insertion Settings',             'wpa_ad_insert_section_text',             'wpa_ad_insert'         );         add_settings_field(             'wpa_ad_insert_paragraph',             'Ad will appear after paragraph number:',             'wpa_ad_insert_paragraph_setting',             'wpa_ad_insert',             'wpa_ad_insert_main'         );         add_settings_field(             'wpa_ad_insert_adcode',             'Ad code:',             'wpa_ad_insert_adcode_setting',             'wpa_ad_insert',             'wpa_ad_insert_main'         );     }          function wpa_ad_insert_paragraph_setting() {         $options = get_option('wpa_ad_insert_paragraph');         $items = array("1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20");         echo "<select id='wpa_ad_insert_paragraph' name='plugin_options[wpa_ad_insert_paragraph]'>";         foreach($items as $item) {             $selected = ($options['wpa_ad_insert_paragraph']==$item) ? 'selected="selected"' : '';             echo "<option value='$item' $selected>$item</option>";         }         echo "</select>";     }          function wpa_ad_insert_adcode_setting() {         $options = get_option('wpa_ad_insert_adcode');         echo "<textarea id='wpa_ad_insert_adcode' name='plugin_options[wpa_ad_insert_adcode]' rows='7' cols='50' type='textarea'>{$options['wpa_ad_insert_adcode']}</textarea>";     }               function wpa_insert_ad($content) {         $paragraphAfter = get_option('wpa_ad_insert_paragraph');         $ad = get_option('wpa_ad_insert_adcode');         if( is_single() && is_main_query() ) {             $content = explode("
", $content);             for ($i = 0; $i <count($content); $i++ ) {                 if ($i == $paragraphAfter)                    echo $content[$i] . "
";             }         }            return $content;     }     add_filter('the_content', 'wpa_insert_ad');     ?>      This code creates a settings page, but when I save the settings page, nothing happens (well, I get the yellow bar saying my settings have been saved, but the information is definitely not getting saved in the database. What am I missing here?


Filtering a WP_Query meta_query by numeric values isn't working

That was a very dense title. I have a custom post type "event" which has a Date/Time picker field "event_date" thanks to the Advanced Custom Fields plugin. This Date/Time picker saves a UNIX timestamp to the database. I'm trying to use WP_Query to get all events that are today or in the future. This is the code that I have right now:               $args = Array(         'post_type'         => 'event',         'posts_per_page'    => -1,         'meta_key'          => 'event_date',         'orderby'           => 'meta_value_num',         'order'             => 'ASC',         'meta_query'        => array(                     'key'       => 'event_date',                     'compare'   => '>=',                     'value'     => intval(strtotime(date('Y-m-d'))),                     'type'      => 'numeric'         ),     );          $query = new WP_Query( $args );      It's giving me all the events, past and future. I realize that the timestamps are stored as strings in the database so 'compare' => '>=' normally wouldn't work, but what what I've read on Google and in the Codex that 'type' => 'numeric' should cast the string to an integer and allow it to be compared with my value of this morning at midnight. Unfortunately that doesn't seem to be working and I don't understand why.


Assigning tags to user?

Does anyone know a way (either programmatically or plugin) to assign tags to users. I want to build a list of user interests as tags so I can match related content to their interests? Cheers, Chris.


I want only my sub-pages to be clickable in the navbar

I am building a simple website with a number of pages, each of which is grouped. Let's say my website has roughly 20 pages, grouped into 5 categories. So I want my navbar to display the 5 categories, and each category, on rollover, displays the pages created under it. Now since I am creating my pages as pages and not posts, I understand that "categories" are not available. So I am creating them as sub-pages. And I am creating each "category" as a page. My problem: I only created these "pages" for the purpose of grouping the "sub- pages" in the navbar. But none of these "pages" are actual pages, so I don't want any of them to be clickable. What I want is if someone clicks on the "page" itself in the navbar, they should be taken to the first sub-page of that category (or page). I would be grateful for any solutions. (Side note: This seems like an extremely common situation, and yet, after hunting around for quite a while, I see nothing addressing the issue. I'm a web programmer with over a decade experience, but a relative newbie to wp, and I find this kind of situation repeating itself over and over.)


How can I remove a menu item programmatically?

I'm using the built in menu manager to create my menues and I disaply them by using `wp_nav_menu()`. I'm wondering, is it possible to remove certain menu items from being displayed based on some specific condition?


Select Options Meta Data is Not Updating in Edit Meta Box

I have a Meta box with two user inputs 1: Text-field and 2:a Select drop Down options. I used following Save Method in mt Meta box and second part of the code belong to saving the Selected option from drop down.               function save_options(){     global $post;     if (!isset($_POST['price']) || $post->post_type != 'product')     {         return $post;     }     update_post_meta($post->ID, "price", $_POST['price']);          if (!isset($_POST['nyc_borough']) || $post->post_type != 'product')     {         return $post;     }     update_post_meta($post->ID, "nyc_borough", $_POST['nyc_borough']);     }      Everything works fine so far an I am even able to retrieve the selected value in a custom Column, however when I go to Edit Product session the Drop down options always shows the first Item selected( As Default). So I have to update the select box again otherwise it is going to select the first Item and update the metadata! Can you please let me know why this is happening and how I can prevent it? Thanks for you time and comments


How to show Categories and Sub-categories using WooCommerce

I would like to know how to display all the categories and subcategories on my WooCommerce archive-product page. (The shop index page). I am aware you can go to the WooCommerce admin in Catalog options and tick show categories, however this displays images of the parent categories. I am looking for something exactly like this.. http://www.simonandsimononline.com/shirts.html As you can see on the left, I want some function to output all the categories and subcategories as links (no images).


Prevent duplicate pages from being added

Im using this code to prevent duplicate post from being added but i also need to prevent duplicate pages too. Can Someone please help?               function clearDuplicatePosts(){         global $wpdb;         $prefix = $wpdb->prefix;         $wpdb->query("DELETE bad_rows . * FROM ".$prefix."posts AS bad_rows INNER JOIN (         SELECT ".$prefix."posts.post_title, MIN( ".$prefix."posts.ID ) AS min_id         FROM ".$prefix."posts         GROUP BY post_title         HAVING COUNT( * ) >1         ) AS good_rows ON ( good_rows.post_title = bad_rows.post_title         AND good_rows.min_id <> bad_rows.ID )");     }      add_action('publish_post', 'clearDuplicatePosts');


after wordpress update to 3.5+ i get error in this plugin. I do not understand how to fix it. If anyone can help me with these problem or give me an example of how to fix it here is the full code of the plugin: http://pastebin.com/pVUXjWat the errors i get:               WordPress database error You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'wp_jsrm_menus' at line 1 for query SHOW TABLES LIKE wp_jsrm_menus made by activate_plugin, do_action('activate_simple-retail-menus/simple-retail-menus.php'), call_user_func_array, jsrm_activate_loop, jsrm_activate     WordPress database error You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'wp_jsrm_items' at line 1 for query SHOW TABLES LIKE wp_jsrm_items made by activate_plugin, do_action('activate_simple-retail-menus/simple-retail-menus.php'), call_user_func_array, jsrm_activate_loop, jsrm_activate     WordPress database error You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'wp_jsrm_menus' at line 1 for query SHOW TABLES LIKE wp_jsrm_menus made by do_action('activate_simple-retail-menus/simple-retail-menus.php'), call_user_func_array, jsrm_activate_loop, jsrm_activate     WordPress database error You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'wp_jsrm_items' at line 1 for query SHOW TABLES LIKE wp_jsrm_items made by do_action('activate_simple-retail-menus/simple-retail-menus.php'), call_user_func_array, jsrm_activate_loop, jsrm_activate     WordPress database error You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'wp_jsrm_menus' at line 1 for query SHOW TABLES LIKE wp_jsrm_menus made by do_action('activate_simple-retail-menus/simple-retail-menus.php'), call_user_func_array, jsrm_activate_loop, jsrm_activate     WordPress database error You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'wp_jsrm_items' at line 1 for query SHOW TABLES LIKE wp_jsrm_items made by do_action('activate_simple-retail-menus/simple-retail-menus.php'), call_user_func_array, jsrm_activate_loop, jsrm_activate     WordPress database error You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'wp_jsrm_menus' at line 1 for query SHOW TABLES LIKE wp_jsrm_menus made by activate_plugin, do_action('activate_simple-retail-menus/simple-retail-menus.php'), call_user_func_array, jsrm_activate_loop, jsrm_activate     WordPress database error You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'wp_jsrm_items' at line 1 for query SHOW TABLES LIKE wp_jsrm_items made by activate_plugin, do_action('activate_simple-retail-menus/simple-retail-menus.php'), call_user_func_array, jsrm_activate_loop, jsrm_activate      all the sql queries here               function jsrm_activate() {             add_option('jsrm_val_cols', '2');                  global $wpdb;             $jsrm_menu_table = $wpdb->prefix . "jsrm_menus";             $jsrm_item_table = $wpdb->prefix . "jsrm_items";                  require_once(ABSPATH . 'wp-admin/includes/upgrade.php');                  if (!empty ($wpdb->charset))                     $charset_collate = "DEFAULT CHARACTER SET $wpdb->charset";             if (!empty ($wpdb->collate))                     $charset_collate .= " COLLATE $wpdb->collate";                  if ($wpdb->get_var( "SHOW TABLES LIKE $jsrm_menu_table") != $jsrm_menu_table){                          $sql1 = "CREATE TABLE IF NOT EXISTS $jsrm_menu_table (                                     id mediumint(9) NOT NULL AUTO_INCREMENT,                                     menuorder mediumint(9) NOT NULL,                                     name tinytext NOT NULL,                                     description text,                                     label tinytext NOT NULL,                                     itemheader tinytext NOT NULL,                                     valueheader tinytext NOT NULL,";                          for ($v=2;$v<=JSRM_VALUE_COLS;$v++){                             $sql1 .= "valueheader" . $v . " tinytext NOT NULL,";                     };                                  $sql1 .= "UNIQUE KEY id (id)                                     ) $charset_collate;";                          dbDelta($sql1);             }                  if ($wpdb->get_var( "SHOW TABLES LIKE $jsrm_item_table") != $jsrm_item_table){                                  $sql2 = "CREATE TABLE IF NOT EXISTS $jsrm_item_table (                                     id mediumint(9) NOT NULL AUTO_INCREMENT,                                     menu mediumint(9) NOT NULL,                                     itemorder mediumint(9) NOT NULL,                                     item tinytext NOT NULL,                                     description text,                                     image tinytext,                                     linked tinyint(1),                                     linkurl tinytext,                                     itemhidden tinyint(1),                                     value tinytext,";                                  for ($v=2;$v<=JSRM_VALUE_COLS;$v++){                                     $sql2 .= "value" . $v . " tinytext,";                             };                                  $sql2 .= "UNIQUE KEY id (id)                                     ) $charset_collate;";                     dbDelta($sql2);             }          }               // CHECK DATABASE TABLES ON INIT AND UPDATE IF NECESSARY          function jsrm_check_database_version(){             $dbversion = get_option( 'jsrm_db_version', '1' );             if ($dbversion != JSRM_DB_VERSION){                     jsrm_activate_loop();             }     }     add_action('init', 'jsrm_check_database_version');


Custom field values deleted when trashing custom post type

I've created a custom post type with 2 custom fields attached to it... When I create a post of this type and fill in the custom fields, the data is, in fact, saved to the db... However, if I trash one of them, then that post's custom fields data is deleted from the database. I thought trashing was just supposed to basically change the post_status to "trash" so it's out of view unless you actually delete it permanently? If that's the case, why am I losing my custom fields data when I trash an item? Here's all the relevant code for the above question:               <?php     add_action('admin_init', 'wpg_add_testimonial_author');     function wpg_add_testimonial_author() {       add_meta_box('wpg_testimonial_author', __('Author Information', 'quotable'), 'wpg_testimonial_author', 'testimonials', 'side', 'low');     }          function wpg_testimonial_author() {       global $post;       $custom = get_post_custom($post->ID);       $testimonial_author_name = $custom['testimonial_author_name'][0];       $testimonial_author_link = $custom['testimonial_author_link'][0];       ?>
         <?php _e("Author's Name:", 'quotable'); ?>         <input name="testimonial_author_name" value="<?php echo $testimonial_author_name; ?>" />

         <?php _e('Attribution Link:', 'quotable'); ?>         <input name="testimonial_author_link" value="<?php echo $testimonial_author_link; ?>" />
       <?php     }          function wpg_save_testimonial_author() {       global $post;       if(defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {         return $post_id;       }       if (defined('DOING_AJAX')) {         return;       }       update_post_meta($post->ID, 'testimonial_author_name', $_POST['testimonial_author_name']);       update_post_meta($post->ID, 'testimonial_author_link', $_POST['testimonial_author_link']);     }     add_action('save_post', 'wpg_save_testimonial_author');          function wpg_row_actions() {       global $post;       if($post->post_type == 'page') {         if(!current_user_can('edit_page')) {           return;         }       }       else {         if(!current_user_can('edit_post')) {           return;         }       }       if($post->post_status == 'trash') {         $actionLinks  = '
ID.'&action=untrash', 'untrash-'.$post->post_type.'_'.$post->ID).'">'.__('Restore', 'quotable').' | ';         $actionLinks .= 'ID.'&action=delete', 'delete-'.$post->post_type.'_'.$post->ID).'" title="'.__('Delete this item permanently', 'quotable').'" class="submitdelete">'.__('Delete Permanently', 'quotable').'';       }       else {         $actionLinks  = '
ID.'&action=edit">'.__('Edit', 'quotable').' | ';         $actionLinks .= ''.__('Quick Edit', 'quotable').' | ';         $actionLinks .= 'ID.'&action=trash', 'trash-'.$post->post_type.'_'.$post->ID).'" title="'.__('Move this item to the Trash', 'quotable').'" class="submitdelete">'._x('Trash', 'verb (ie. trash this post)', 'quotable').'';       }       return $actionLinks;     }          function wpg_edit_testimonials_columns($columns) {       $columns = array(         'cb' => '<input type="checkbox" />',         'testimonial_author' => __('Author', 'quotable'),         'testimonial_text' => __('Testimonial', 'quotable'),         'attribution_link' => __('Attribution Link', 'quotable'),         'date' => __('Date Added', 'quotable')       );       return $columns;     }          function wpg_manage_testimonials_columns($column, $post_id) {       global $post;       $custom = get_post_custom($post->ID);       $testimonial_author_name = $custom['testimonial_author_name'][0];       $testimonial_author_link = $custom['testimonial_author_link'][0];            $wpg_row_actions  = wpg_row_actions();            switch($column) {         case 'testimonial_author':           echo $testimonial_author_name.$wpg_row_actions;         break;              case 'testimonial_text':           echo $post->post_content;         break;              case 'attribution_link':           echo $testimonial_author_link;         break;              default :           break;         }       }       add_filter('manage_edit-testimonials_columns', 'wpg_edit_testimonials_columns');       add_action('manage_testimonials_posts_custom_column', 'wpg_manage_testimonials_columns', 10, 2);      The custom post type doesn't support the "title" portion of posts, so it's not included as one of the columns in the edit posts page. Therefore, I had to hack my own version of the row_actions() function to enable the edit/quick edit/trash links when each post is hovered. All of the functionality works as it should... Except that the "testimonial author" and "attribution link" values are deleted from the database when moving a post to the trash. No idea why...


recent posts for different categories

I'm developing a theme that will have two recent posts section on the home page- one section for recent portfolio updates and the other for recent blog posts. I'm struggling with implementing these functions in the theme; I know it's something to do with wp_query, I'm just not entirely sure how to go about this. Any and all help is greatly appreciated. HTML:

Recent Work

Recent Blog

      CSS               #recent {         border-top: 1px solid #202020;         padding-bottom: 40px;         padding-top: 40px;     }          #recent .divider {         display: block;         float: left;         margin-left: 20px;         padding-bottom: 20px;     }          #recent #recent-work {         display: block;         float: left;         position:relative;     }          #recent #recent-work p {         padding-bottom: 20px;     }          #recent #recent-work p span {         font-family: nevis-webfont;         font-size: 112.5%;         font-weight: normal;         letter-spacing: 1px;         text-transform: uppercase;     }          #recent #recent-work a {         padding-bottom: 40px;         padding-right: 20px;     }          #recent #recent-blog {         display: block;         float: right;         position:relative;     }          #recent #recent-blog p {         padding-bottom: 20px;     }          #recent #recent-blog p span {         font-family: nevis-webfont;         font-size: 112.5%;         font-weight: normal;         letter-spacing: 1px;         padding-left: 20px;         text-transform: uppercase;     }          #recent #recent-blog a {         padding-bottom: 40px;         padding-left: 20px;     }          #recent .next {         position: absolute;         bottom: -40px;         right: 0px;     }


How do I get the permalink of a custom post type?

I can get the permalink of a specific post tag or category, but what if I want to get the permalink of a custom post type? I can't find anything in the Codex or anywhere else about how to do this.


Custom post types & Thumbnails

I am looking to set up 2 custom post types - Publicity & Management What I would like to do is display the featured thumbnail for each post from the custom post type on the Publicity page. These will then link though to each post using a custom template. I would like to do the exact same for the Management section. I have created the post type, but when I click on the thumbnails I am being taken to a page that doesn't contain any of the relevant info. I am using a child theme of Twenty Twelve. Can someone please help with this? ### Code used for cpt registration               add_action('init', 'publicity_register');            function publicity_register() {           $labels = array(         //the (probably plural) name for our new post type         'name' => _x('Publicity', 'post type general name'),         //how you’d refer to this in the singular (such as ‘Add new ****’)          'singular_name' => _x('Publicity', 'post type singular name'),         'add_new' => _x('Add New', 'publicity'),         'add_new_item' => __('Add New Publicity Artist'),         'edit_item' => __('Edit Publicity Artist'),         'new_item' => __('New Publicity Artist '),         'view_item' => __('View Publicity Artist'),         'search_items' => __('Search Publicity'),         'not_found' =>  __('Nothing found'),         'not_found_in_trash' => __('Nothing found in Trash'),         'parent_item_colon' => ''       );       $args = array(             'labels' => $labels,               'public' => true,             'show_ui' => true,             'capability_type' => 'post',             'hierarchical' => false,             'rewrite' => true,             'supports' => array('title', 'editor', 'thumbnail'),         'has_archive' => true,       );       register_post_type( 'publicity' , $args );         }      ### Code used for loop               $args = array( 'post_type' => 'publicity', 'posts_per_page' => 20 );     $loop = new WP_Query( $args );     while ( $loop->have_posts() ) : $loop->the_post();       echo '
';       echo '';       echo get_the_post_thumbnail() . ' ';       echo '
' . get_the_title() . '
';       echo '
';     endwhile;     ?>


How To Add Class To Style Search Box

I am not very experienced with PHP but have managed to find a snippet to add a search bar to my main menu, using this code in my functions.php file:               add_filter( 'wp_nav_menu_items','add_search_box', 10, 2 );     function add_search_box( $items, $args ) {     $items .= '<li>' . get_search_form( 'echo=0' ) . '</li>';     return $items;     }      I don't know how to style this though, I know I need to add a class to it so I can style it with css but don't know how to! Also, I wondered how difficult it would be to make it just a search icon that toggles to a bar on click? I think this can be done in css too? Thanks in advance...


loop on page makes shortcode fail

I have this typical _WordPress_ page (page.php):               <?php the_post(); ?>
      <div <?php post_class(); ?>>      <?php the_content(); ?>
      All works fine; have some shortcode, _[gallery]_ , in the page content. So then I add a simple loop to the page to display random posts form a given category:               <?php query_posts('category_name=interesting_sites&posts_per_page=3&orderby=rand'); ?>     <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>      <div <?php post_class(); ?>>
<?php the_title(); ?>
       <?php the_content(); ?>
     <?php endwhile; ?>     <?php endif; ?>     <?php wp_reset_postdata(); ?>      Then, shortcode in page content fails! Why this happens? Any ideas?


Get current taxonomy and display query accordingly

Okay i'm having a bit of a catogorisation/taxonomy/filtering problem here and am at loss on how to solve this. I hope someone could help me on the way a bit. Say I've got a blog about food, with a few main subjects;   * thai food   * indian food   * greek food   * mexican food   * french food   * spanish food   * fast food A blogpost is always tied to one or multiple of these subjects (a blogpost about a fajita is just filed under _'mexican food'_ , a blogpost on 'burrito' under both _'mexican food'_ and _'fast food'_ ). Then there are different categories like   * restaurants    * reviews   * information   * news   * take-out   * recipies Blogposts are also always tied to one or multiple of these categories. These categories are available through the menu. What I want to do is, offer the visitor a possibility to filter all the content on a specific subject. If one would chose to put the filter on _'thai food'_ , all the articles returned should be about thai food. If one would chose the category _reviews_ while the filter _'thai food'_ is on, it should only list articles about _thai food_ within the category _reviews_. If the filter is set to off (or all) and one would navigate to the category _'reviews',_ articles in the category review on all different subjects should be retreived. So there it is! Now I realize I might have explained this in a difficult way, but I'm a loss on how to achieve this here. Right now I've got both the subjects as the categories as top level categories but I'm assuming a custom taxonomie might be a better solution. Any help would be greatly appreciated! _edit: okay to make things easier, I think I have a better idea of what should be happening here: I should detect wether the user has a filter selected (which are custom taxonomies right now) and return posts accordingly. (so something like: if thai food is selected and user clicks on category 'reviews', return a query with custom taxonomie thai food in category reviews) My main question in this case is, how do you detect if there is a taxonomie selected, and which? Thanks!_


Find out how many times the user has logged in

I'd like to determine how many times a user has logged in. Does WordPress retain that information or will I have to add a db entry every time they log- in?               if(is_user_logged_in() && ($logged_in_times == 2)) {         // do something     }


Function shortcode - Set Parameter

function get_gifts_posts($params, $content){             $default_params = array(                 'post_type'     => 'post',                 'order'         => 'desc',                 'orderby'       => 'date',                 'posts_per_page'=> 5,             );                  if (isset($params['type']) && !empty($params['type']) && post_type_exists($params['type']))                 $params['post_type'] = $params['type'];                  if (isset($params['taxonomy']) && !empty($params['taxonomy']) && taxonomy_exists($params['taxonomy'])                  && isset($params['slug']) && !empty($params['slug']))                 $params[$params['taxonomy']] = $params['slug'];                  foreach(array('type', 'slug', 'taxonomy') as $key)                 if (isset($params[$key]))                     unset($params[$key]);                  $params = wp_parse_args($params, $default_params);                  $transient_hash = 'get_gifts_posts_'.substr(md5(serialize($params)),0,10);                  if (false === ($html = get_transient($transient_hash))){                 add_filter('query', 'q');                 global $request_sql;                      // init                 $html = '';                      $rp = new WP_Query($params);             //  $html .= '
START
';             //  $html .= '
'.var_export($params, 1).'
';             //  $html .= $request_sql.'
';              if ($rp->have_posts()){                          $html .= '
';                     while ( $rp->have_posts() ) {                          $rp->the_post();                          $html .= "
";                              if (($thumb_id = get_post_thumbnail_id())){                             $thumb = wp_get_attachment_image_src($thumb_id, 'panel-small', false);                             $html .= "
";                         }                              $html .= "".get_field('fl_price_ex')."";                         $html .= "".get_field('fl_title')."";                         $html .= "

";                     }                     $html .= '
';                 }                      if (!empty($html))                     set_transient($transient_hash, $html, 60);                  }             return $html;         }         How can I specify the number of posts I would like to display as a parameter in the shortcode? Right now I am showing 5 posts by default `'posts_per_page'=> 5,` If the user doesn't specify the number of posts then the function should continue to display 5 posts by default.


Add Older Posts at bottom of List Category Post page

I've installed this plugin and have it working, I'm using the shortcode but cannot figure out how to have a link for "Older Posts" or More posts" or "Archive" appear at the bottom of each page of posts listed if there are indeed more posts in the category than the maximum displayed per page. I want this to work similarly to how a category of posts is usually displayed where the most current are displayed and you scroll down to the "Older Posts" link go back into the list of posts. Thanks!


Php markup question: php/html within conditional bit

I'm getting very confused trying to get an existing bit of code to work within a conditional if/else bit of code. I can't get the syntax correct. All the echo commas and semi colons (sorry I'm not a coder). Existing code to show a post author info under the post content:

About The Author
          <?php echo get_avatar( get_the_author_id() , 80 ); ?>
<?php the_author_posts_link(); ?>

<?php the_author_meta('description'); ?>

      And the new code that I want to use to prevent the author info for a post created by the main admin account to show:               <?php global $wp_query;      $thepostid = $wp_query->post->ID;     $postdata = get_post($thePostid, ARRAY_A);     $authorid = $postdata['post_author'];     if ($authorid==1)     {     echo 'Show nothing';     }     else     {     echo 'Existing author info code to go here';     }     ?>      Both bits of code work separately but combining them as I've noted above results in mark up errors in Dreamweaver and the site breaking in browser. Can someone please give me a few pointers on how to edit the first bit of code to fit in the else part?


Proper WP conditional tag to check for existing taxonomies to list out terms with wp_list_categories?

This is what I currently have but its not rendering any results...   It was the closest conditional I could think of using to match what Im trying to output but it didnt seem to work. Any ideas?... NOTE: The taxonomy terms that I am listing in the sidebar need to be visible at **all times** while viewing custom post type queries, taxonomy archives, and single product/post pages.                  <?php if (is_tax('productcategory')): ?>
                 <?php                 echo '
';                 $args_list = array(                     'taxonomy' => 'productcategory',                      'title_li' => __(''),                     'show_count' => false,                     'hierarchical' => true,                     'echo' => '0',                 );                    echo wp_list_categories($args_list);                 echo '
';                 ?>
              <?php else: ?>         <?php endif; ?>


Auto post with filling templates from external data and update periodical

Hi I want to achieve the following szenario and asking for advice to start off **Szenario** We have an external mysql-database filled with product informations. This database is delivering data for a few online-shops. The access to the database is possible directly per mysql connection or as i prefer per homegrown API. (http-request). The result can be fetched as a JSON-formated array. We now want several wordpress environments on different servers / countries and display filtered product information. We want to build an "advertisment- blog" for let's say a specific product branch (e.g. lighting supplies). Each product as a wordpress-post If I want to add a new product-advertisement to a specific blog, I want to create a new post and click a button and enter a product id. The plugin has to fetch the data from the external server (at best via api-access) and auto-fill parts of a template. I found plugins which can do parts of that, but none which fits the requirements. The other problem, I have, is, that the post has du auto-update the information periodically (let's say once per week). Is this even possible? **Solutions** I am not afraid in developing a homegrown plugin, which can fit the requirements. I am also not afraid to customize some plugins if necessary. Buying a commercal plugin is even an option. But I am not sure where to start. Does anyone know a plugin or a suite of plugins which fits (or almost fits) the requirements? Has someone some plugins/themes/wordpress-clones which fits the requirements? **Auto-Update-Part** Developing a plugin which fetches data and creating a post is not that problem for me. I also could format the output of the api to deliver a copy-pasteable block for post creating. I am afraid for the update- part. Is it better to create the post, and manipulate the data in the database afterwards or to create some kind of widget which don't store the data and fetches the information over the api at each page request? Is it performant enough? Or should i store the product-relevant data for each post in a seperate table/column/whatsoever and update them periodically per cronjob or something? I am thankfull for any advice **EDIT** I am writing my own plugin now. Data import, storage and shortcode display works like a charm. Now struggeling with the update part, but this won't be a serious problem. Thanks for your advice


Display Post Thumbnail Without Being Featured Image

I'm hoping that I can explain what I'm going for here. On my current project's main page, I'm displaying each post's Featured Image Thumb, along with an excerpt of the post's content. In each of the actual post pages, there is a default WP gallery with 2 to 4 images inside. What I want to do, is make it so that my client doesn't always have to use a Featured Image in each post, so that the thumbnail always shows up on the home page. In other words, right now, he has to pick an image to be Featured in order for there to be that representative thumbnail for each post in the loop on the home page. Can I make it so that even if he doesn't pick a featured image for a post, there still is a thumbnail to represent the post? Can I make it automatically just pick the first image in the post's gallery, if no featured image is chosen? Just in case, here is some of what I'm using, code wise:
                  <?php                    if ( has_post_thumbnail() ) {                   the_post_thumbnail();                    }                    ?>
                               <div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>                      <?php the_title('
', '
'); ?>
     <?php the_content(__('Continue reading', 'example')); ?>     <?php wp_link_pages('before=
' . __('Pages:','example') .          '&after=
'); ?>

          <?php endwhile; ?>          <?php else : ?>
<?php _e('Sorry, no posts matched your criteria',       'example'); ?>
          <?php endif; ?>     <?php wp_reset_query(); ?>       Then this is in my FUNCTIONS File:                // This theme uses post thumbnails     add_theme_support( 'post-thumbnails' );     set_post_thumbnail_size( 150, 100, true );                         // Automatically makes featured image thumbs a clickable link     add_filter( 'post_thumbnail_html', 'my_post_image_html', 10, 3 );          function my_post_image_html( $html, $post_id, $post_image_id ) {          $html = '' . $html . '';     return $html;          }          // This theme displays full size featured image on the Post's page     function InsertFeaturedImage($content) {          global $post;          $original_content = $content;          if ( current_theme_supports( 'post-thumbnails' ) ) {              if ((is_page()) || (is_single())) {             $content = the_post_thumbnail('page-single');             $content .= $original_content;              }          }     return $content;     }          add_filter( 'the_content', 'InsertFeaturedImage' );       http://dependablecarcompany.com is the address if you care to see what I'm talking about. You'll see what I mean when looking at the post titled: "1991 GMC Sierra". I did not use a featured image for the post, so there is no thumbnail shown. Thanks in advance!


Does Wordpress check for updates of a plugin via plugins root folder name?

I just completed writing a plugin from another plugin. When I changed the developer name, version and other details from the plugin file, I thought the version tracing would now be done using the new name of the plugin but it actually linked the update to the older plugin until I changed the root folder name for the plugin. Wasn't the update supposed to be happen from the details provided in the file? Please guide. Thanks


Current User Seeing Another Logged In User Info

Having a strange issue where I am checking for the current user by using the `wp_get_current_user` command and occasionally, users have reported to seeing the information for another user. Should I be checking for the current user a different way? This is scary because the information that I am displaying for the users is sensitive and I need the system to only show the current user and not another user that is also logged in. UPDATE: Attached code...               function ssm_dashboard()     {         global $wpdb;         $user = wp_get_current_user();         echo '
Parent Dashboard
';              if (current_user_can(SSM_CAPS_APPROVED_USER))         {             $ssmuser = $wpdb->get_row( "SELECT id, last_name, first_name FROM " . $wpdb->prefix.SSM_USER_TABLE . " WHERE user_id_1=" . $user->ID, ARRAY_A);              echo 'Welcome ' . $ssmuser['first_name'] . ' ' . $ssmuser['last_name'];         }     }      So, the code snippet is a widget I created for my plugin that shows a user's dashboard. What is supposed to happen is that once a user logs in, the widget gets the current user's ID, then looks up their account in my table (wp_ssm_user) and returns the row that matches the wp_user->ID and is displayed on the dashboard. Problem is, some users are reporting that when they log in and perform certain functions (I'm awaiting a reply as to which function in particular), they are redirected to the dashboard where a different user's information is displayed.


Replace text in excerpt

I have a separate theme for my custom WP install that will be use for mobile users, in my case I need to change an html tag in all the excerpt instances but without altering the DB, I found this simple function that would be perfect but I can't get it to work, nothing's happening.               function replace_content_on_the_fly($text){     $replace = array(         // 'words to find' => 'replace with this'         '
' => '
',         '
' => '
'     );     $text = str_replace(array_keys($replace), $replace, $text);     return $text;     }     add_filter('the_excerpt', 'replace_content_on_the_fly');      I added the above code in my theme `function.php`. Why doesn’t it work?


White screen of death only in wp-admin

I'm able to log into the website but the moment after login, I get a white screen in wp-admin. I can still access the website and it shows that I am logged in with the toolbar at the top of each page but whenever I venture off into wp-admin, I'm met with a white screen. I've tried renaming the themes and plugins folder, even deleting both. I'm tried increasing the php memory limit to 128M but still no luck. Any advice? If I do have to reinstall Wordpress, how would I not lose everything that is already there? EDIT: I've also turned on debug but still do not get any errors, warnings or notices.


Is it possible to add an argument to a custom function added to a filter hook?

Example: I'm trying to modify an instantiation of WP_Query by using the `posts_orderby` filter like so:               add_filter('posts_orderby', 'favorites_orderby');     $new_query = new WP_Query($args);     remove_filter('posts_orderby', 'favorites_orderby');      the `favorites_orderby()` function is like so:               function favorites_orderby($post_in){         if(is_array($post_in))             $post_in_str = implode(',', $post_in);         return $post_in_str;     }      `$post_in` is an array that changes based on a previous, separate db query, so I need to be able to pass it into the `favorites_orderby()` function. Basically it's an array of post IDs that need to get fed to the WP_Query instantiation's `ORDER BY` parameter so that the resulting db request is set like so: `ORDER BY FIELD(ID, 6, 18, 90, 12)`. Everything works except passing the array of post IDs (`$post_in`) to the `favorites_orderby()` Any help would be greatly appreciated!


Wordpress Redirect based on the prescence of a cookie

I have a tricky situation.... I'd like to check for a cookie. If it doesn't exist then then redirect to an internal wordpress page, and set a cookie. And then carry on browsing the site. But i get stuck in a loop if the url doesn't exist. This is what i have so far...any help would be great.               function cookiebasedredirect() {              // WHEN YOU HAVE FOUND YOUR COOKIE         if ( !isset($_COOKIE["sevisitor"])) {                  setcookie('sevisitor', 1, time()+1209600, "/", "http://localhost/child/", false);                         // GRABS THE CURRENT PAGE NAME - THIS IS ALSO KNOWS AS THE PAGE/POST SLUG             $pagename = get_query_var('pagename');                  // PAGE CHECK SO THAT YOU ARE NOT IN AN INFINITE LOOP             // IN THIS SAMPLE MEDIA-GALLERIES IS THE PAGE YOU WANT TO BE              //  REDIRECTED TO IF A COOKIE IS NOT SET, BUT ONCE YOU GET THERE             // MAKE SURE WORDPRESS DOESN'T EXECUTE THE REDIRECT             if( $pagename != "about-myself") {                           wp_redirect( get_site_url().'/about-myself' ); exit;                  } else {                       }                   } else {              }}     add_action("template_redirect", "cookiebasedredirect");


Adding help information to custom post edit page

I have two custom post types created (using `Types` plugin) with a bunch of custom fields. I need to add a help information, instructions for admins that will show at the top of add new/edit CPT page of dashboard. How can I add a text visible only on those two pages (`add/edit post type 1` and `add/edit post type 2`)?


How can I restrict changing the max nested comment levels option to super admins?

I have an older theme that I've modified to support threaded comments. I would like the individual admins in my multisite install to be able to choose whether threaded comments are enabled. However, I'd like to restrict the ability to choose the maximum number of levels to super admins. Looking at the capabilities, it seems that all capabilities for the settings screen are grouped together as one capability. Is it possible to restrict just this single option so that it is forced to be the same static value across the entire blog network?


Extending AZIndex plugin to use custom post types and custom taxonomies

I desperately need to be able to display something exactly like this: http://bottlesup-07112011.31two.com/bottlesup-retailers/ 5 columns of custom post type posts sorted alphabetically by custom taxonomy with paging. I have seen this plugin AZIndex plugin (http://wordpress.org/extend/plugins/azindex) but it does not load custom post types or custom taxonomies. I am willing to sponsor a mod if someone can help out with this asap. Thanks. Or help with the raw query code as I am a decent WP coder but not good with column output.


prevent same wordpress post title

I am working on a wordpress site where users can submit there own posts. I would like to prevent users from adding a post with the same `post_title` This is how i currently check to see if the post title exists:               $posts = $wpdb->get_col("SELECT post_name FROM $wpdb->posts WHERE post_type = 'post' AND post_status = 'publish' OR post_status = 'trash' OR post_status = 'draft'");      gets the post title from the form               $alias = $_POST['post_title'];      checks if post_title is empty if it is create a random post_title else use the user defined one               if ($_POST['post_title'] == ''){         $alias = generateRandomString();     } else {         $alias = $_POST['post_title'];     }      I then check to see if the post_title already exists like this:               if (in_array($alias, $items)){         echo '
Sorry, That Title already exists!
';     } else {     //insert the post     }      My issue is that wordpress will add a number after the post title if it does already exist. Is there a way to prevent wordpress from doing this? The output of the above above shows this:               Array ( [0] => db [1] => abi [2] => ybd [3] => cc [4] => cc-2 [5] => fb )      I need to prevent the cc-2 from happening.


Nav Menu meta failing to import

I'm the author of the Nav Menu Roles plugin that lets you display/hide menu items based on the user's role. It has come to my attention that the menu item meta does not import when using the regular WordPress plugin/tool for importing. Each menu item is essentially just a post in the database, and I've been saving the data as post meta. It appears in the exported XML. Here's a sample from a test export I just did locally.               <item>         <title>Art & Design</title>         <link>http://localhost/blog/2013/01/13/263/</link>         <pubDate>Mon, 14 Jan 2013 03:36:16 +0000</pubDate>         <dc:creator>helga</dc:creator>         <guid isPermaLink="false">http://localhost/blog/2013/01/13/263/</guid>         <description></description>         <content:encoded><![CDATA[]]></content:encoded>         <excerpt:encoded><![CDATA[]]></excerpt:encoded>         <wp:post_id>263</wp:post_id>         <wp:post_date>2013-01-13 22:36:16</wp:post_date>         <wp:post_date_gmt>2013-01-14 03:36:16</wp:post_date_gmt>         <wp:comment_status>open</wp:comment_status>         <wp:ping_status>open</wp:ping_status>         <wp:post_name>263</wp:post_name>         <wp:status>publish</wp:status>         <wp:post_parent>0</wp:post_parent>         <wp:menu_order>1</wp:menu_order>         <wp:post_type>nav_menu_item</wp:post_type>         <wp:post_password></wp:post_password>         <wp:is_sticky>0</wp:is_sticky>         <category domain="nav_menu" nicename="main-menu"><![CDATA[Main Menu]]></category>         <wp:postmeta>             <wp:meta_key>_menu_item_type</wp:meta_key>             <wp:meta_value><![CDATA[taxonomy]]></wp:meta_value>         </wp:postmeta>         <wp:postmeta>             <wp:meta_key>_menu_item_menu_item_parent</wp:meta_key>             <wp:meta_value><![CDATA[0]]></wp:meta_value>         </wp:postmeta>         <wp:postmeta>             <wp:meta_key>_menu_item_object_id</wp:meta_key>             <wp:meta_value><![CDATA[6]]></wp:meta_value>         </wp:postmeta>         <wp:postmeta>             <wp:meta_key>_menu_item_object</wp:meta_key>             <wp:meta_value><![CDATA[category]]></wp:meta_value>         </wp:postmeta>         <wp:postmeta>             <wp:meta_key>_menu_item_target</wp:meta_key>             <wp:meta_value><![CDATA[]]></wp:meta_value>         </wp:postmeta>         <wp:postmeta>             <wp:meta_key>_menu_item_classes</wp:meta_key>             <wp:meta_value><![CDATA[a:1:{i:0;s:6:"design";}]]></wp:meta_value>         </wp:postmeta>         <wp:postmeta>             <wp:meta_key>_menu_item_xfn</wp:meta_key>             <wp:meta_value><![CDATA[]]></wp:meta_value>         </wp:postmeta>         <wp:postmeta>             <wp:meta_key>_menu_item_url</wp:meta_key>             <wp:meta_value><![CDATA[]]></wp:meta_value>         </wp:postmeta>         <wp:postmeta>             <wp:meta_key>_nav_menu_role</wp:meta_key>             <wp:meta_value><![CDATA[a:2:{i:0;s:13:"administrator";i:1;s:12:"shop_manager";}]]></wp:meta_value>         </wp:postmeta>     </item>      But then on import, the meta key `_nav_menu_role` doesn't even appear in the database. I'm running a multisite locally, but the user who brought this issue to my attention is not. I'd like to fix this issue for everyone who uses this plugin, but I am so stumped about where to even begin looking. I thought it might be a problem with serialization/non-serialization, but the key isn't corrupt, it isn't even there after the import. **UPDATE** : I've investigated the importer plugin and for menu items, the plugin only imports the traditional, pre-defined meta.. such as 'class'.


Tab from Settings API resetting all options with INSERT INTO

I have an Options menu created with the code from Chip Bennett tutorial, the old code, though, the one from like a year ago (the new one has a much better validation structure, but still, it works really nice). This is the link to the tutorial:http://www.chipbennett.net/2011/02/17/incorporating-the-settings-api- in-wordpress-themes/ It is based on several tabs, each one with a submit-tabName and a reset- tabName button. In my case, everything's working right, except from three installs of the theme in three different URLs from three different customers. On their case, all tabs save and reset their options fine, but clicking on Save button from the Homepage options tab resets all (!) options for all tabs. And this happens, till now, only in those 3 installations, without me being able to replicate that behavior in purpose. Furthermore, when comparing the results in Debug bar, in the Queries for the malfunctioning install of the theme, I get this:               INSERT INTO `wp_options` (`option_name`, `option_value`, `autoload`) VALUES ('quadro_theme_options', 'a:112:{s:17:\"display_text_logo\";b:1;s:14:\"logo_image_url\";s:0:\"\";s:15:\"display_tagline\";b:0;s:12:\"topleft_logo\";b:0;s:17:\"favicon_image_url\";s:0:\"\";s:14:\"login_logo_url\";s:0:\"\";s:11:\"show_footer\";b:1;s:13:\"footer_layout\";s:1:\"4\";s:21:\"copyright_footer_text\";s:102:\"mINUSCULA Theme by Quadro\";s:16:\"404_custom_title\";s:9:\"404 Error\";s:15:\"404_custom_text\";s:127:\"Oops! Looks like the page you were looking for isn\'t here. Don\'t feel blue... use the search tool and get wherever you want! :)\";s:18:\"top_sidebar_layout\";s:1:\"a\";s:24:\"contact_sidebar_position\";s:5:\"right\";s:22:\"show_blog_title_single\";b:1;s:17:\"blog_title_single\";s:4:\"Blog\";s:23:\"blog_description_single\";s:15:\"Our latest news\";s:24:\"blog_ribbon_color_single\";s:7:\"#e53f0b\";s:21:\"blog_sidebar_position\";s:5:\"right\";s:19:\"show_prevnext_title\";b:0;s:17:\"google_map_script\";b:1;s:14:\"display_slider\";b:1;s:12:\"slider_style\";s:12:\"large-slider\";s:16:\"cycle_transition\";s:4:\"fade\";s:22:\"slider_slides_quantity\";i:1;s:14:\"slider_timeout\";i:5000;s:14:\"display_slogan\";b:1;s:12:\"slogan_input\";s:75:\"I\'m your slogan. Use me to display a neat welcome message for your website.\";s:15:\"display_tophtml\";b:0;s:21:\"top_custom_html_input\";s:0:\"\";s:16:\"display_services\";b:0;s:15:\"display_recents\";b:1;s:19:\"recent_news_heading\";s:11:\"Recent News\";s:19:\"recent_news_tagline\";s:25:\"read my latest blog posts\";s:17:\"display_portfolio\";b:0;s:20:\"portfolio_categories\";a:0:{}s:14:\"portfolio_size\";s:5:\"Small\";s:18:\"portfolio_quantity\";i:3;s:17:\"portfolio_heading\";s:13:\"Our Portfolio\";s:17:\"portfolio_tagline\";s:22:\"browse my latest works\";s:28:\"portfolio_categories_display\";b:1;s:17:\"portfolio_infotag\";s:7:\"Client:\";s:21:\"portfolio_viewproject\";s:19:\"View Project →\";s:18:\"display_widgetarea\";b:0;s:23:\"homepage_widgets_layout\";s:1:\"c\";s:18:\"display_bottomhtml\";b:0;s:24:\"bottom_custom_html_input\";s:0:\"\";s:21:\"quadro_homepage_order\";s:63:\"tophtml,slogan,services,portfolio,recents,widgetarea,bottomhtml\";s:18:\"background_pattern\";s:4:\"none\";s:16:\"background_color\";s:7:\"#eeeeee\";s:19:\"main_color_selector\";s:7:\"#e53f0b\";s:20:\"links_color_selector\";s:7:\"#e53f0b\";s:20:\"hover_color_selector\";s:7:\"#ff9a1a\";s:15:\"menu_tabs_color\";s:7:\"#525252\";s:22:\"menu_color_selector[1]\";s:7:\"#e53f0b\";s:22:\"menu_color_selector[2]\";s:7:\"#e53f0b\";s:22:\"menu_color_selector[3]\";s:7:\"#e53f0b\";s:22:\"menu_color_selector[4]\";s:7:\"#e53f0b\";s:22:\"menu_color_selector[5]\";s:7:\"#e53f0b\";s:22:\"menu_color_selector[6]\";s:7:\"#e53f0b\";s:22:\"menu_color_selector[7]\";s:7:\"#e53f0b\";s:22:\"menu_color_selector[8]\";s:7:\"#e53f0b\";s:22:\"menu_color_selector[9]\";s:7:\"#e53f0b\";s:23:\"menu_color_selector[10]\";s:7:\"#e53f0b\";s:15:\"quadro_css_tbox\";s:0:\"\";s:23:\"enable_minusculas_magic\";b:1;s:9:\"logo_font\";s:25:\"Abel|font-family: \"Abel\";\";s:10:\"logo_fsize\";i:40;s:24:\"logo_text_color_selector\";s:4:\"#111\";s:13:\"tagline_fsize\";i:18;s:22:\"tagline_color_selector\";s:4:\"#555\";s:13:\"top_menu_font\";s:25:\"Abel|font-family: \"Abel\";\";s:10:\"menu_fsize\";i:14;s:13:\"headings_font\";s:25:\"Abel|font-family: \"Abel\";\";s:14:\"headings_fsize\";s:6:\"medium\";s:23:\"headings_color_selector\";s:4:\"#555\";s:11:\"slogan_font\";s:25:\"Abel|font-family: \"Abel\";\";s:12:\"slogan_fsize\";i:36;s:9:\"body_font\";s:47:\"none|font-family: Helvetica, Arial, sans-serif;\";s:10:\"body_fsize\";i:12;s:19:\"body_color_selector\";s:4:\"#111\";s:17:\"footer_text_color\";s:4:\"#fff\";s:7:\"send_to\";s:0:\"\";s:10:\"name_label\";s:4:\"Name\";s:11:\"email_label\";s:5:\"Email\";s:13:\"subject_label\";s:7:\"Subject\";s:12:\"button_label\";s:4:\"Send\";s:15:\"incorrect_email\";s:34:\"The email you entered is not valid\";s:15:\"missing_general\";s:27:\"Please, complete this field\";s:12:\"missing_name\";s:31:\"You forgot to fill in your name\";s:13:\"missing_email\";s:41:\"Your forgot to fill in your email address\";s:15:\"missing_subject\";s:33:\"You forgot to fill in the subject\";s:15:\"missing_message\";s:41:\"Please include some words in your message\";s:15:\"sending_success\";s:61:\"Thanks for contacting us! We will answer as soon as possible.\";s:10:\"mail_title\";s:23:\"Email from your Website\";s:10:\"mail_intro\";s:54:\"You have received a message through your contact form.\";s:9:\"mail_name\";s:5:\"From:\";s:15:\"mail_email_from\";s:14:\"Email address:\";s:12:\"mail_subject\";s:8:\"Subject:\";s:12:\"mail_message\";s:12:\"The message:\";s:7:\"digg_id\";s:0:\"\";s:11:\"dribbble_id\";s:0:\"\";s:11:\"facebook_id\";s:0:\"\";s:9:\"flickr_id\";s:0:\"\";s:9:\"forrst_id\";s:0:\"\";s:9:\"google_id\";s:0:\"\";s:6:\"rss_id\";s:0:\"\";s:12:\"sharethis_id\";s:0:\"\";s:8:\"skype_id\";s:0:\"\";s:10:\"skype_link\";s:0:\"\";s:10:\"twitter_id\";s:0:\"\";s:8:\"vimeo_id\";s:0:\"\";s:10:\"youtube_id\";s:0:\"\";}', 'yes') ON DUPLICATE KEY UPDATE `option_name` = VALUES(`option_name`), `option_value` = VALUES(`option_value`), `autoload` = VALUES(`autoload`)      Which is weird because it's not doing that "INSERT INTO" with all the default options in any of my installs. Here is a Gist with the relevant files: https://gist.github.com/4692896 I'm clueless already, don't know where else to look. Any one has any idea? Thanks!! EDIT: I forgot to add that in one of the cases, the database was being shared with another WP site, and re-installing the site over a fresh new database solved it. The other two sites, however, are on their own database. Could it be a case of a corrupted database? And could that be happening with just one of the option tabs?


Defining a default page for custom post type

Let's say I create a custom post type called 'new projects', with capability type = page and slug = 'projects'. Let's then say that I create a new page of type 'new projects' and name it 'my new project'. By default the URL would be represented as: mysite.com/projects/my-new-project/ However, if I want the page **my-new-project** to be the default page (like an index) for that custom post type, is that possible? In other words, I would like mysite.com/projects/ to load the **my-new-project** page. If this is possible, could I then add more pages of type 'new projects' and still define one of those pages as the 'default' page? Thanks so much, Tathiana


Advanced Custom Fields query

I have, hopefully easy question. I have my query here, which is using ACF               <?php query_posts(array('post_type' => 'our-clients-list', 'posts_per_page' => 1, 'order' => 'DSC', 'orderby' => 'rand','paged'=> $paged)); ?>                       <?php while(have_posts()) : the_post(); ?>                                 <?php the_field('testimonial_'); ?>                       <?php endwhile; ?>                  <?php wp_reset_query();?>      So there is a field in my custom post type called 'testimonial_' I would like to only execute query when custom field is not empty so !='' but not sure how to do that. Anyone can help or give me some hint?


Wordpress Site has 35K spam images

I am helping a client who's site has numerous plugins and 35K spam images from Zillow. They are in the media library. He also has 100K spam comments. I have since disabled the comments. He also had over 300 users with no roles. I have removed all users except the one with admin privileges. How can I go about removing all pictures not uploaded by the admin? I obviously cannot manually go through everyone, but I do not see a filter option for Author type. Thanks!


Add a InfoBox in the media upload window

I am trying to add a InfoBox (just infotext for the user) to the media upload popup window (se mockup link). Any tips on how to adress this feature? Filter hook? Other solution? Thanks in advance. Mockup of InfoBox **Edit** Problem solved               function media_upload_infobox() {?>

Your header here.

 Infotext here

               <?php          } // End function media_upload_infobox          // Add function to Action Hook     add_action('pre-flash-upload-ui','media_upload_infobox');     add_action('pre-html-upload-ui','media_upload_infobox');          ?>


Rewrite rule for custom parameters

Im having rewrite rules like this               add_rewrite_tag('%offercode%','([^&]+)');     add_rewrite_tag('%offerdatefrom%','([^&]+)');     add_rewrite_tag('%offerdeparture%','([^&]+)');          add_rewrite_rule('^oferta/([^/]*)-([^/]*)-([^/]*)?','index.php?page_id=193&offercode=$matches[1]&offerdatefrom=$matches[2]&offerdeparture=$matches[3]','top');      Link which works with rewriting rule is: oferta/40_37830_2635-2014_05_14-Warszawa/ Is there any possibility to create rewrite rule that will ignore if there arent 2 last paremeters specified in the link and still output me proper page oferta/40_37830_2635--/ This above works, but i dont want to have two not needed --. Is there any way to achieve this? Im not good at rewriting rules and only this i've came up to... Thanks in advance.


theme options not saving

I've created a really simple theme settings page to just enable my user to add some social media links. However when I input some data and save the fields the text vanish's and doesn't seem to save.               <?php         // create custom theme settings menu         add_action('admin_menu', 'getextra_settings_create_menu');              function getextra_settings_create_menu() {                //create new top-level menu           add_menu_page('Theme Settings', 'Theme Options', 'administrator', __FILE__, 'ge_settings_callback_page');                //call register settings function           add_action( 'admin_init', 'register_mysettings' );         }                   function register_mysettings() {           //register our settings           register_setting( 'theme-settings-group', 'theme_options' );         }              function ge_settings_callback_page() {         ?>

Foxyrentals Theme Settings
              <form method="post" action="options.php">             <?php settings_fields( 'theme-settings-group' ); ?>             <?php do_settings_sections( 'theme-settings-group' ); ?>

                 Facebook	                 <input type="text" name="facebook" value="<?php echo get_option('facebook'); ?>" />

                 Twitter	                 <input type="text" name="twitter" value="<?php echo get_option('twitter'); ?>" />

                 Pinterest	                 <input type="text" name="pinterest" value="<?php echo get_option('pinterest'); ?>" />

                 Google+	                 <input type="text" name="googleplus" value="<?php echo get_option('googleplus'); ?>" />

                 Linkedin	                 <input type="text" name="linkedin" value="<?php echo get_option('linkedin'); ?>" />

                 Foursquare	                 <input type="text" name="foursquare" value="<?php echo get_option('foursquare'); ?>" />

                  <?php submit_button(); ?>              </form>
              <?php } ?>      from this I've created a function that displays these options in the footer using the following;                 <?php          function social_icons() {         $facebook = get_option('facebook');         $twitter = get_option('twitter');         $googleplus = get_option('googleplus');         $linkedin = get_option('linkedin');         $foursquare = get_option('foursquare');         $pinterest = get_option('pinterest');     ?>             <a href="<?php echo $facebook; ?>"<img src="<?php bloginfo('template_url'); ?>/images/icon_fb.png" alt="facebook" />             <a href="<?php echo $twitter; ?>"><img src="<?php bloginfo('template_url'); ?>/images/icon_tw.png" alt="twitter" />             <a href="<?php echo $googleplus; ?>"><img src="<?php bloginfo('template_url'); ?>/images/google-icon.png" alt="googleplus" />             <a href="<?php echo $linkedin; ?>"><img src="<?php bloginfo('template_url'); ?>/images/pinterest-icon.png" alt="pinterest" />             <a href="<?php echo $pinterest; ?>"><img src="<?php bloginfo('template_url'); ?>/images/linkedin-icon.png" alt="linkedin" />             <a href="<?php echo $foursqaure; ?>"><img src="<?php bloginfo('template_url'); ?>/images/foursquare-2-icon.png" alt="foursqaure" />           <?php } ?>


Sort author list alphabetically

I have narrowed the code down to this:               <?php         $authors = $wpdb->get_results('SELECT DISTINCT post_author FROM '.$wpdb->posts);         if($authors):         foreach($authors as $author):              ?>      I would like the authors to be sorted Alphabetically, it doesn't matter if it sorts by first name, last name.


Copying taxonomy term to custom field

I have a custom post type called "listing", and a custom taxonomy called "listing_state". I'm using formidable to create posts. What I am trying to do is have two things happen when a user selects a state from the taxonomy drop down. First, to set the taxonomy, which is what happens now. But then at the same time, also have this selected state get copied to a custom field called "state". The end result should be a listing that is classified by state, but that also holds that state name in a custom field as well. Any ideas? Thanks in advance for any help.