question
stringlengths
0
34.8k
answer
stringlengths
0
28.3k
title
stringlengths
7
150
forum_tag
stringclasses
12 values
Shortcode: <code> [permalink][title][/permalink] </code> Output: <code> &lt;a href="foobar"&gt;[title]&lt;/a&gt; </code> Wordpress shortcode API sais, it's correct: http://codex.wordpress.org/Shortcode_API#Nested_Shortcodes Any Ideas?
From the page you linked: The shortcode parser correctly deals with nested shortcode macros, provided their handler functions support it by recursively calling do_shortcode(): You need to recursively call <code> do_shortcode() </code> on any shortcode handler that could contain nested shortcodes. So for example: <code>...
nested Shortcode doesn't work
wordpress
Is there a way to add a hook for a plugin when a new author is added by the administrator? I would like to be able to add that user to my plugin database table. Thank you.
There's user_register .
Plugin Hook When New Author Added
wordpress
I have installed the audio plugin, to create Xbrowser playlists, but I am getting the following error <code> jPlayer 2.0.0 : id='jquery_jplayer_1' : Error! </code> All I have done so far is create a new post, upload audio to the post using the wordpress audio uploader, added the playlist to the post using the following...
Answered my own question. Kept here for others who may have in the same problem. Turns out, being locally hosted WAS relevant. the problem is line 192 in <code> /wp-content/plugins/audio/js/audio.js </code> <code> swfPath: 'http://' + window.location.host + '/wp-content/plugins/audio/js/', </code> This expects the site...
Error Using Audio plugin
wordpress
I am getting <code> function deactivate_plugins does not exist </code> error when calling this function <code> function deactivateSelf(){ deactivate_plugins(RSD_PLUGIN, true); //gives error: function deactivate_plugins does not exist header("Location: plugins.php?deactivate=true"); //redirect to plugin management with ...
The file <code> wp-admin/includes/plugin.php </code> is not always included. You may have to do this in your plugin. And your <code> Location </code> header is invalid: You have to send a complete URL. You should use: <code> require_once( ABSPATH . 'wp-admin/includes/plugin.php' ); </code> When do you call this functio...
function deactivate_plugins does not exist
wordpress
I'm thinking maybe limit the number of posts a user can make in a given period of time. (Say a user can only publish 1 post per 5 minutes?) Is there such a plugin?
Limit Post Creation Per Day plugin seems to provide this functionality.
Restrict the Number of Posts an Author can Publish (over time)?
wordpress
I built a post interface to accept specific data in the form of custom meta boxes [rant]but now the end user says it's too much work to cut and paste 4 times[/rant]. So now (completely out of original scope) I need to parse the data entered into a new text area meta box and assign each line as a value to 2 existing key...
This is a very simple script that will split up the text of the box in different lines and fill them in in the title, excerpt and two custom fields. <code> jQuery( function( $ ) { $( '#wpse18528_paste_box' ).keyup( function() { var text = $( '#wpse18528_paste_box' ).val(); var lines = text.split( /[\n\r]+/ ); $( '#titl...
Parse a text area custom meta box and assign as value to existing meta keys
wordpress
I'd like to include Pages in my RSS feed. Whenever I add or edit a page, I'd like it to show up in the feed. I can't seem to find any setting in the default WordPress installation or in the default (TwentyTen) theme. Is there a theme or plugin which can do this? I'm using the latest version of WordPress (3.1.3).
Adding the following code to your theme function file (functions.php) will solve your problem: <code> // Add Pages to RSS Feeds function myfeed_request($qv) { if (isset($qv['feed']) &amp;&amp; !isset($qv['post_type'])) $qv['post_type'] = array('post', 'page'); return $qv; } </code> Credit: http://www.wpbeginner.com/wp-...
How to add pages to feed?
wordpress
Working on a new site, I'm trying to plant recent post excerpts on a static front-page. I had been doing all my static content outside of wordpress (as static files), but was convinced to pull everything into the WP fold, so to speak. On my external static file that was serving as my home page, I had figured out how to...
Ah - got it - was almost there with the new WP_Query, but was failing to call the query method on it... This works perfectly: <code> &lt;?php $excerptQuery = new WP_Query(); $excerptQuery-&gt;query('showposts=6'); ?&gt; &lt;?php if ( $excerptQuery-&gt;have_posts() ) while ( $excerptQuery-&gt;have_posts()) : $excerptQue...
Static Front-Page Excerpts
wordpress
For example, we have some image on the external site: http://site.com/image.png How do I upload this image to my wordpress as an image attachment by php? Image should be copied to my uploads folder, post added, meta generated.
You can <code> media_sideload_image() </code> function to upload your files ex: <code> $upload = media_sideload_image( $url, $post_id ); </code> or you can use a plugin like Cache Images which uploads all external images to your server as attachments.
Upload attachment from external site
wordpress
some of my posts have the post meta of "project_id". How can I retrive all the posts which have the meta key of "project_id" ? I tried: <code> $meta_key = 'project_id'; return $wpdb-&gt;get_var($wpdb-&gt;prepare("SELECT ID FROM $wpdb-&gt;postmeta WHERE meta_key = %s", $meta_key)); </code> It returns nothing. Please hel...
As simple as this: <code> $the_posts_you_want = get_posts( array( 'meta_key' =&gt; 'project_id' ) ); </code> <code> foreach ( $the_posts_you_want as $post ) { // Do whatever you need in here... // Read further how to inspect the post object: stackexchange-url // echo each meta key echo $post-&gt;whatever; // or save it...
how to get all post with the same post meta?
wordpress
So I did something like below, but I get just (I am expecting a Facebook textbox?) I hope its not too messy. I am new to Settings API ... <code> add_action('admin_init', function() { register_setting('elem_opts', 'elem_opts', 'elem_validate_opts'); add_settings_section('elem_opts_form', 'Elements Theme Options', 'elem_...
You have some of the callback functions and the ID's mixed up, try this: <code> add_action('admin_init', function() { register_setting('elem_opts', 'elem_opts', 'elem_validate_opts'); add_settings_section('elem_opts_form1', 'Elements Theme Options', 'elem_opts_form', 'elem_opts'); add_settings_field('elem_opts_form', '...
Need help understanding/coding with Settings API
wordpress
I'm building a template for twentyten child theme. I need to add a class in in the template page, but not in other pages.My template inherits the header and footer, so, I can't change any markup there. How can I add a class in there without adding that class to other pages? Thanks a lot for the help.
You're probably looking for something like this: <code> &lt;?php function add_classes_to_body_class($classes) { // make sure 'page-template.php' matches your template name if ( is_page_template('page-template.php') ) { $classes[] = 'main'; } return $classes; } add_filter( 'body_class', 'add_classes_to_body_class' ); ?&...
I want to add a class to main div on a template. how can I do that?
wordpress
I have a multisite installation, and I was changing the settings of one of my sites from the mu administration panel when I came across a setting called <code> Use BalanceTags </code> . Out of curiosity, what does that setting do?
balanceTags fixes incorrectly nested html markup, for instance if you had an opening tag but no closing tag, or if they're closed in the wrong order.
What does "Use BalanceTags" Do?
wordpress
I've created custom taxonomy called <code> Brands </code> and made it hierarchical so I can add Car brands and models there and keep their relations, like this: Ford Mustang Mondeo Focus Problem is, this list might get pretty long and only one brand and one model is needed per post, so checkboxes are misleading. I'm th...
Here is an example. I have also created a Gist with more generic code. <code> add_action('add_meta_boxes', 'my_custom_metabox'); function my_custom_metabox() { add_meta_box('custom-taxonomy-dropdown','Brands','taxonomy_dropdowns_box','post','side','high'); } function taxonomy_dropdowns_box( $post ) { wp_nonce_field('cu...
Taxonomy dropdown metabox in the back-end
wordpress
I use the default TwentyTen theme and I have made a child theme with some CSS adjustments, and that's pretty much it. Now I'd like to do two things Make the theme load the latest jQuery, and to load it using the Google CDN. Add a javascript file which would be loaded on every page. What's the best way to do that? I'm a...
Here you go. <code> add_action('init', 'register_custom_jquery'); function register_custom_jquery() { wp_deregister_script('jquery'); wp_register_script( 'jquery', 'https://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js', array(), '1.6.1' ); wp_register_script( 'my-custom-script', 'http://example.com/js/scrip...
Best way to add some custom javascript using jquery to a child theme
wordpress
At the moment I have the following code for changing the author_base slug. <code> /** ADD REWRITE RULES **/ function change_author_permalinks() { global $wp_rewrite; $wp_rewrite-&gt;author_base = 'profile'; $wp_rewrite-&gt;flush_rules(); } add_action('init','change_author_permalinks'); </code> How can I add, for exampl...
The author rewrite rules are filtered through <code> author_rewrite_rules </code> . You can add a rule there for the pattern <code> author/([^/]+)/edit/?$ </code> , but the substitution will depend on how you want to create the <code> edit </code> page. A simple example that will set a custom query variable and load a ...
Adding more pages to author pages
wordpress
I remember seeing a search plugin that creates a database log of your pages it use for search. Does anyone know of the plugin? And would this be a good way to make the Widget Text searchable? If not is there a plugin to add widget text to the search?
I think Search Engine works by indexing front-end pages.
Replacement search plugin that reads widgets or catalogs entire page?
wordpress
I learned that you can add new cron schedules by using the cron_schedules filter. If I change a interval of a schedule that I added earlier, will a job that uses this schedule be scheduled using this new interval the next time, or will it still use the previous interval?
After some testing I figured out that yes, it will use the new schedule, updated using the 'cron_schedules' filter.
Will Wordpress use the newer schedule if it is updated using the filter 'cron_schedules'?
wordpress
it is not the first i see that we "delete" a post meta even if it does not exist : example : <code> $count = get_post_meta($postID, $count_key, true); if($count==''){ $count = 0; delete_post_meta($postID, $count_key); add_post_meta($postID, $count_key, '0'); </code> So if $count is empty, so if it does not exist in the...
The reason why in the code, you show there, that <code> delete_post_meta() </code> is run first, is because <code> add_post_meta() </code> is run after it. If the delete wasn't done first then you would end up with multiple entries stored in the meta table. To be honest it would be better to use <code> update_post_meta...
delete post meta from db, even if does not exist?
wordpress
My "links" come in from Windows Live Writer, from a perl based delicious sync directly to the database and who knows where from. They all have in common that the category is 'Daily-Links'. So I think I will schedule a cron that every day checks for all posts in the category 'Daily Links' and then adds the post format t...
Hook save_post and add the post format if the post is for that category. (save_post) Runs whenever a post or page is created or updated, which could be from an import, post/page edit form, xmlrpc, or post by email.
How can I convert everything from category X to have post format Link
wordpress
I'm running this code to tell me what plugins need updating: <code> $update_plugins = get_site_transient('update_plugins'); </code> Here is an example return: <code> Array ( [login-lockdown/loginlockdown.php] =&gt; stdClass Object ( [id] =&gt; 3760 [slug] =&gt; login-lockdown [new_version] =&gt; v1.5 [url] =&gt; http:/...
I think you'll have to work via <code> get_plugins() </code> . It will return a list of all plugins in your plugin folder, indexed by plugin location - which is the same as your array index. This is also what the plugin administration table uses . If you only need the data from one file you could also call <code> get_p...
How to get plugin name from plugin file location
wordpress
I'm using the code below to first grab the post's attachments (if they're either a Word doc or pdf file), then echoing the url of said attachment. This works great on the first post on a page. However, on each subsequent post the same attachment url is echoed, even if that post doesn't have an attachment. How can I kee...
Try this: <code> &lt;?php if ( $attachments = get_children( array( 'post_type' =&gt; 'attachment', 'post_mime_type' =&gt; array('application/doc','application/pdf'), 'numberposts' =&gt; 1, 'post_status' =&gt; null, 'post_parent' =&gt; $post-&gt;ID ))); foreach ($attachments as $attachment) { echo '&lt;a href="' . wp_ge...
How can I display a link to a post's (Word doc or pdf) attachment?
wordpress
At the moment, Wordpress checks the wordpress core for it's updates. But, I'd like to add an additional check to repeat the process for themes and plugins using a seperate address, for updating themes that are not on the core wordpress repositories, such as commercial themes and such. Is this possible? If so how would ...
There is no native mechanism for WP to check for updates from non-official resources. Some plugins/theme have such functionality of their own for themselves. If you want to implement such checks for arbitrary plugins/themes (coded without such in mind) it is not impossible, but will take loads of custom code and handli...
Custom theme/plugin update checks
wordpress
I removed some widgets from the dashboard in the wrong way (using <code> unset() </code> on <code> $wp_meta_boxes </code> ) and as a side effect my dashboard widget area is now split into 4 columns, but with just the first 2 having the normal default widgets in, thus the page is squashed. Is there a way to change the a...
Under "Screen Options", you can change the number of columns. Does that fix your problem?
Change number of widget columns in dashboard?
wordpress
There is something missing because this is driving me crazy at the moment. I'm using the wp_query with the following args. <code> $args = array( 'post_type' =&gt; 'project', 'post_status' =&gt; 'publish', 'meta_query' =&gt; array( array( 'key' =&gt; '_sf_project_budget', 'value' =&gt; '6', //'compare' =&gt; '=', //'typ...
The meta query is converted by <code> _get_meta_sql() </code> . You can check the output by hooking into <code> get_meta_sql </code> . Dump that value and see what it gives.
What's missing in this wp_query and meta_query
wordpress
When my results show in Google for the respective keywords, in the meta description I see the date as well. Is there a way to remove the date? Example meta description shows up as: 15 Jun 2009 ... My meta description I use FV Simplr SEO and very pleased with it.. Would like to know if there's a hack for this.
I havent tried these yet but I was actually looking at the exact same thing the other day. http://magstags.com/wordpress-seo/remove-date-meta-descriptions-wordpress-seo/ and http://seo-ho.blogspot.com/2011/02/how-to-remove-date-from-meta.html
How to remove date from showing in meta description
wordpress
I have a massive WXR file im trying to import into wordpress. I run out of memory when i try to import as one file, so I'm thinking of how i can split the big file into smaller files programatically and if anyone had a script to do this
Googling for "split wxr file" returned several results, including python script for splitting .wxr file GUI for splitting WXR files (OSX and Windows) .Net splitter for WXR files Haven't tried any of these, but the comments look positive.
WXR slicing script
wordpress
I need to display a list of results which will include a name, time, etc. They will be in this format: results . I have looked at using tables, but short of writing a script to parse the text file, it wouldn't work. I think the best option is to make them appear in a monospaced font but I cannot find a way to do this t...
So you want to import textual content and preserve its formatting, as opposed to parsing it into HTML? I suppose the <code> &lt;pre&gt;&lt;/pre&gt; </code> tags are meant for exactly this. However I would consider spending osme effort to parse input after all, otherwise there is little merit in having it in WordPress.
How to display list of results
wordpress
I want to let my customer choose any image (in my backend) and then it will be displayed in my header.php. i've found Image Widget, but it just show images in the sidebar. I want something like: <code> &lt;?php wp_plugin_that_shows_a_simple_image(); ?&gt; </code> In my header. Which plugin could I use? I've searched a ...
WordPress contains built-in support to select header images for a theme . You only have to indicate that your theme supports this, by calling <code> add_custom_image_header() </code> . See the Twenty Ten initialization for details. In your theme's <code> header.php </code> you then call <code> header_image() </code> to...
Show an image in my header.php
wordpress
Any ideas on this? I earlier got an error on some update directory, and manually deleted it (unfortunately I didn't write it down). I think I've done auto-upgrades on the same domain before. <code> Downloading update from http://wordpress.org/wordpress-3.1.3.zip… Unpacking the update… Warning: copy(/home/nwalters/publi...
sounds like you need to think about a new host... do I dare ask where you're hosted now? But yes that's a permission issue.
3.1.3 auto-upgrade
wordpress
I am having posts with images.In single post page all contents displaying well with image. But in blog page , the content only displaying not an image. How can i make it to display For example, http://www.beezid.com/blog this blog displaying images with read more link but not in my case http://optisolbusiness.com/gonzo...
If you did not set an explicit excerpt for your post in the post editor, WordPress by default calls <code> wp_trim_excerpt() </code> to auto-generate an excerpt. This function throws out all HTML tags to make life simple. <code> the_content() </code> does not do this when it splits your post on a <code> &lt;!--more--&g...
the_excerpt function not showing image
wordpress
I found an XML to WP decoder script that stores the data as an array in a custom meta field. What is the best way to extract the information? For example how could I display the "Manufactured in" field as "CANADA"? <code> [_ttn_i_details] =&gt; Array ( [0] =&gt; a:5:{s:9:"engine_id";a:1:{i:0;s:9:"300000225";}s:15:"tran...
Use unserialize() to convert it into an array. <code> $mydata = 'a:5:{s:9:"engine_id";a:1:{i:0;s:9:"300000225";}s:15:"transmission_id";a:1:{i:0;s:6:"257691";}s:5:"plant";a:1:{i:0;s:23:"Oshawa, Ontario, Canada";}s:15:"Manufactured in";a:1:{i:0;s:6:"CANADA";}s:22:"Production Seq. Number";a:1:{i:0;s:6:"151411";}}'; $mydat...
How to extract data from a post meta serialized array?
wordpress
I need to override the setting in the WP Admin for the number of recent posts in the Syndication settings under General -> Admin. I'm using the following code, which gets all posts, but I don't need that many. Can someone tell me how to retrieve 50 posts? <code> function no_limits_for_feed( $limits ) { return ''; } add...
This is no normal filter. It's a <code> filter_ref_array </code> . <code> // Use this to alter your limit: add_filter( 'post_limits', create_function( '$a', "return 'LIMIT $start, 10';" ) ); </code> EDIT After I saw that this got marked as solution, I want to show you a more "best practice"-approach: <code> function al...
How to get override the WP Admin Syndication feed limit for a custom feed?
wordpress
I've got a button in theme options that calls a file called color.php, (the contents of which are below). On certain installations of the theme, the script is generating a 404 error and failing unless I take out everything above the //do something line. Any suggestions on what might be causing it? <code> &lt;?php requi...
It is not a 404 error, it’s a server error. You are calling <code> is_user_logged_in </code> and <code> current_user_can </code> probably before the definition is loaded. Hook your check to an action where these functions are known, <code> admin_init </code> for example.
Call to require('../../../wp-blog-header.php') results in 404 error?
wordpress
I think this is a fairly simple issue but I haven't got my head around it. Question: how do I get my custom posts to show only on the category archives, but not in the blog post listing page? Background: I have a custom post type "video", with has_archive true and 'taxonomies' => array('category', 'post_tag') - I want ...
This may be overly simplistic, but have you tried changing <code> is_home() </code> to <code> is_category() </code> , in this line: <code> if ( is_home() &amp;&amp; false == $query-&gt;query_vars['suppress_filters'] ) </code> i.e. change it to this: <code> if ( is_category() &amp;&amp; false == $query-&gt;query_vars['s...
Displaying custom post type on category pages but not on blog listings
wordpress
I'm using WordPress 3.1.3 and trying to make a "product" menu with post count in each category. Like this: New Cars (4) BMW (2) Ford (1) Nissan (1) Used Cars (10) BMW (3) Ford (1) Nissan (6) For this, I've created custom post type <code> Cars </code> and taxonomies <code> Type </code> and <code> Brand </code> . Not sur...
I adjusted your code a little bit to integrate the <code> wp_query() </code> class instead of <code> query posts() </code> , which is stackexchange-url ("only meant for altering the main loop"). You should always opt to use <code> wp_query() </code> when trying to create secondary loops. Since we're using <code> wp_que...
Taxonomy menu with post count and multiple parents
wordpress
I'm trying to hide a navigation menu item under certain circumstances. Specifically, if a user is logged in AND has already registered their product bar code, I want to hide the 'Register Kit' link (which has a class of 'ac-regkit'). Below is the PHP I've added to the head section of header.php, just before wp_head();....
I'd have 2 menus, and show the 2nd only if the user meet criteria. Then, use CSS to show both menus like its only one. I think it's the easiest way. And you have the benefit that the items aren't really there, not just hidden.
Hide a nav menu item based on get_user_meta results
wordpress
I'm using url like «wp-login.php?action=register&amp;role=patient» and «register_form» hook for add extra inputs form which depends on urls like this: <code> add_action('register_form','add_extra_role_fields'); function add_extra_role_fields() { if (isset($_GET['role'])) { $user_type = $_GET['role']; } if (isset($user_...
If you want to keep this information in the <code> $_GET </code> , you will have to modify the form's <code> action </code> parameter URL . You can do this by hooking into <code> site_url </code> : <code> add_filter( 'site_url', 'wpse18418_site_url', 10, 4 ); function wpse18418_site_url( $url, $path, $scheme, $blog_id ...
Can I change default registration link (without htaccess)?
wordpress
How can I update the URLs that Drag-To-Share eXtended generates? At least in version 1.13, sharing items for Twitter and Facebook does not produce the proper url string for actually sharing the content on either network. Facebook, Twitter, and possibly other networks have since changed the url query string methods for ...
The URLs are constructed in the <code> wp-dragtoshare-extended.js </code> Javascript file . For most services you can see how the <code> customUrl </code> is constructed and change it right there. For Twitter you should look a bit lower, in the <code> isGD </code> function, because it does an Ajax request to shorten th...
Updating the Drag-To-Share eXtended share URLs?
wordpress
I want to exclude posts from aside post-format in the feed. I have already checked up stackexchange-url ("here") about how to exclude posts from a certain post format from the loop but how to exclude posts from a post format in the feed? Couldn't modify it because I am not very good with the code.
If you want to modify the feed, you should hook into the main query that WordPress will do on every page request. The best hook here is <code> pre_get_posts </code> . This code example will hook into <code> pre_get_posts </code> , check whether it is a feed, and add the post format taxonomy query: <code> add_action( 'p...
How to exclude posts of a certain format from the feed
wordpress
I saved a group of data in post meta, now I need to get the meta and use them as other items. My code not working, please help me correct it, thanks! <code> $boxes = Array( 'height', 'width' ); foreach ( $boxes as $data ){ $project = get_post_meta($post-&gt;ID, $data, true); } $item_a = $project-&gt;height; $item_b = $...
<code> foreach ($boxes as $data) { $project[$data] = get_post_meta($post-&gt;ID, $data, true); } $item_a = $project['height']; $item_b = $project['width']; </code>
How to obtain a group of post meta and assign each meta to other variables?
wordpress
I created an options page for my theme, where I can manually edit the CSS. Lets say I change the CSS in the options page for the <code> &lt;H1&gt; </code> tag, so it will now change it on the front-end. What I want to also do is have it change in the visual editor. I have added the function <code> add_editor_style(styl...
The reason why this isn't working is because the WordPress core isn't loaded when this dynamic style sheet is loaded. <code> get_option() </code> hasn't been defined yet. What you need to do is load WordPress at the top of your dynamic stylesheet: <code> &lt;?php include("../../../wp-load.php"); ?&gt; </code>
Dynamically add CSS to the visual editor
wordpress
The function below is called from my index.php just below the main content block. Its purpose is to write out a link list of the latest posts. However, I need to reset the post object once this function has completed (or the sidebar query that follows thinks that the current post is the last post that gets executed by ...
<code> wp_reset_query() </code> will reset the query to the original query WordPress did on this page. So if you somewhere called <code> query_posts() </code> , it will not reset back to that query, but to the "main" query. You probably want to use <code> wp_reset_postdata() </code> , which resets the <code> $post </co...
How to effectively reset the post object after calling get_posts()
wordpress
I'm wondering if it's possible in the single.php template to use the width of the post's featured image elsewhere in the page. What I'm trying to do is add a div element on the page with the same width as the post's featured image (which will always be a different width). If anyone has any ideas, let me know. Thanks
Try the following. First, add this piece of code to the template: <code> &lt;?php $image_data = wp_get_attachment_image_src( get_post_thumbnail_id( $post-&gt;ID ), "thumbnail" ); ?&gt; </code> $image_data will now return an array containing the url, width, and height (function reference). To get the width, you might do...
How to get featured image's width and use elsewhere in template?
wordpress
How do I create a new usermeta field with a drop down selection values? Im want to create a conditional statement for all users with a certain value of the new custom field I want. For example, The new field would be: Approved The drop down values are: Yes and No The conditional statement will recognize all users with ...
You need to hook edit_user_profile to add your custom inputs. Then, you need to hook the profile_update action and use the function add_user_meta to add the metadata
Create a new usermeta field for users
wordpress
ok so i have a nav menu with the top level of menu items being static pages. When you highlight or visit one of them there is a sub-menu that pops up. Each one of them has there own sub-menu and each sub-menu is full of custom taxonomy terms. Since WordPress will only give the current-menu-item class on an archive page...
Problem is that you'd need to pass a <code> $post-&gt;ID </code> in order to not <code> return false. </code> Better use <code> is_object_in_taxonomy($object_type, $taxonomy) </code> and fill both the term and the tax in the function. It returns <code> (boolean) </code> , so simply add your class based on the result: <...
has_term if/echo else/echo function
wordpress
If I use the URL "/tag/tag1,tag2/feed", it will retrieve posts that have both tags. Is there anyway to do this and just get posts that have BOTH tag1 and tag2?
You could make a custom rss feed..... Here's a link for that http://yoast.com/custom-rss-feeds-wordpress/ Simply use that info to make a page template Make a new page through the WP interface and assign that template The url for that page is your new feed. You just need to adjust the query line to call to both tags For...
Anyway to retrieve a feed of posts that have BOTH tags?
wordpress
I've just purchased a plan with MaxCDN to deliver my content through CDN, but i've got a small issue before i create a pull-zone. I moved my WordPress core files out of my root and into a sub-directory. These are my current settings: WordPress address URL: <code> http://example.com/wordpress </code> Site address URL: <...
Just use the site address URL, <code> http://example.com </code> From the literature: `When the custom CDN URL works, you can access all files in your site via that URL and it will be delivered through the MaxCDN content delivery network. For example, if you normally open an image from example.com/images/example.jpg, t...
CDN: Origin server URL, WordPress Core files installed in sub-directory
wordpress
Working on an SEO plugin and stuck on something I thought would be simple. Looking for code to generate just the URLs for categories, tags, search, and date archives when on that archive set. So if on category ABC there's the URL to www.domain.com/category/abc/ Was hoping it was something simple like this for the categ...
in a category archive, the code could be: <code> echo get_category_link(get_query_var('cat')); </code> in a tag archive, this could be: <code> if(is_tag()) echo get_term_link(get_query_var('tag'), 'post_tag'); </code> the conditional was added to avoid an error messages if not in a tag archive.
Code for Category, Tags, Archive URLs
wordpress
I'm working on a plugin that will be installed in a multisite instance. How do I create a single settings page that is visible at the "Network admin" level only - most of the guides i've seen relate to a standard blog level plugin. Any links to information would be useful, otherwise I'll just end up going through sitew...
As a reference To create network or global settings, you need to do the following Add a settings page <code> add_submenu_page( 'settings.php'... # cf options.php for blog level` </code> Add a global option <code> add_site_option($key,$value) </code> Update a global option <code> update_site_option($key,$value) </code> ...
'Global' settings page for multisite plugin
wordpress
What is the best way to display/dump all custom fields associated with a post? It doesn't have to be pretty, I just need to verify what is being saved in what field array for debugging. Thanks!
you can use get_post_custom() which returns a multidimensional array with all custom fields of a particular post or page: <code> echo '&lt;pre&gt;'; print_r(get_post_custom($post_id)); echo '&lt;/pre&gt;'; </code>
How to display all custom fields associated with a post type?
wordpress
This might be kind of simple, but I couldn't find a way to do so in the WP docs. My plugin currently uses custom fields for things I could just have radio buttons/check boxes for each post. How do I add a little section where I can have such options rather than custom fields?
Below is the example of a couple of checkboxes to set custom field values: <code> // register the meta box add_action( 'add_meta_boxes', 'my_custom_field_checkboxes' ); function my_custom_field_checkboxes() { add_meta_box( 'my_meta_box_id', // this is HTML id of the box on edit screen 'My Plugin Checkboxes', // title o...
How to add option box in "Edit Post" plugin API?
wordpress
I have a function which is used to display a video, I want this video to be shown after the post, It should display the video when the post ends. I have added filter to it, but then too, the video is shown before the post. Here is the filter which I am using: <code> function append_the_video($content) { global $post; $...
2 options: 1) Edit your youtube_video() function so it return a string instead of printing the code 2) The easiest way... if you can edit your theme, place the youtube_video() call after showing your post content Edit: <code> &lt;?php function youtube_video() { $ret = ""; $ret .= "&lt;div class='post'&gt;"; $newvar = u...
Add filter to the end of the post
wordpress
Is there any free (or cheap) software that can be used for testing WordPress functionality? I would like to create some test scripts and then them against my self-hosted WordPress installation.
This isn't really a WordPress question - more a generic web development issue. These are some open source tools that can be used for scripting and testing a web browser session. Selenium Cucumber Watir
Is there any free (or cheap) software that can be used for testing WordPress functionality?
wordpress
i've just find out about the custom field, which makes it possible to add something near a post, but what is the difference between "add_meta_box" and "custom field"? Custom field is inside the "supports" line, when we register a post type, so : isn't it easier to create a custom field than a add meta box? or are there...
A meta box is an element in the graphical user interface, a custom field is an extra key and value stored with a post. Most of the time the interface to change the value of a custom field is put in an extra meta box - or in the default meta box for custom fields, which you can enable per post type. Maybe a picture can ...
add meta box - custom field : which to choose?
wordpress
How I can handle this shortcode: [my_gallery] img01.jpg img02.jpg img03.jpg img04.jpg [/my_gallery] I can't understand how to write a function, to handle image files name.
Are you going to put newlines in there between each image? or just spaces? I'll put in both for this example, checking if there's a newline. You would want something like this in your functions.php: <code> add_shortcode('my_gallery', 'gallery_function'); function gallery_function($atts, $code=''){ $files=preg_split( '/...
Create own Wordpress shortcode gallery
wordpress
My custom widget's form will have two pull-down menus: the content of the second menu is dependent on the user's selection in the first menu (think of the way Country and State/Province works). I think the easiest implementation (though perhaps not the most user-friendly) would simply be to have the form automatically ...
The Save buttons have a class <code> widget-control-save </code> , and this is hooked up to <code> wpWidgets.save() </code> . So you either have to call <code> wpWidgets.save() </code> , or (probably easier) trigger a click event on the Save button.
How can I use AJAX to save/update a widget form?
wordpress
I just installed a WPML, but my custom post types is showing just in default language, if I am switching to other languages, it will show the same posts as default language, but in wordpress panel they are translated. Part of my code in function.php <code> $args = array( 'labels' =&gt; $labels, 'public' =&gt; true, 'pu...
Which versions of WPML and WordPress are you using? I'm sure that you noticed that the old versions of WPML from wp.org only run on old WordPress versions (up to 3.0.5).
WPML custom post type - not translated
wordpress
I have a custom front end page where users can post from. All works fine but the i want if more than one field is empty then the errors for all empty fields should show all together. Right now the code only show error for the first empty field it detects. The code is : <code> $errors = new WP_Error(); if (isEmptyString...
Sorry to bother . It was one of my other functions which was limiting the error to echo only once. Here is the previous code : <code> function display_message( $message = false ) { if( is_wp_error( $message ) ) { echo '&lt;div class="error"&gt;&lt;p&gt;' . $message-&gt;get_error_message() . '&lt;/p&gt;&lt;/div&gt;'; } ...
Display all WP Errors together during form validation
wordpress
In Buddypress, after Registration first step, users are redirected to Change Avatar step. Im trying to find a way to redirect to an alternate page, for example: http://www.mysite.com/yeah Im using the following code, but Im continuously redirected to Change Avatar page. <code> function custom_filter_bp_signup() { globa...
Yeah I ge it: <code> function bp_redirect($user) { $redirect_url = 'http://www.mysite.com/yeah'; bp_core_redirect($redirect_url); } add_action('bp_core_signup_user', 'bp_redirect', 100, 1); </code>
Redirect after registration in BuddyPress
wordpress
I have my CPT edit screen almost looking how I want it but want to remove the filter and view options from this screen as they are not needed for this interface. How do I remove them? Are there any filters that disable them? My edit screen has got to this stage by this code so far: <code> // Manage columns in edit scre...
Css: <code> .tablenav.top .alignleft.actions select[name="m"], .tablenav.top .alignleft.actions select#cat, .tablenav.top .alignleft.actions input#post-query-submit, .tablenav.top .view-switch { display: none; } </code> Note: You'll have to take a look at the input elements ID. I guess this will be named different on c...
Remove filter and view options from custom post type edit screen
wordpress
Nightly Builds or Beta Releases? I like using the <code> /wp-admin/update-core.php </code> utility to update wordpress. But I'd like to be able to use it to download beta releases or nightly builds. Does anybody know of a way to enable this? Perhaps a constant or option in <code> wp-config.php </code> ?
There's not a constant or anything there, but you can install the WP Beta Tester plugin to switch your update stream to the latest nightlies. Once you install this plugin, you can automatically update to the latest "bleeding edge" release from the standard update panel. Just remember, it's not advised to update product...
Is there a wp-config.php option or constant that I can set to allow me to download nightly / beta builds?
wordpress
I need to assign some tags to my posts (for external use), but I don't want them showing anywhere that tags are listed. Can someone tell me how to do this?
The best way is not to do this. Use a custom taxonomy instead.
How to hide certain tags from the_tags()?
wordpress
I have a custom post I am looking to categorize via a custom taxonomy. The taxonomy itself I want to be dependent on the items of another custom post type. Is it possible to populate a taxonomy via the items of a custom post type, or is it something I have to do manually? Plugins, snippets, guidance on alternat methods...
I always use something like: <code> add_action('save_post', 'mdz_correlate_casos_taxonomy'); function mdz_correlate_casos_taxonomy( $post_id ){ if ( defined('DOING_AUTOSAVE') &amp;&amp; DOING_AUTOSAVE ) return $post_id; if ( 'YOUR CUSTOM POST TYPE' == $_POST['post_type'] ){ if (!wp_is_post_revision($post_id)){ if (!ter...
Populate Taxonomy from Custom Posts
wordpress
How can I limit the get_pages to only show 5 items? I thought adding <code> 'number' =&gt; 5 </code> to the array would limit it to 5 but it doesn't show anything. Here's my code: <code> &lt;?php $pages = get_pages(array('post_type' =&gt; 'page','sort_column' =&gt; 'menu_order','sort_order' =&gt; 'ASC','child_of' =&gt;...
I have had similar problems with the <code> number </code> attribute in <code> get_pages() </code> I got around it by using get_children : <code> $pages = get_children(array( 'numberposts' =&gt;1, 'post_parent' =&gt; $heading_page-&gt;post_id )); </code> and using <code> post_parent </code> instead of <code> child_of <...
Limit get_pages to only show 5 items
wordpress
Is there a way to disable atom feed and have only rss feed? When I click on the RSS button on my Firefox, I am show 'subscribe to domaintitle using RSS feeds' and 'subscribe to domaintitle using atom feeds' I do not use a plugin but rather a function.
The feed links that are included in the HTML code depend on your theme. For example, Twenty Ten only includes one feed type (with two feeds: posts and comments). Check your <code> header.php </code> to see which feeds are referenced there. If it is a modern theme (like Twenty Ten), you might see no feed links there. Th...
How to disable atom feed and only use RSS feed
wordpress
I have created a custom post types and added some custom metaboxes and now I am wondering witch translation plugin I use for my site? I don't have experience with none of them, so I don't know who will support my custom metaboxes and who will not.
take a look at Internationalizing Your Plugin codex entry to get a better understanding of WordPress Translations. and read I18n for WordPress Developers after that you will know that if you coded your custom post types and metaboxes the right way with Translatable strings , all plugins work in the same way of looking ...
Custom metabox translation
wordpress
I'm trying to pull rss from sites similar to this: http://andreabadendyck.blogg.no/ I have several posts with the URL in the title, so I can pull the URLS from here and hardcode the rss reader in the theme. I want to display the recent posts like this (under "Siste innlegg"): http://blogglisten.no/blogg/andreabadendyck...
I followed this guide to insert the feed in the post: http://digwp.com/2009/11/import-and-display-feeds-in-wordpress/ My only problem is that I need to strip away the HTML from the feed.
Pulling RSS from site and display it in posts
wordpress
I have combination of valid input with native WP function throwing PHP notice. In this specific case it is image without extension with <code> image_resize() </code> . This is usually suppressed by WP, but it still has me worried because it runs in feed and such things can explode XML to pieces. If I can neither change...
Simply use the <code> @ </code> operator in front of a function to suppress an error message/notice/whatever. Fun as it is: Even the <code> image_resize() </code> function uses it for <code> chmod </code> . :)
How to handle core code throwing notice on valid input?
wordpress
How would I make my WordPress Comments Editable? I tried using an Ajax plugin that take them to another screen, but it's not as nice as I would like. For example, I just want it to re-open the initial comment box and allow them to edit their comment for at least 30 minutes after a post.
Best plugin I've found is Editable Comments .
Making Comments Editable?
wordpress
On my new site i am displaying most of the images instead of text. I show images for recently written, recently viewed, mostly viewed posts etc. I found that in 40% of cases posts are same. so i need not to hit the DB to extract the image. It can save number of hits to Db &amp; processing time. I intially thought to ca...
As long as you use WP API ( <code> $wpdb </code> ) to perform queries, they will be cached by caching plugins (well, by those that have such functionality). If you need to cache data that is more compelx to generate rather than just retrieve look into Transients API .
Cache DB queries result
wordpress
I am implementing (trying) a front end posting system which shows taxonomy data in several dropdown select fields, each of the dropdowns is named by using the "name" $arg in wp_dropdown_categories. <code> &lt;?php wp_dropdown_categories('taxonomy=location&amp;hide_empty=0&amp;orderby=name&amp;order=asc&amp;name=locatio...
Use <code> wp_set_object_terms </code> after you have the post id for each taxonomy: <code> ... $post_id = wp_insert_post($my_post); wp_set_object_terms($post_id,$location,'location'); wp_set_object_terms($post_id,$sale_rental,'sale_rental'); wp_set_object_terms($post_id,$price,'price'); </code>
Attaching taxonomy data to post with wp_insert_post
wordpress
I released the first version of stackexchange-url ("my Rewrite analyzer plugin") with a commit on 2010-05-12. The WordPress.org plugin directory however still displays 2010-11-27 as the "Last Updated" date - this is the date when the plugin directory was created in the repository. The Developer FAQ states: Last updated...
I've been trying to work out the issue for months now, and have made several adjustments to try to solve the problem. In short: Yes, we know there's a problem. No, I don't know how to fix it yet. You can stop reporting it already. Current workaround: ANY commit of any kind should trigger it to update. So simply adding ...
Plugin directory "Last Updated" not changed after initial commit?
wordpress
I've developed a few plugin for Wordpress. Currently I've not been able to replicate the way wp save settings. I've a setting page which I learned from a tutorial. It POST to <code> option.php </code> , and wp take care of saving the data. But I have some custom option page which require more complex handling. Basicall...
I've found a way to overcome what I needed by using wp_redirect() . I'm calling <code> wp_redirect() </code> after I've done processing. Also following advise from WordPress and wp_redirect() function problem , I added <code> noheader=true </code> to the form's action or link to prevent the error "header already sent" ...
Wordpress Plugin Setting's POST
wordpress
How do I override the search template i.e. used inside a theme with a custom search page inside a plugin? Please point our any relevant action/filter hooks which can be used to do this. Any help is highly appreciated.
You can use <code> template_include </code> filter hook <code> add_filter('template_include','my_custom_search_template'); function my_custom_search_template($template){ global $wp_query; if (!$wp_query-&gt;is_search) return $template return dirname( __FILE__ ) . '/my_search_template.php'; } </code>
How do I override the search template in a plugin?
wordpress
Using Wordpress 3.1 is it possible to completely disable the drafts functionality or at least remove the "Save Draft" button from the post screen?
If by draft, you mean "autosave", you can consider using this plugin: http://wordpress.org/extend/plugins/wp-feature-disable/ If you want to disable revisions, instead...try this: <code> define('WP_POST_REVISIONS', 'false'); </code> You can put that in your /wp-config.php file and it should immediately take effect. Any...
How to disable drafts?
wordpress
Is it possible to completely disable Bulk Edit functionality? I'm using Wordpress 3.1.
A more reliable approach than messing with CSS would be to add some Javascript in the admin_head action, and basically override the built-in "inlineEditPost" function (located in wp-admin/js/inline-edit-post.js and easier to read in inline-edit-post.dev.js). I haven't looked into it much specifically, but the brute for...
How to remove bulk edit options
wordpress
I want to set up a basic 'post rating' system for my site - I don't want to use a plugin - so I want to add the custom field 'rating' to each new custom post and populate this field with the number 1. Is this possible? Or am I going about this the wrong way? Did a lot of searching a found not much, <code> add_post_meta...
you can do that with hooking a simple function to <code> save_post </code> hook <code> add_action('save_post','my_rating_field'); function my_rating_field($post_id){ global $post; // verify if this is an auto save routine. // If it is our form has not been submitted, so we dont want to do anything if ( defined( 'DOING_...
Populate Custom Fields in a Custom Post Type?
wordpress
I'm familiar with this method... <code> update TABLE_NAME set FIELD_NAME = replace(FIELD_NAME, ‘find this string’, ‘replace found string with this string’); </code> The problem is, I'm trying to do this to all tables (or select tables), but need the replace to hit all columns for the table in question. Currently, the o...
Have you tried the search and replace plugin? it will allow you to select particular tables: http://wordpress.org/extend/plugins/search-and-replace/ Of course use it with caution. etc.
Global MySQL replacing of text patterns/matches
wordpress
Was asked to simplify the question. Here we go: As you know, the "content" part of a WordPress posts all appears together. What I'm trying to recreate is how on several news sites, they'll have the title (and the rest of the "meta" stuff), followed by a photo or video, but then the body text is slightly indented either...
a few ideas- use shortcodes to insert inline markup with your content. use custom fields to insert inline markup with your content. if you don't want to deal with parsing out the URL to figure out if it's an image, youtube, etc., just define different custom field names and handle them individually if they exist. read ...
How to insert a column (part of theme) in the middle of the content body?
wordpress
Hi: I have been using the comments.php, comments-popup.php, single.php and loop from the Kubrick theme to create my blog functionality in themes I build from scratch. But with WP 3.0 there's a new approach and I can't quite get it to work. From what I've gathered I have the loop in the index.php, loop with some additio...
Just download twentyten and see how it works, it's relatively simple to use it as an example. Nothing needs to go into functions.php for comments to work. You can use custom callbacks in there if you wish, but just a few template tags get the comments going <code> &lt;?php comments_template( '', true ); ?&gt; </code> I...
What templates/funtions needed in custom theme to allow comments the new 3.0 way
wordpress
I'm using Wordpress as CMS and have a checkout page where info is inserted into the db using $wpdb-> insert. I have 2 questions: Is 'sql injection' already a part of that function or do I need to add my own code? Are there wordpress form input validation functions that I can use on my custom form?
Is 'sql injection' already a part of that function or do I need to add my own code? When inserting input to the database you should use <code> prepare </code> method of WPDB class which supports both a <code> sprintf() </code> - like and <code> vsprintf() </code> -like syntax. read more at the codex Are there wordpress...
Data Validation
wordpress
I want to create a custom archive page. It will look like this: 2011 January February March April May June... (Months) May (Current Month) Post 1 Post 2 Post 3 ... And clicked one of months ( <code> is_month() </code> page) it will be look like this : 2011 (Selected Year) January February March April May June... (Month...
I highly recommend checking out the Smart Archives Reloaded plugin . It has several formats and one of them, called "fancy", displays things very similar to what you described.
Custom Archive Page
wordpress
I want to write a plugin so I can hook up the <code> wp_install_defaults </code> function. I actually need to do the following: when a new site is created, I want to import a default XML file with some categories and default posts. <code> wp_install_defaults </code> is the function that does that, but it doesn't seem t...
You can use <code> wpmu_new_blog </code> action hook which accepts 6 arguments: $blog_id $user_id $domain $path $site_id $meta
Hook up MU site creation
wordpress
When you create a post in WP, if you don't specify a title rapidly, WP generates a default slug on autosave, based on the post ID. Then, when you add the title later, unless you modify the slug by editing it, it remains the same (based on post ID) What I'm trying to do is add an action on post publish, that generates a...
As long as haven’t touched the slug WordPress will generate a new one after you entered a title. Update To change other peoples slugs use a filter (not tested!): <code> add_filter( 'wp_insert_post_data', 'prevent_numeric_slugs', 10, 1 ); function prevent_numeric_slugs( $post_data ) { if ( ! isset ( $post_data['post_tit...
How can I automatically set a post slug based on the post title during post publish?
wordpress
Ive created a custom post type and I want to hide the main textarea content in the publish/edit page. Is it possible ? Thanks!
Yes, remove the editor support from your custom post type. You can do it in two ways. While registering your custom post type: Example: <code> $args = array( 'public' =&gt; true, 'publicly_queryable' =&gt; true, 'show_ui' =&gt; true, 'show_in_menu' =&gt; true, 'capability_type' =&gt; 'post', 'has_archive' =&gt; true, '...
Hide content box with Custom Post Type?
wordpress
I have three custom post types, each with around 5 taxonomies and 2 of the custom post types share two taxonomies. I've just about got everything set up for posting from the front end other than the part of a dropdown to show the post_types. As it is now front end posting works but, the urls are broken because they don...
Sorry about that feels a bit weird answering ones own question, but here you go.... Firstly declare the variable: (customcategory) <code> global $userdata; $errors = array(); $title = trim($_POST['wpuf_post_title']); $customcategory = trim($_POST['customcategory']); $content = trim($_POST['wpuf_post_content']); $tags =...
List custom post types in dropdown
wordpress
I'm new to Wordpress and I'm trying to edit the Twenty Ten theme so that my template for basic pages (basic-template.php) does not show the comments box. I do want the comments box to show up on other pages, such as blog posts. I'm pretty sure that changes need to be made in loop.php, but my doesn't seem to be having t...
You can turn off the discussion per post/page when you're creating new posts/pages. this option is usually below the text editor and is often hidden. In order to bring it up, you might have to click on "Screen Options" at the top of the page and check the box next to "Discussion"
How can I edit the Twenty Ten Theme to remove the comments box when a page uses a specific template?
wordpress
I'd like to have a custom field interface show up only when a certain template is assigned to a particular WordPress page. Any ideas?
The best way to approach this situation is via JavaScript. That way, whenever the selected value changes, you can instantly hide/show the related metabox. Use <code> wp_enqueue_script() </code> in <code> functions.php </code> to load a custom JavaScript file in the admin area: <code> add_action('admin_enqueue_scripts',...
Toggle admin metabox based upon chosen page template
wordpress
I am currently looking for a way to replicate the image I have below. I have come across many tabbed content plugin's and snippets of code, but I cannot figure out how to add different background images to each tab.
Prepare You will have to use some jQuery and jQuery UI on your tabs. Load it with <code> wp_enqueue_script </code> - Codex , How-To . The search In any case: Google for "jQuery Tabs". Mark up The mark-up will look close to this one. <code> &lt;!-- These are the tabs --&gt; &lt;ul class="wpse-tabs"&gt; &lt;li&gt; &lt;a ...
tabbed content box with different tabbed background images
wordpress
I have been using WordPress for several years, but have yet to see a reason to employ tags over categories or tags with categories. What is the thinking behind the two, and when are each appropriate?
Aside from the technical aspects, Categories are for broad topics while Tags are for adding more detail to your posts' subject. Lorelle has written the definitive guide on the difference between categories and tags . You might also want to check out the WordPress.com guide on Categories vs. Tags .
What is the difference between a "tag" and a "category"?
wordpress
Ok = I've looked around a lot for a clear answer to this, but find very few real answers. I would really appreciate some info from experienced individuals. A tiny bit of background. I've worked content generation (among other thing) on a largeish website for many years, and it follows the pretty basic file system and d...
Put everything into WordPress. This way, you can search your entire content from the built-in search engine, and you can edit each piece. If you need pages with special markup create templates for your theme. Naked Template <code> &lt;?php /* * Template Name: Naked * * That’s the complete template! */ </code> Basic HTM...
Static files or dynamic WP pages for "static content"?
wordpress
I would like to modify a WP Gallery to use the jquery cycle plugin by malsup . I know this is possible but would like to know best practice for this, if anything just pulling out the url for each image should give me enough to work with. Please advise on best practice for this. Note I do not want to use a plugin and wo...
What your asking for has the basic functionality of a plugin, so saying you don't want to use a plugin doesn't make much sense. If you do for some reason want to write your own , using any jquery or JavaScript is relatively straightforward, you enqueue the script where you want it, then wrap whatever data your using in...
using jQuery Cycle by Malsup with WordPress Page and Gallery
wordpress
Does anyone know of a way to create a sitemap by using wp_list_pages and have the order by the same orders a custom nav menu?
Using wp_list_pages you can sort order only by: 'post_title' 'menu_order' 'post_date' 'post_modified' 'ID' 'post_author' 'post_name' anything else (like order by custom menu order) you would have to write your own function. But a better way to get it done would be to create a custom walker for it so you could control t...
wp_list_pages sort order by custom nav menu order
wordpress
i found a code searching through stackexchange --> to create a "list" inside a meta box of a custom type, BUT, i don't see anything appearing in this meta box, except the input field (which comes from the example page from the CODEX : http://codex.wordpress.org/Function_Reference/add_meta_box ), is it a problem with WP...
You are missing the declaration of the HTML select tag which options are his children so just add something like this: <code> function myplugin_inner_custom_box() { // Use nonce for verification wp_nonce_field( plugin_basename( __FILE__ ), 'myplugin_noncename' ); // The actual fields for data entry echo '&lt;label for=...
add a "list" into add meta box : problem
wordpress
I am using the code below to display posts defined as a custom-post-type and filtered by a custom-taxonomy of 'england'. I've tried using 'posts_per_page=5' in the query_posts function but this brings up a completely different set of posts from one of my post categories of type 'news'. When I remove the posts-per-page ...
Something like this is what you need. The Codex page for WP_Query is very helpful <code> $args = array('post_type' =&gt; '&lt;your custom post type name&gt;', 'posts_per_page' =&gt; 5, 'tax_query' =&gt; array( array( 'taxonomy' =&gt; '&lt;your custom taxonomy name&gt;', 'field' =&gt; 'slug', 'terms' =&gt; 'event-englan...
Limit the number of posts in query_posts function with custom post types
wordpress
Is there a way in WordPress 3.1 to restrict allowed file uploads by extension (images only) and file size? Bonus question: Can I limit users to only be able view files they have uploaded themselves?
I believe you can add a filter to <code> upload_mimes </code> to restrict to certain types. The hook: http://adambrown.info/p/wp_hooks/hook/upload_mimes The filter: <code> add_filter('upload_mimes','restict_mime'); function restict_mime($mimes) { $mimes = array( 'jpg|jpeg|jpe' =&gt; 'image/jpeg', 'gif' =&gt; 'image/gif...
Restrict file uploads by extension?
wordpress
How can I limit html elements allowed in the tinymce editor in Wordpress 3.1 and ensure harmful scripts have been removed (script/embed tags, etc)
Adjust HTML-Filter: <code> &lt;?php function fb_change_mce_options($initArray) { // Comma separated string od extendes tags // Command separated string of extended elements $ext = 'pre[id|name|class|style],iframe[align|longdesc|name|width|height|frameborder|scrolling|marginheight|marginwidth|src]'; if ( isset( $initArr...
Limiting allowed html elements/strip harmful scripts from editor
wordpress
In my taxonomy.php, my query is ` <code> $term = get_term_by( 'slug', get_query_var( 'term' ), get_query_var( 'taxonomy' ) ); $wpq = array ('posts_per_page' =&gt; -1, $term-&gt;taxonomy =&gt; $term-&gt;slug, 'order' =&gt; 'ASC', 'orderby' =&gt; 'slug'); $loop = new WP_Query($wpq);` </code> It correctly retrieves the dr...
Not possible in WP 3.2.1. See here http://codex.wordpress.org/Function_Reference/get_pages under "Parameters" and "page_name". I'm working on exactly the same thing, but it seems I'll need to resort to to a custom query: http://codex.wordpress.org/Displaying_Posts_Using_a_Custom_Select_Query
Can you orderby slug in a taxonomy archive page using WP_Query?
wordpress
I need to conditionally not show the comment form. I've added a filter to <code> comment_form_defaults </code> as follows: <code> function dont_show_comments($defaults) { $defaults = array( 'fields' =&gt; array(), 'comment_field' =&gt; '', 'must_log_in' =&gt; '&lt;p class="must-log-in"&gt;' . sprintf( __( 'You must be ...
I can think of only following ways to achieve this. There is a filter " comments_open " that check if the post whose $post_id is provided has comments open. You can use that to return false. There is another filter " comments_template " that return the template file to be used to display comment form. You can return an...
Hide comment form completely (preferably without using CSS)
wordpress