question
stringlengths
0
34.8k
answer
stringlengths
0
28.3k
title
stringlengths
7
150
forum_tag
stringclasses
12 values
Using wp 3.3beta1 with the wp_editor on the front-end for bbPress. When calling the editor on the front end, how do I allow a guest to see the visual editor? I only see options to disable the visual editor site wide, or on a per user basis, but no option to allow guests to use visual?
Just add the <code> can_richedit </code> capability to the user you want to be able to use the editor. You can use the Capability Manager to do it. Update: to enable the rich editor on anonymous/guest users, add this to your <code> funcitons.php </code> or anywhere you like, just make sure it comes before the <code> wp...
How to enable user_can_rich_edit for guests?
wordpress
I am a newb in writing this and since this is dangerous stuff to fidlle with (if you are not sure what you are doing) can you please verify it? I use wordpress multisite, this is why I chose to allow blogs.dir I want only my posts and categories indexed. That's it:) <code> User-agent: * Disallow: /cron/ Disallow: /lo/ ...
The file robots.txt doesn't exclude all the search engines to crawl your site... Most search engines crawl the hole site without taking the robots.txt file in consideration. I think that the best way is to use meta tags in the theme of the blogs. Use the next meta tags for post and categories template files: <code> &lt...
Can you please verify my robots.txt for wordpress
wordpress
Having a bit of trouble using all the Wordpress ajax hooks, and functions. Been reading this post: 5 Tips for Using Ajax in Wordpress But became confused after trying all the code and applying it to an Ajax form. I am calling a function from my plugin class to echo a from on the single posts pages for users to "Swoon" ...
Things you can check: View the page source, and look for your <code> js </code> files, if they're included or not, and whether their order is proper. Use <code> console.log(SwoonAjax.ajaxurl) </code> to check if you're getting the proper path in your <code> js </code> file. In Firebug, switch to <code> Console </code> ...
Using AJAX in a plugin to submit form - REALLY confused
wordpress
Suppose you have a WordPress blog that you are using to produce tutorials, and that you would like to split up your posts according to skill level (i.e. beginner, intermediate, advanced) depending on how technical/difficult/advanced the tutorial is. Furthermore, the blog in questions spans several categories, so using ...
Use a 'difficulty' custom taxonomy. The only thing is that you'll have to roll your own metabox that allows you to choose a single term.
What is the best way to add an advanced / intermediate / beginner tag to a post
wordpress
I'm setting up a Wordpress Network and wanted all new sites to have the same permalink structure (i.e. "/%year%/%monthnum%/%postname%/"). I'm wondering if this is possible to do via hooks or hacks in functions.php, without having to rely on users to choose that structure.
You can set the permalink structure by calling on the <code> set_permalink_structure() </code> method of the global <code> $wp_rewrite </code> object. <code> add_action( 'init', function() { global $wp_rewrite; $wp_rewrite-&gt;set_permalink_structure( '/%year%/%monthnum%/%postname%/' ); } ); </code> Here's a PHP &lt; 5...
How to set permalink structure via functions.php
wordpress
In addition to the normal feed that wordpress produces, i need to publish an additional feed of posts that have a certain custom field value. I'm a bit lost on where to start. Any tip?
Something like this will add a /feed/special to your site. <code> add_feed('special','do_special_feed'); function do_special_feed() { query_posts(array( 'meta_key' =&gt; 'key', 'meta_value' =&gt; 'value', )); do_feed_rss2(false); } </code> After putting it in a plugin or your theme's functions.php or what have you, you...
how to publish a feed of posts with a certain custom field value?
wordpress
I am using the Twenty Eleven theme and need to show the full content of the latest post and then show the rest as summary. I'm looking for instructions/help on how to display, on the home page, the full post of the most recent article and then just the summary of the older the posts. For Example (Post #5 being the newe...
after creating a child theme for Twenty Eleven, copy content.php from the Twenty Eleven theme into your child theme to edit it; find (line 35): <code> &lt;?php if ( is_search() ) : // Only display Excerpts for Search ?&gt; </code> change to: <code> &lt;?php if ( is_search() || is_paged() || $wp_query-&gt;current_post &...
Twenty Eleven: Home Page, View full post of most recent post & Summary of the rest
wordpress
I am trying to make a wordpress site with an idiot-proof backend CMS. I have built several relatively small wordpress sites, but now have moved on to a larger project and want to do it right . There will be several (maybe as much as 10+) pages each with unique structures and elements (different numbers of pictures, and...
In my experience, the default "Pages" is easy enough for people to understand..it is where you edit each page. You can make a "Videos" page template for a Videos page that can show the page content at top "your text areas" and then calls a listing of all the custom post type Videos you created. I just worked on a site ...
Custom posts type for individual pages?
wordpress
I have a series of share buttons, each one using a short URL (using Ozh's Yourls plugin) and a page title (as found on stackexchange-url ("urlencoding of the_title() doesn&#39;t work?")) and some require a description. How do I put the blog description, encoded correctly, into my URL?
<code> echo urlencode(get_bloginfo('description')); </code>
How do I urlencode() the blog description?
wordpress
I'm a bit stuck with getting the custom permalink for custom post type (CPT) archive to work. I've registered my 'press_release' CPT as following: <code> add_action('init', 'press_release_post_type_init'); function press_release_post_type_init() { $labels = array( 'name' =&gt; _x('Press Releases', 'post type general na...
Here's the solution: Install Custom Post Type Archives plugin Go to Settings-> Post Type Archives Remove the url base option (leave it blank) Change the template pattern to <code> archive-{POST_TYPE}.php </code> Tick your custom post type and click save Rewrite/save your custom permalink structure Now your links <code>...
Custom Post Type Archives by Date with Custom Permalink
wordpress
How do I determine if I'm on the very first page of pagination? I'm using WP_Pagenavi. I want to run a function only on the first page of the pagination. I checked the query_var 'paged', it's set to 0 on this page, and then 2, 3 and so on in the later pages (1 is missing!)... Anyone knows a clean solution? Thanks.
<code> // get current page we are on. If not set we can assume we are on page 1. $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; // are we on page one? if(1 == $paged) { //true } </code>
How to determine if I'm on the first page of pagination?
wordpress
Site is: http://kremim.com WordPress 3.2.1 MS, buddypress,bbpress installed. wp_options have 333 records. But Object Caching 2165/2469 objects? Why 2000+ ? Debug: http://www.unsalkorkmaz.com/problems/kremim_debug.txt lots of notoptions:options , alloptions:options ? whats those?
Simply put - not everything in object cache is an option. Many other things, such as fetching posts or results of resource-intensive function calls, are also cached in there. I am not sure about meaning of that naming scheme, but according to plugin's author that seems to be normal operation.
w3 total cache - Object Caching 2165/2469 objects?
wordpress
I'm writing a function to make all of my header images link to their respective home pages. I wrote this function: <code> function get_category_location(){ $header = get_category_header(); $home = bloginfo('url'); if ($header == 'wth') { $location = $home . "/wth/" ; } else if ($header == 'campus' || $header == 'tech')...
you are storing the value into a variable you need to use <code> get_bloginfo('url') </code> http://codex.wordpress.org/Function_Reference/get_bloginfo
Header Link function not working. Problem with bloginfo()
wordpress
So I have several CPTs set up but I want to have all my default posts listed under /blog. I was hoping I could somehow enable has_archive for the default post type but I have yet to succeed. Any ideas? <code> add_action( 'init', 'enhance_post' ); function enhance_post( ) { global $wp_post_types; $wp_post_types['post']-...
You can change front page and designate another as blog via Reading settings. See Creating a Static Front Page in Codex.
has_archive for default post type
wordpress
I'm looking for a plugin that will allow me to link to posts by title. That is, when I click the link icon in the editor (or some other icon), instead of entering a URL, I get a drop-down of posts to link. I select one, press okay, and tada! Link is done. I also expect that the link looks at the ID; so if I change the ...
SEO Smart Links does an amazing job for this. It provided exactly what I wanted.
Plugin to Link Posts by Title
wordpress
For example, I have a post that's filed under category 1 and category 2. When someone clicks on it from category 2, I want to know the slug for category 2. If it links from the category 1 page, I want to know the category 1 slug. Is this even possible?
As anything that has to do with stats this is really an analytics task and as such not something that WP does natively. You options are: installing (if not already) some kind of analytics solution and getting data from it add code to that post that will track referers (I won't really recommend this since it comes with ...
Is it possible to know which category page the post was linked from?
wordpress
The function below creates a button when used like so [btn]Button Text[/btn] <code> function btn($atts, $content = null) { extract(shortcode_atts(array('link' =&gt; '#'), $atts)); return '&lt;a class="btn" href="'.$link.'"&gt;&lt;span&gt;' . do_shortcode($content) . '&lt;/span&gt;&lt;/a&gt;'; } </code> I'd like to be a...
<code> function btn($atts, $content = null) { extract(shortcode_atts(array('link' =&gt; '#', 'color' =&gt; 'teal' , 'size' =&gt; 'large'), $atts)); return '&lt;a class="btn '.$size.'" href="'.$link.'" style="background:'.$color.';"&gt;&lt;span&gt;' . do_shortcode($content) . '&lt;/span&gt;&lt;/a&gt;'; } </code> With th...
Shortcode Variations?
wordpress
I have just created a custom database table and would now like to output every inserted row from it into a predefined format using a foreach statement. Some guidance in this matter would be great. Thanks, Ashley
Thanks to Rutwick Gangurde, I found out how to do it. <code> &lt;?php $mylistitems = $wpdb-&gt;get_results("SELECT * FROM wp_mytable"); foreach ( $mylistitems as $mylistitem ) { echo $currency-&gt;somefield; } ?&gt; </code>
Custom Database Table and foreach
wordpress
I'd like to set up my WP so that urls ending in <code> /last </code> would return the most recent post in that set of posts. For example, <code> /last </code> returns the most recent post of any type, <code> archives/category/trivia/last </code> would return the most recent post categorized as trivia, and <code> archiv...
<code> add_action( 'init', 'ASHmostrecent_init' ); function ASHmostrecent_init(){ add_rewrite_rule( 'last/?$', 'index.php?post_type=post&amp;posts_per_page=1'); } </code> A query already pulls up posts starting from the latest to the oldest, so all you have to do is limit what's returned by one. <code> posts_per_page <...
url rewriting for most recent post
wordpress
I'm not sure if this is possible but after extensive searching I can't find an answer. What I want to do is to get all images from a NextGEN gallery so I can display them in a custom slideshow within a page/post. Is it possible to load them into an array or edit the HTML in some way? Any help is greatly appreciated!
For anyone interested I found a solution to what I wanted. You simply need to create a custom template Then I accessed the images like this: <code> &lt;?php foreach ($images as $image) : ?&gt; &lt;?php echo do_shortcode('[singlepic id="' . $image-&gt;pid . '"]'); ?&gt; &lt;?php endforeach; ?&gt; </code>
Retrieving images from a NextGEN gallery
wordpress
Im Getting a couple of warnings when creating custom post types, someone referred me to using a plug in but since i'm new to this i want to know what is going on so i want to do it manually. This are the warnings i get. <code> Warning: Missing argument 2 for _x(), called in C:\xampp\htdocs\wordpress\wp-content\themes\p...
Wherever you're using <code> _x('lorem') </code> , use <code> _x('lorem', 'models'); </code> instead. Models is actually supposed to be a context, but I don't know your context, hence using models. Try this.
Help With Warning on creating new Post types?
wordpress
I need this for menu "red car", "blue car", "green car". Information is retrieving from a single category (cars). But the output on pages depending on the values ​​in the metaboxes (colors). On the page with blue cars shouldn't be a green cars. Cars and colors for illustrative purposes only. How can I do this?
I did it with $_REQUEST help. This is not very pretty solution because of ugly url, but it works. http://example.com/?key=value Something like: <code> if ( $_REQUEST['key'] == 'value' ) { $additional_args = array( 'meta_key'=&gt;'key', 'meta_value'=&gt;'value' ); $args = $args + $additional_args; } $query = new WP_Quer...
How can I make different page templates for one category?
wordpress
I am trying to create a custom button shortcode, with multiple color and size options. However, when I try to use the shortcode in my post it isn't showing up. My Function <code> function btn($atts, $content = null) { extract(shortcode_atts(array('link' =&gt; '#', 'color' =&gt; 'teal' , 'size' =&gt; 'large'), $atts)); ...
How about this? <code> &lt;?php function btn($atts, $content = null) { extract(shortcode_atts(array('link' =&gt; '#', 'color' =&gt; 'teal' , 'size' =&gt; 'large'), $atts)); return '&lt;a class="btn '.$size.'" href="'.$link.'" style="background:'.$color.';"&gt;&lt;span&gt;' . $content . '&lt;/span&gt;&lt;/a&gt;'; } add_...
Button Shortcode
wordpress
I would like to know my options for how best to use WordPress as a wiki. I tried Media Wiki, but the sheer amount of changes I need to make to code to make even trivial changes turned me off. Way off. Googling doesn't reveal much. What are the best options for using WP as a wiki? (This can be a community question discu...
Wordpress CMS is for blogging you can do this with it but can make something similar like this with your own logics but i recommend you to use other CMS there are many CMS for wiki also check this top 5. MediaWiki MoinMoin PhpWiki OddMuseWiki TikiWiki
Options for Wiki WordPress
wordpress
I'm confused about the different uses of esc_html() and wp_kses(). I understand that esc_html() converts special characters to their HTML entity, and that wp_kses() removes unwanted tags (e.g., &lt;script&gt;), but I'm not sure in what contexts they should be used together or separately. If I run some untrusted HTML th...
The general rule, at least as espoused by Mark Jaquith, is sanitize on input, escape on output (the corollary to this rule being sanitize early, escape late ). So: use sanitization filters (such as the <code> kses() </code> family) when storing untrusted data in the database , and use escaping filters (i.e. the <code> ...
Should HTML output be passed through esc_html() AND wp_kses()?
wordpress
I am trying to use wp_query (or another native Wordpress query class) to do the following: get all posts WHERE ( post_type = 'post' AND category = 7 ) OR ( post_type = 'case-studies' AND meta_key = 'homeslide' AND meta_value = 1 ) I am not sure any of them can handle this yet. Trying with WP Query: <code> $args = array...
Ok I put together a solution using get_posts &amp; query_posts to return the arrays for each: posts and case-studies. Then array_merged them (thanks for the heads up EAMann), then using uasort() with a custom compare function to sort them by post_date. It's not the most attractive solution, but since it works and I'm o...
Tricky WP Query
wordpress
I need thumbnails of minimum width: 400px. I would like that if the user uploads an image that is, say, 380px wide, Wordpress creates a 400px-wide version. Is that possible?
No, its not. But you can set up a css rule like min-width:"400px" for the thumbnails
post thumbnail: increase dimension if smaller than... Possible?
wordpress
I am running WPMU 2.9.2 and want to update to WP 3.2.1. As I understand it, WP 3 took in WPMU. I imagine that involved some big changes to the implementation of WPMU. What steps do I need to take to perform the upgrade? Thank you. Pat
The codex has some very detailed advice: Upgrading_WPMU . Make sure to test it on a safe copy of the real site.
upgrade from WPMU 2.9.2 to WP 3.2.1
wordpress
How can I to add a wrapper class to the WordPress admin bar? I would like to center the contents to the same width as my theme.
There isn't a filter/wrapper for the admin bar CSS that you can plug into , the function is simply <code> function wp_admin_bar_header() { ?&gt; &lt;style type="text/css" media="print"&gt;#wpadminbar { display:none; }&lt;/style&gt; </code> You can over ride the CSS using <code> !important </code> or use jQuery to prepe...
Add class to WordPress admin bar?
wordpress
I have seen a number of similar questions here on WP_SE but I believe my situation is a little different because the common libraries I'm creating are frameworks that I'd certainly like to be able to update and maintain, but are not decorations - ie: I can't author a theme that depends on the library and then degrade t...
Can a theme or plugin go and fetch another plugin and install it? For themes, it's rather straighforward. See https://github.com/thomasgriffin/TGM-Plugin-Activation For plugins, it's trickier, since you can't bundle the same boilerplate code in more than one plugin. See http://wordpress.org/extend/plugins/plugin-depend...
Theme and Plugins sharing common libraries
wordpress
I'd like to enable the Recent posts widget with the ability to show a "View All" link when there are more posts than I've currently got the widget set to show. I'd also like to be able to exclude certain categories or posts from it. Is it possible to do either via my theme's functions.php? (1) Customize the existing wi...
It's usually best to copy the existing one, name it something unique, and then add your own functionality. Copy the <code> WP_Widget_Recent_Posts </code> class from wp-includes/default-widgets.php into your functions.php (or, preferably, another file in your theme devoted just to widgets) and rename to something else, ...
Can I create my own "Recent Posts" widget or customize the existing one?
wordpress
How can I list users by last name ASC when using WP_User_Query ? There is an orderby parameter but looking in core it doesn't accept ordering my user meta. Anyone know how to extend WP to allow this ordering by last name?
Made something myself: Page template file: <code> &lt;?php $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; $paged -= 1; $limit = 20; $offset = $paged * $limit; $args = array( 'number' =&gt; $limit, 'offset' =&gt; $offset, ); // Create the WP_User_Query object global $wp_query; $wp_query = new WP_User_Qu...
List users by last name in WP_User_Query
wordpress
I'm used the plugin More Types to create a custom post type (News). I'm also using the plugin Smart Archives Reloaded to have an archive of my custom post type. The problem is when i click on a month which takes me to .com/2011/10 i just get a page not found. I've also added the wordpress archive widget to the sidebar ...
I've used a plugin called collapsing archives and it appears to be working with that. Maybe it was an issue with smart archives not working with custom post types, not really sure. It's working now though.
custom post type not getting archived?
wordpress
I am trying to prevent index.php from redirecting to a file index.html which I also have in the home directry. I want the index.html file to remain there for a few days until the wordpress site is finished, being the page that visitors will see, and I'd access the new installation by adding index.php to the url; but wo...
Found the problem - you have to access index.php/ not just index.php
Disable redirect canonical
wordpress
I have some posts in which I inserted the picture manually (before migrating to Worpdress) <code> &lt;img src="http://www.example.com/images/2010/quand-l-inde-compte-ses-habitants,M35788.jpg" border="0" alt="" /&gt; </code> I want to use those pictures as "featured image", but they don't appear in the post Gallery. Wha...
Found a solution - using the plugin "Add from server", I can re-import the pictures which I attached to the posts when the blog was powered by Dotclear.
Picture inserted in the post not showing in "Gallery"
wordpress
We'd like to use WordPress to author the technical documentation for our software product. We've used plain-old WordPress pages, arranged then hierarchically, and it works ok, but it's not great. The problems: The Wordpress page editor is dog slow. You can't drag and drop pages around to change the hierarchy Nothing ma...
You're going to have to go with some plugins. The Wordpress page editor is dog slow. Throw more resources at it and/or disable some functions from showing under the "Screen Options" tab. It should not really be slow unless your have a ton of people working on a ton of pages at same time, if you can clarify what/why it ...
Wordpress plugin for authoring technical documentation?
wordpress
I've got a custom post type called Products and when i go to select page parent i only get other pages of the same post type. Is it possible to select a category as a parent for the page? The reason i'm asking is i have a plugin that lets me automatically add child pages to a menu under the parent. If i can somehow be ...
I didn't need to set a category as a page parent, i found this which did exactly what i needed. It shows a menu of categories and subcategories as well as their posts. http://wordpress.org/extend/plugins/collapsing-categories/
Select Category as Page Parent
wordpress
I am trying to embed a Vimeo video into a post. I am inserting the URL into the page like so. <code> Lorem ipsum dolor sit amet, consectetur adipiscing elit. http//vimeo.com/1234 Lorem ipsum dolor sit amet, consectetur adipiscing elit. </code> It is outputted as the plain text URL. I have tried it with a youtube link a...
Looking into WordPress Core vimeo is registered like so: <code> '#http://(www\.)?vimeo\.com/.*#i' =&gt; array( 'http://www.vimeo.com/api/oembed.{format}', true ), </code> But looking at vimeo API for oEmbed they show their URL without the <code> www. </code> so what you need to do is register vimeo oEmbed correctly: <c...
oEmbed not recognising Vimeo URLs
wordpress
I want my permalink for my standard posts to be www.mywebsite.com/photoblog/name-of-post So I've written the custom structure as: /photoblog/%postname%/ However, my custom post type 'projects' permalinks now displays as www.mywebsite.com/projects/photoblog/name-of-post How can I fix this so it only displays 'photoblog'...
I added with_front='false' to the slug rewrite for the custom post type
Change permalinks for posts but not custom post type?
wordpress
How do I set the medium and large images sizes in WP to hard crop? In my theme I can set the thumbnail size to hard crop using this: <code> add_theme_support('post-thumbnails'); set_post_thumbnail_size( 96, 96, true ); </code> But I can see no way to make the medium and large images to hard crop. Is there possibly a wa...
You can over write the default like this: <code> add_image_size( 'medium', 200, 200, true ); </code>
Set default image sizes in WordPress to hard crop
wordpress
I want to activate Paypal 'Buy Now' button for my products. After purchasing product it needs redirection to thank you page. How to do this via a plugin? Is there any plugin available for this task? Please recommend a plugin or an easy way to achieve this. Thank you.
For wordpress plugins you can see the below links http://wpmu.org/8-wordpress-paypal-plugins-for-receiving-payments-and-donations/ http://www.tipsandtricks-hq.com/wordpress-simple-paypal-shopping-cart-plugin-768 http://www.bestwpplugins.net/wordpress-plugins-for-paypal-integration.html Check this plugin link it might w...
Buy now button and thankyou page for my website?
wordpress
Advanced custom fields(2.1.4) plugin disables the wordpress default editor for custom post types. How can I fix this.
I'm using Advanced Custom Fields (3.1.5) and attaching it to a custom post type. I was startled when adjusting some values with my advanced fields that the editor for my custom post type disappeared. I solved the problem very simply: On the Edit Field Group page, go to the bottom of the Options section and make sure 'E...
Advanced Custom Fields Plugin - Conflict with Custom Post Type Default Editor
wordpress
Is there a way to create a login/register with facebook and facebook comments on my wordpress site without using plugins? Some sort of a guide would be appreciated.
You can use the Facebook Comments for WordPress plugin or the Disqus Comment System , which allows comment login using Google, Twitter, Facebook, or OpenID accounts, and is totally import/export compatible with WP comments.
Facebook and WordPress
wordpress
Im creating a theme which have a custom setting page. I know the best method to choose a static page is by going to Settings -> Reading, but my client wants to have all in the same place. I already got the dropdowns on the settings page and i did the front page by creating the front-page.php file and added <code> $opti...
the front page displays setting as set under settings > reading is stored in the options table under <code> show_on_front </code> , with value either <code> posts </code> or <code> page </code> . if page is selected, the selected pages are stored in options <code> page_on_front </code> and <code> page_for_posts </code>...
Select front page and blog page in custom theme settings page
wordpress
Upgraded to 3.2 from 3.1 and lost the featured image panel in admin that was running in a custom post type. <code> add_action( 'init', 'create_my_post_types' ); function create_my_post_types() { register_post_type( 'header_image_gallery', array( 'labels' =&gt; array( 'name' =&gt; __( 'Header Images' ), 'singular_name' ...
Change this: <code> // This theme uses post thumbnails add_theme_support( 'post-thumbnails', array('post', 'page') ); </code> To this: <code> // This theme uses post thumbnails add_theme_support( 'post-thumbnails' ); </code> The problem is that the array is explicit , when used. So, post-thumbnail support will only be ...
Featured Image Panel Missing From Custom Post Type in Wordpress 3.2
wordpress
Being new to word-press as well php i am struck at a point. I am trying to display author information along with his picture in the post and have successfully able to fetch all the data from gravatar.com and able to display it on the right hand side bar successfully. Currently this box is coming through out the website...
Where is your code for the author appearing (what files > category / post / single?)? I would guess you have the author code within either a category or post template file, simply add the author code to the single template file (create single.php if you don't have one) and remove from the upper level files. ** To answe...
Showing author box on post detail page
wordpress
I am using bbPress 2x and modified the plugin to use the new wp_editor in place of the textarea for adding new topics and replies. This part works beautifully. Where I am stuck is when a person clicks edit for a topic or a reply. The post content is not showing up in the editor. I'm probably just missing something real...
For the sake of completeness, I am going to post an answer based on the solution you edited in your question. <code> $post = get_post( $post_id, 'OBJECT' ); wp_editor( esc_html( $post-&gt;post_content ), 'textarea01', $settings ); </code> This would escape the HTML too so if you are editing a post you might want to rep...
How to edit posts with the new wp_editor api?
wordpress
Any suggestions on the simplest way to display tags using get_tags in an html table (4 columns across) ? Example: Tag 1 | Tag2 | Tag 3 | Tag 4 Tag 5 | Tag 6 | Tag 7 | Tag 8 I'm using the following code to display tags, I found it in codex .: <code> $tags = get_tags(); $html = '&lt;div class="post_tags"&gt;'; foreach ($...
This is what I tried and it works well. I am using <code> array_chunk </code> , but I'm also adding a check to see if a chunk has less than 4 values (as you want 4 columns), then just add a blank <code> &lt;td&gt; </code> , which will avoid the mark up from breaking. <code> &lt;?php $tags = get_tags(array('hide_empty' ...
How to list Tags using get_tags in an html table?
wordpress
I'm using a filter on get_terms (see below) to remove a specified number of named categories from the "Manage Categories" listing. It works great, however, the excluded categories are still counted in the category count field that's displayed just under the "Search Categories" button. Is it possible that I can subtract...
I think you should use <code> get_terms_args </code> filter instead of <code> get_terms </code> and just add exclude arg, so now <code> get_terms() </code> function won't retrieve those cats and you'll get right count. Here's code example: <code> add_filter( 'get_terms_args', 'mamaduka_edit_get_terms_args', 10, 2 ); /*...
Excluding categories from "Manage Categories" using a get_terms filter
wordpress
I have noticed that my TinyMCE editor in Wordpress MU 2.9.2 loses text after a double space when you save a blog post. This is a problem because some users habitually use two spaces after a period. In these two examples, there are two spaces between "test" and "test": "test test" ("test__test") becomes "test" when the ...
Problem solved: In 2.9.2 under "New Blog Defaults", the field "Encoding for pages and feeds" was blank and should have been <code> UTF-8 </code> . When I updated this field on all blogs, the problem went away. In 3.2.1 you can edit this value on a blog by blog basis on the reading settings page: <code> /wp-admin/option...
editor text cut off when using 2 spaces (after periods)
wordpress
Seriously, I hate flyout menus with a passion, and now they're popping up all over the place in the admin screen. (They are particularly heinous when you use the blue admin theme, because they add a dark arrow. Eye dirt.) How do I disable the flyout menu? They add zero functionality and usability to my workflow. Thanks
It's a bit of a workarround but here you go: <code> function remove_flyout() { echo '&lt;style type="text/css"&gt; .js #adminmenu .wp-submenu.sub-open { display: none; } &lt;/style&gt;'; } add_action('admin_head', 'remove_flyout'); </code> Put it in your functions.php
How to disable admin flyout menus?
wordpress
Where you can see it: http://themeforward.com/demo2/functional-codes The first button is my code, as it should appear. The second button is within <code> &lt;pre&gt;&lt;code&gt;&lt;/pre&gt;&lt;/code&gt; </code> tags to show users how I made the button appear. But instead of showing the code, the button is generated. Ho...
You can display a shortcode by using two (or three) square brackets at the open and close, e.g. <code> [[[pdf href="http://www.constitution.org/usdeclar.pdf"]Declaration of Independence[/pdf]]] </code> In my experience, a standalone shortcode just needs two whereas one that wraps needs three on each end, even though I'...
Problem with <code> tag
wordpress
hii I am making a site related to entertainment which also has Movies Wallpapers category where i want that i can add new Movie wallpapers in single post and People can View and download them easily ? So it will be very difficult to check all Available Plugins So i need suggestions which plugin is better for my Idea Si...
What you could do is use NextGen Gallery and then in the picture description provide a download link to the wall paper or the original picture file. You can find it here: http://wordpress.org/extend/plugins/nextgen-gallery/
Wordpress wallpaper Plugin
wordpress
Where did the screen options menu go? I can't seem to find it anywhere in the new "improved" admin interface. Screenshots from the dashboard page:
Apparently, they decided to move it under the un-helpful "help" menu in the main admin bar.
Where did the screen options menu go?
wordpress
I'm facing a problem where I haven't seen proper answer anywhere. What I need help with is this: How can I prevent my users registering non-alphanumeric usernames? To be exact, I could prevent it by using something like: <code> function validate_alphanumeric_underscore($string?) { return preg_match('/^[A-Za-z][A-Za-z0-...
Check for alphanumeric For more details, look at the regex Q on stackexchange-url ("SO"). <code> $name = 'input string 123"; // Doesn't allow: // Pre-/Appending white space // Not more than one space in between // Non-alphanumeric characters (lower case) if( ! preg_match( "/^[a-z0-9]+([\\s]{1}[a-z0-9]|[a-z0-9])+$/i", $...
Alphanumeric usernames and error message for it
wordpress
I would like to set a site's front page to be a single post from a custom post type. I have been able to alter the request for my front page to a Custom Post Type archive with the following code (originally stackexchange-url ("posted here")): <code> function custom_front_page($wp_query){ if($wp_query-&gt;get('page_id')...
Easiest way to display single post on front page would be: <code> global $wp_query; $wp_query = new WP_Query( array( 'p' =&gt; 'POST ID HERE' ) ); include( 'single-POSTTYPE.php' ); </code>
How to use a custom post type as front page?
wordpress
I would like to use PHP in some posts. These posts should look like normal posts, be in the archive and categories like normal posts an have tags. I don't need PHP in every post, but it would be great if I could use it in some. I saw that it is possible to create custom page templates which seems to be almost what I wa...
You can edit the <code> single.php </code> and/or <code> content-single.php </code> files in your theme. Then it depends what you mean by "some". You could apply some conditions to your code (only certain categories, certain tags, certain specific post IDs only, etc.) You could also create a custom post type "myspecial...
How can I include PHP-Code to my post?
wordpress
I'd like to use a custom post type archive as a site's front page, so that <code> http://the_site.com/ </code> is a custom post type archive displayed according to my <code> archive-{post-type}.php </code> file. Ideally I would like to alter the query using <code> is_front_page() </code> in my <code> functions.php </co...
After you have set a static page as your home page you can add this to your <code> functions.php </code> and you are good to go. This will call the <code> archive-POSTTYPE.php </code> template correctly as well. <code> add_action("pre_get_posts", "custom_front_page"); function custom_front_page($wp_query){ //Ensure thi...
How to use a custom post type archive as front page?
wordpress
My theme has a custom post type called 'portfolio'. I want the url to display 'projects' instead. I've change the rewrite on the register_post_type function to 'projects' but it doesn't change the permalinks... <code> 'rewrite' =&gt; 'projects' </code> How can I fix this?
rewrite accepts a boolean or array, try: <code> 'rewrite' =&gt; array( 'slug' =&gt; 'projects' ) </code> make sure to visit your permalinks settings page to flush rewrites after you make the change.
Rewrite on custom post type permalink not working?
wordpress
So I have the following custom <code> wp-query </code> working on my site: <code> function custom_front_page($wp_query){ if($wp_query-&gt;get('page_id')==get_option('page_on_front')){ $wp_query-&gt;set('post_type','album'); $wp_query-&gt;set('page_id',''); // empty // fix conditional functions $wp_query-&gt;is_page = f...
You can use the following filter: <code> add_filter('wp_list_pages', 'foo_bar'); function foo_bar($html){ //Create a regex pattern to identify the LI element with preg_match //Create another pattern to identify the class attr and alter it with preg_replace return $html; } </code> As I'm not familiar with the exact elem...
How to apply the 'current_page_item' class to an archive page in `wp_list_pages()`?
wordpress
I find that the parent/child pages in the "Pages" area of WordPress has become a bit confusing since the introduction of the new menu creation area. Using the new menu system, as far as I know I can set a page which is actually itself a child page (in the pages section) to be a parent of a page which is actually itself...
Using the new menu system, as far as I know I can set a page which is actually itself a child page (in the pages section) to be a parent of a page which is actually itself a parent= TRUE What is normaly done on a site that doesn't use wp_list_pages? I can't speak for all, but I do just as you mentioned. I order the men...
Parent/Child pages
wordpress
I want to have an offset of 4 posts for my related posts. I'm using Flowplayer's jQuery Tools Scrollable, so I want people to be able to scroll through the 4 latest posts, then the next 4 posts etc. I tried something like that, but I keep getting error messages: <code> &lt;h2&gt;Related Posts&lt;/h2&gt; &lt;!-- "previo...
It's a php error probably because its expecting either one of your if statements to be closed before the endwhile. It's hard to tell without seeing all the code but at a guess check this one is closed: <code> if ($tags) { </code> also I would wrap your foreach in curly brackets. Maybe just preference though... <code> f...
Offset for Loop
wordpress
i am trying to build a widget that would display a list of top authors on sidebar.. This is not my first widget but it is my second one so my apologies if i am way off.. The problem is that when i drag the widget into the side (in admin ofcourse) and saves it apears no where..later when i check i see after refreshing t...
It sticks if you don't include <code> id_base </code> in <code> $control_ops </code> , when you pass it to WP_Widget in the constructor. Looking at the core code it looks as though <code> id_base </code> is actually the first arg to WP_widget and the <code> $control_ops </code> array should only carry 'width' and 'heig...
Got a problem with a widget
wordpress
I'm trying to password protect a page but it doesn't seem to be working. I've set the password for the page but when you navigate to it it just loads up like normal and doesn't ask for any passwords. This is the loop I have on my page: <code> &lt;?php /** * @package WordPress * @subpackage Default_Theme * Template Name...
One solution would be to create a custom Page template for Pages that you intend to password protect. Start by creating your custom Page template, perhaps named <code> template-password-protected.php </code> , and add the <code> Template: </code> file-docblock tag at the top, like so: <code> &lt;?php /** * Template: Pa...
Password protecting a page
wordpress
My current WordPress site only exists of pages. The structure is as simple as this: <code> example.com/hotels example.com/attractions example.com/restaurants </code> I want to use Custom Post Types to add listings about individual hotels, attractions and restaurants. The new structure will look like this: <code> exampl...
Personally I would structure it like a CPT for each Hotels, Attractions, Restaurants. Then a custom taxonomy that ties them together for instance "Places" with children like "Locations", etc. If the site has a lot of connected data it is a really good idea to sketch out the relationships on paper or using software like...
How many Custom Post Types to register?
wordpress
I'd like to get a post's featured image and use it in the style="background: url()" of the post. I thought this would do it, but alas I was wrong because this outputs the whole (img src=""> stuff. <code> &lt;div style="background: url(&lt;?php the_post_thumbnail( 'thumbnail' ); ?&gt; ) !important;"&gt;adasdasdasd &lt;/...
You just need to retrieve the src attribute of the thumbnail: <code> $thumb_src = wp_get_attachment_image_src ( get_post_thumbnail_id('thumbnail')); </code> <code> $thumb_src </code> is then an array containg the url, width and height of the thumbnail image. So something like... <code> &lt;div style="background: url(&l...
How to add post featured image url to inline background url()?
wordpress
i have try many methods after searching on internet but unable to ramove Nothing Found from my 404 page title how to do it please help me even i have us this in my 404 page header <code> if( is_404() ) echo '404 message goes here | '; else wp_title( '|', true, 'right' ); </code> i also ramove php title function and fiv...
I would use the <code> wp_title </code> filter hook: <code> function theme-slug_filter_wp_title( $title ) { if ( is_404() ) { $title = 'ADD 404 TITLE TEXT HERE'; } // You can do other filtering here, or // just return $title return $title; } // Hook into wp_title filter hook add_filter( 'wp_title', 'theme-slug_filter_w...
How to Change 404 page title
wordpress
I have a WP-Query which I pass post IDs to via <code> 'post__in' =&gt; explode(',', $my_ids) </code> I then want the ability to refine this list by a custom field value (if present). I have tried including the custom field test in the args for WP-Query but I get my ID list PLUS the custom field post IDs (instead of my ...
Have you tried using meta_query ? More details at http://codex.wordpress.org/Class_Reference/WP_Query .
How to refine WP-Query with further criteria
wordpress
I'm using some code provided stackexchange-url ("in an answer") on here to calculate "post X of Y" and display pagination icons on single.php. It works beautifully but it's causing problems displaying <code> the_content(); </code> On my local MAMP server it displays the content from the first post on every post, and on...
Try adding <code> wp_reset_postdata(); </code> after the <code> endwhile; </code> statement.
Wp-query causing problems with the_content();
wordpress
In the wordpress settings => Reading => Blog pages show at most [input field] posts I have it set to 3 posts at the moment. On my index, date archives, tag archives, category archives, search results, etc... All pages that use the loop and paging, it shows 3 posts per page now. My goal is to be able to have different n...
This will do it: (add to your theme's functions.php) <code> add_action( 'pre_get_posts', 'set_posts_per_page' ); function set_posts_per_page( $query ) { global $wp_the_query; if ( ( ! is_admin() ) &amp;&amp; ( $query === $wp_the_query ) &amp;&amp; ( $query-&gt;is_search() ) ) { $query-&gt;set( 'posts_per_page', 3 ); } ...
Change Posts per page count
wordpress
Hi I'm trying to select users with a particular role only, using the following sql statement... <code> SELECT DISTINCT ID, u.user_login, u.user_nicename, u.user_email FROM wp_users u, wp_usermeta m WHERE m.meta_key = 'wp_capabilities' AND m.meta_value LIKE '%supplier%' ORDER BY u.user_registered </code> However, it reu...
Double-check your SQL syntax. It sounds like you want to do a <code> JOIN </code> ... But you're not building the query correctly. It should be something more like: <code> SELECT u.ID, u.user_login, u.user_nicename, u.user_email FROM $wpdb-&gt;users u INNER JOIN $wpdb-&gt;usermeta m ON m.user_id = u.ID WHERE m.meta_key...
SQL select of users by metadata
wordpress
I'm looking to create a page for a wedding site that will have a form. The idea is that it is an RSVP page where a visitor will input a unique string that was on the invitation that they received and will take them to another page that will have the info (attending, how many guests, etc.), after that storing it in a da...
If I were doing it this is how I'd do it: I would be to use a plugin such as cFormsII (free), Gravity Forms (Commercial), or several others to store the data in the database. Both the plugins I mentioned allow you to export the data which is great for a guest list. For the key you could go about it the lazy way by havi...
Adding Custom Forms
wordpress
I must say that I am a complete nooby at Wordpress custom URL rewrites. I have searched for past many days to find a clear explanation of how to determine and write correct pattern for URL rewrites. I have a custom page template that uses query var passed to it, e.g. http://example.com/pagename?user=username . In this ...
Extending @Stephen Harris' excellent answer, I would opt for; <code> add_action( 'generate_rewrite_rules', 'my_rewrite_rules' ); function my_rewrite_rules( $wp_rewrite ) { $wp_rewrite-&gt;rules = array( 'mypageslug/([^/]+)/page/?([0-9]{1,})/?$' =&gt; $wp_rewrite-&gt;index . '?pagename=mypageslug&amp;user=' . $wp_rewrit...
URL rewrites and pagination
wordpress
How do I force WordPress/Buddypress to use the WordPress admin bar on the frontend? I know that I can disable the BP bar with <code> define( 'BP_DISABLE_ADMIN_BAR', true ); </code> in the config, but the admin bar does not show back up.
In your <code> wp-config.php </code> , put this: <code> define( 'BP_USE_WP_ADMIN_BAR', true ); </code> Note you must put it in wp-config.php, I had it in functions.php first and it did not work.
How to re-enable admin bar with Buddypress active? (BP bar removed)
wordpress
im trying to get a post info when I click a button on the post and make it echo out the the same info it has in the else function, I tried adding in a query but in return it makes it echo back all the post instead of just the one im clicking on <code> &lt;?php $cb_bp_x_points = cp_displayPoints($bp-&gt;loggedin_user-&g...
Well this worked... <code> $the_query = new WP_Query("post_type=prizes&amp;p=".$redeem_id."&amp;post_status=publish&amp;p={$_GET['post_id']}");while ($the_query-&gt;have_posts()) : $the_query-&gt;the_post(); &lt;span&gt;&lt;a href="?p=redeem&amp;post_id=&lt;?php echo $post-&gt;ID; ?&gt;"&gt;Redeem&lt;/a&gt;&lt;/span&gt...
get selected post using $_GET
wordpress
OK I will try to explane my problem better. What I need to do is to create a kind o service for my WordPress. From some external web sites I like to send some data to my main WordPress web site through the URL. Lets say I have the web site http://www.mysite.ext/ On mysite.ext I will install my plugin. Some external web...
It's more of my personal approach than any kind of best practice, but I find WP's Ajax handler to be easy and logical endpoint for such technical URLs.
Plugin with custom domain
wordpress
I'm working on a IP restriction plugin but having a strange problem. I have a textarea in the settings page where each of the IP addresses that should be allowed are entered, one per line. I'm then parsing the IPs into an array like this: <code> $ips = trim($cmm_options['ips']); $ips = array_filter(explode("\n", $ips),...
There are two pieces to this code: 1) Interpreting the list of allowed IPs from a textarea, delimited by newline character, and 2) Checking if a given user's IP is in the allowed list of IPs. Part 1) Parse list of IPs delimited by newline character, and trim whitespace: <code> $_POST['allowed_ips'] = " 67.6.134.102 97....
Test for IP in Array Always Fails on First IP
wordpress
I've created a custom post type called news. On the page that shows all of my news posts i need to have a menu on the left side (sidebar) which shows months, i.e. October 2011, September 2011 and so on. When I click on one of these months i want it to be able to show the posts from that month as sub items in the menu a...
You seem to know WP so I'll just give you the outline ( This recent post from my blog includes the details anyway). The best way to do this would be to use query variables. From the comments, I gather this is what kaiser is saying. The link (for October 2011, say) could point <code> example.com/news/2011/10 </code> You...
Menu that shows months and filters posts to show only posts from that month and shows posts as sub items
wordpress
I have setup my plugin's table to use $wpdb-> prefix but aside from that are there any conventions that you should name them; Maybe <code> $wpdb-&gt;prefix.'plugin_'.$tablename </code> or something. I can't find any documentation and the examples of plugins I have used in the past don't seem to adhere to anything in pa...
I'd say (and that's just my opinion ), that prefixing global available stuff like: functions classes tables ... should always share the same prefix. Aside from making your code more unique &amp; therefore collision save, it helps when searching for plugin code, plus it serves as branding for your plugin too. Adding <co...
Is there a naming convention for database tables created by a plugin?
wordpress
I'm new to PHP and WordPress, and I'm curious: Why is WP-Query capitalized like it is? Is this a PHP naming convention, based on the type of query? Or what? Thanks.
<code> WP_Query </code> is a PHP Class , class names are capitalized, with words separated by underscores, as per the Naming Conventions in WordPress Coding Standards .
Why is WP-Query spelled like it is?
wordpress
After taking a look at <code> global $max_page; </code> and <code> global $numpages; </code> on category-archive pages ( <code> is_archive() || $GLOBALS['wp_query']-&gt;is_archive </code> returning <code> true </code> ), I see the following return values: <code> $numpages </code> : 4 <code> $max_page </code> : 7 What's...
First, let's go through variables one by one: <code> $numpages </code> is set on each <code> setup_postdata() </code> call. It becomes either <code> 1 </code> or number of pages in multipage post. <code> $max_page </code> doesn't seem to be global at all. I don't see it referenced as such in code and from quick test it...
Difference between $numpages & $max_page on archive pages
wordpress
I have a custom query to get the post title, permalink, and featured image. However the Post title is displaying but not in the container I want it in. here is the query <code> &lt;ul class="updatelist"&gt; &lt;?php $portquery = new WP_Query(); $portquery-&gt;query(array('cat' =&gt; 3, 'posts_per_page' =&gt; 2)); while...
The problem is that <code> the_title() </code> itself echoes its value, so you can't use it within an <code> echo </code> unless you set the echo parameter to false: <code> the_title( '', '', false ); </code>
Post Title displaying but not in the wrapped HTML I need
wordpress
Hy all! I have a problem with the Wordpress Dashboard - the Incoming Links are not working. I only get "A feed could not be found at http://blogsearch.google.com/blogsearch_feeds?hl=de&amp;scoring=d&amp;ie=utf-8&amp;num=10&amp;output=rss&amp;partner=wordpress&amp;q=link:http://www.markus-schober.at/ ". I have tried a f...
Click configure and copy the URL (in your case, it sounds like it is: http://blogsearch.google.com/blogsearch_feeds?hl=de&amp;scoring=d&amp;ie=utf-8&amp;num=10&amp;output=rss&amp;partner=wordpress&amp;q=link:http://www.markus-schober.at/ ) Paste the URL into your browser, and you'll notice that it redirects you to http...
Wordpress Dashboard Incoming Links Error
wordpress
I need to make adjustments to a horribly written WP theme that (a custom theme that was written in tables, and bad code). The theme has several custom templates, but pagination wasn't used and get_posts was used in place of query_posts - <code> &lt;?php query_posts('showposts=1'); ?&gt; &lt;?php $posts = get_posts('num...
You can replace the code with something like this <code> &lt;?php global $wp_query; $limit = get_option('posts_per_page'); $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; query_posts(array('posts_per_page'=&gt;$limit,'paged'=&gt;$paged,'category_name'=&gt;'albertsons, carrs, dominicks, genuardis, heb, k...
Wordpress pagination showing same posts on each page
wordpress
I need to check if a page is an archive or not, before my plugin does some URI manipulations. These manipulations only work before <code> wp </code> but if I perform them first and then check <code> is_archive </code> , the check will always return false. How can I check <code> is_archive </code> (or achieve the same e...
This is what I could come up with, within <code> init </code> like you said ! Even if you print the <code> $GLOBALS </code> array, there is no way to check if the current page is an archive, <code> is_archive </code> is also set to blank! But if you check the <code> $_GET </code> array, the <code> q </code> variable co...
Need to check is_archive during init
wordpress
So Im just getting started with Custom Post Types. I'm trying to make a custom post called a Certificate. The thing is, I don't need any of the usual 'editor' boxes or anything that would normally be in a post. All I need is an upload form for a user to upload a file. So I've set up the the Certificate post-type, and I...
Take a look at stackexchange-url ("this answer").
Custom Post Type - Upload Form
wordpress
It's normal that a developer or a shop will spend several hours on each project running the same configuration options (for permalinks, SEO options, user roles, plugins that you always use etc.). I'm coming from Drupal, where installation profiles have allowed me to preconfigure a set of configuration options that I ca...
Not exactly what you are asking for, but very close. There is a concept of 'dropin' plugins that exists primarily to override or add to core functions The dropins will always load. So one ftp's up wordpress including whatever plugin files you want that will create your default environment. These should be in the top le...
Repeatable configuration package
wordpress
I'm trying to figure out how to display a menu that has been created, but without having to assign the menu to a theme location. From what I can tell, you have to assign a menu to a theme menu location and then <code> wp_nav_menu calls </code> a menu from whatever location you want. I don't want to have to assign a men...
<code> wp_nav_menu </code> takes an optional argument called <code> menu </code> , which will fetch any menu by name, slug or ID. If you just want post objects (or anything but the menu HTML), <code> wp_get_nav_menus </code> is the way to go. Otherwise, use <code> wp_nav_menu </code> . If you need it to return the menu...
Menus, but not by theme location
wordpress
I have a WordPress plugin which I've built. This plugin contains a Pro version. When user sign-up for the Pro version, he is getting a unique key.php file which he required to replace in the plugin directory. The problem is when Pro users upgrade to newer versions, the key.php file is deleted and they need to re-upload...
Two possible approaches: File based: Standard procedure for anything that you do not to get overwritten is to use the uploads folder. Then it will not get overwritten by any kind of update. I have several plugins that need to save data in files for one reason or another - cached ics files, customised css snippets. I ha...
How to customize WordPress Plugin installation?
wordpress
When constructing the HTML <code> &lt;title&gt; </code> attribute in a theme, I found there is a convenient hook for modifying wp_title . However, a quick review of themes indicates using this hook is not common practice. In fact, if you look at TwentyEleven, you'll see this in header.php: <code> &lt;title&gt;&lt;?php ...
It's been a while since I've asked this, and I've built several themes in that timeframe. The answer I've come up with is "use the filter". There is no limitation to doing this, and it makes other developers' jobs much easier, as they only need to filter the output (vs. trying to do output buffering). In short, just fi...
Limitations when modifying wp_title with a filter
wordpress
I am trying to set additional "default" categories. I figured by hooking into the <code> wp_insert_post_data </code> filter, I could use <code> $postarr </code> to set the category. It doesn't seem to be working? Can someone offer advice as to how I would go about doing this? <code> add_filter( 'wp_insert_post_data', '...
I think that the best way to set the default category is in the <code> wp-admin </code> : Settings > Writings > Default post Category However, I think you're looking for setting more than one category by default. If you look the documentation of <code> wp_insert_post_data </code> , there isn't any key such as <code> po...
wp_insert_post_data filter to set category
wordpress
I have set up a custom post type and a custom taxonomy for it. I'm using the latest version of Wordpress. I believe I should be using the <code> is_post_type_archive </code> function, but this seems to be is returning false no matter what. The post type I've set up is called <code> articles </code> and the taxonomy is ...
Have you made sure your CPT is using the <code> 'has_archive' =&gt; true, </code> parameter? And try something like; <code> wp_reset_query(); if (is_post_type_archive('articles')){ // do something } </code>
How can I tell if I'm on a custom post type archive page?
wordpress
In many themes I've seen (including TwentyEleven) and in the examples I've found online, when building the <code> functions.php </code> file for a theme all functionality is declared in a global scope. To clarify, this is what a typical functions file looks like: <code> function my_theme_do_foo() { // ... } function my...
Using a class for encapsulation is a very common approach by a number of developers for plugins. I do this, and I do find it cleaner. But for plugins. Themes are more procedural by nature. We don't do it for default WordPress themes because it raises the barrier to entry. The functions are quite simple. Removing action...
Using classes instead of global functions in functions.php
wordpress
So I have a plugin that I've created for the admin are when creating post... and I'd like to supply a widget along with it. I'm trying to figure out the best way to initialize my widget. I'm initializing my plugin like so: <code> function call_menu_per_page_class() { return new MenuPerPage(); } if ( is_admin() ) add_ac...
According to Codex <code> register_widget() </code> should be hooked to <code> widgets_init </code> . Hook into <code> init </code> then and at that point hook further different methods to appropriate hooks later.
WordPress: Create A Widget to Accompany Plugin
wordpress
In one part of my site I am displaying custom field data like this: <code> &lt;?php global $wp_query; $postid = $wp_query-&gt;post-&gt;ID; echo get_post_meta($postid, 'info', true); ?&gt; </code> This works ok but it strips any paragraph breaks out and displays it all as one big block which makes it hard to read. So ho...
this obviously depends on the content of your 'info' custom field; generally, you could try: <code> echo apply_filters('the_content', get_post_meta($postid, 'info', true)); </code>
How to make custom fields respect paragraph breaks
wordpress
When I view a category page in 2010 theme, it shown posts categorized in: the category visible in url child categories of 1. I want to restrict the results to 1. only. Please help.
And this is the indirect way I am using now. If there is any better answer please do share. <code> while ( have_posts() ) { the_post(); $cat = get_query_var('cat'); $categories = wp_get_post_categories(get_the_ID()); if (in_array($cat, $categories)) { ... } } // end loop </code>
Category Archives: Show posts categorized in parent category only
wordpress
I am not getting any headway in this one problem I have a separate homepage from the normal blog page. However the site needs a blog so How do I structure a query that will display something like the default wordpress behavior
Do the following: Create a blank page with the name "Blog" or "News" or whatever you like to call it. Go to Settings -> Reading and select A static page from Front page displays section. Choose your front-page from the Front page dropdown box, and your blog page (the page you created in step 1) from Posts page dropdown...
Best Query for blog posts
wordpress
Working on a plugin for wp-ecommerce publish / unpublish all items in a category seems the cleanest place to implement this is in the categories page as a bulk action - though numerous google searches have turned up very little documentation and a series of posts on bug tracker so: Is it now safe to add a bulk_action-I...
Long story short the answer is NO There is no function currently available to add bulk_actions only remove them
Is the bulk_action hook stable for use in 3.2.X?
wordpress
When user registers to my site I want to make them inactive by default so I can manually update their status and send them their login info. I am using wordpress 3.1.2. Is it possible? Are there any plugins for this? BTW, I am using Cimy User Extra Field plugin to add more fields to the registration page.
<code> /* Plugin Name: Role-less New Users Description: Removes all roles from new registrations. Author: 5ubliminal */ // Hook into the registration process add_action('user_register', function($user_id){ $user = new WP_User($user_id); // Remove all user roles after registration foreach($user-&gt;roles as $role){ $use...
How to make user inactive by default while registering?
wordpress
I would like to render some custom dashboard widget conditionally. If logined user have more than or equal to editor role I would like to render some more widgets than a user with subscriber role. How to do this? Any help please...
<code> // PHP 5.3 syntax - anonymous functions (Closures) add_action('wp_dashboard_setup', function(){ if(current_user_can('activate_plugins')){ // Administrator wp_add_dashboard_widget('dbwidget-Administrator', '#Administrator', function(){ // Print widget here }); }elseif(current_user_can('delete_others_posts')){ // ...
how to render dashboard widgets conditionaly in wordpress admin
wordpress