question
stringlengths
0
34.8k
answer
stringlengths
0
28.3k
title
stringlengths
7
150
forum_tag
stringclasses
12 values
I'm currently working on a plugin, which uses the builtin cron functionality of wordpress. Instead of using PHP4, I want to use PHP5 with inheritance and the singleton design pattern. I run in some limitations with the action & filter hook mechanism and wanted to ask, if you have an other approach for this problem....
You don’t have to declare the constructor public, just the action hook function. Example: <code> &lt;?php /* Plugin Name: Singleton Action */ class Singleton_Demo { /** * @static $instance Objekt * @access private; */ private static $_instance = NULL; protected function __construct() {} private final function __clone()...
PHP5, Inheritance, Singleton - action & filter hook limitations
wordpress
How do I test whether there are any images attached to a post? I'm using the gallery shortcode, but I want to put it in a conditional so the surrounding styling isn't displayed if the gallery is empty.
You can check if an attachment for the given post exists with the get_posts function. This will create a new sql query - so there could be a performance issue. <code> // Util.class.php class Util { public static function has_attachments() { $args = array( 'post_type' => 'attachment', 'numberposts' => -1, 'post_status' ...
How do I test whether [gallery] is empty?
wordpress
I'm trying to get pagination to work, I get the nav tools to show, but when i click to move to the next page it loads the first page every time. Here's the code: <code> &lt;?php $args = array( 'post_type' =&gt; 'page', 'orderby' =&gt; 'title', 'order' =&gt; 'ASC', 'posts_per_page' =&gt; 5, 'paged' =&gt; get_query_var('...
Replace 'page' with 'paged': <code> 'paged' =&gt; get_query_var('paged'), </code>
wp-pagenavi only showing first page
wordpress
What I want to achieve is an online listing catalog with a URL like this: <code> www.example.com/drawing-tools/brand/type/material/color/ </code> In this example, I have a custom post type named "drawing-tools" with 4 custom taxonomies for it: "brand", "type", "material", "color" When a user access a URL like: <code> w...
The solution is fairly simple and I don't know why it took me so long to find it on the Codex. You must make use of the <code> $wp_query </code> class. So, in the template, before calling the loop, set a variable to hold the returned data: <code> $vars = $wp_query-&gt;query_vars; </code> And then, check if the required...
Custom post type taxonomies URL rewrite
wordpress
I'm working with the new custom post type archives in 3.1 and I noticed that when my post type has 0 posts, the archive for the type results in a 404. Looking at the order of hooks being processed, it's redirecting to the 404 template before even processing my archive-{post_type}.php template and reaching the condition...
An FYI for those coming back to this question, this was fixed in 3.2: http://core.trac.wordpress.org/ticket/17316
Custom Post Type Archives with 0 Posts Redirects as 404
wordpress
Is it possible to add a token to any wp-option that could be replaced on get where the token being defined in a plugin’s option or the configure file? <code> E.g. http://[[[env_token]]].sitename.com/some-page.html =&gt; http://staging.sitename.com/some-page.html or http://dev.sitename/some-page.html or http://www.siten...
See the filter reference on the codex. In particular, note that you can use the form <code> option_$foo </code> to filter just a specific option key. So if you wanted a filter specific to the <code> siteurl </code> option, you could do: <code> add_filter( 'option_siteurl', 'my_url_filter' ); </code>
Environment Specific Options Token
wordpress
I dont know how to call it, but can I switch off auto linking in Wordpress? I am creating my 3. theme for client, but I have not manage this problem. For example, if I create a page or post, Wordpress automatically create a permalink on my site, www.mysite.com/posttitle. But if I wanna use this post to display it into ...
You don't have to create a post to hold your data, you can use the Settings API for example you put in your functions.php: <code> $copyright = get_option('my_them_copyright'); if (!isset($copyright)){ $copyright = 'Design by: &lt;a href="domain.com"&gt;ME&lt;/a&gt;'; update_option('my_them_copyright',$copyright); } </c...
Page and post auto links
wordpress
i'm having a problem with wordpress and the post-page: my web has several pages like: news, projects, links each page is displaying posts of the corresponding category. my question: when clicking on a post's detail, it will execute always the same script (post-detail.php). now i want to implement a "back"-link which ju...
You can do that: <code> //add reff to query vars to hold the referring page ID add_filter('query_vars', 'my_query_vars'); function my_query_vars($vars) { // add movies_view to the valid list of variables $new_vars = array('reff'); $vars = $new_vars + $vars; return $vars; } </code> then add <code> ?reff=&lt;?php echo $p...
post-page: reference to parent page?
wordpress
Plugin is defining pluggable <code> wp_mail() </code> function. My idea was to check if function is defined already and throw warning if other plugin beat me to it. However this warning causes issues on activation. As far as I understand during normal operation plugin is loaded before <code> pluggable.php </code> but f...
Don't do the check on activation? Seriously, the best way I can think of is not to check for this on activation, but only in the normal plugin load process. And instead of throwing a warning (I assume you mean a PHP E_WARNING), perhaps putting an admin error box up would make more sense.
Pluggable function and activation check?
wordpress
Does anyone know if it's possible to change wp_link_pages, so that the title of each nextpage quicktag is used rather than numbers? I can't seem to find anything on this. This is an example of how I'm using the quicktag: <code> &lt;!--nextpage--&gt;&lt;!--pagetitle:Overview--&gt; </code> Using <code> wp_link_pages(); <...
This is going to be kind of hackish, but it is possible using an alternate function. Add this to your theme's functions.php file. <code> function wp_link_pages_titled($args = '') { $defaults = array( 'before' =&gt; '&lt;p&gt;' . __('Pages:'), 'after' =&gt; '&lt;/p&gt;', 'link_before' =&gt; '', 'link_after' =&gt; '', 'e...
Custom page-links for paginated posts | wp_link_pages quicktag
wordpress
A Little Background I've been running a blog for 4 years that discusses just about anything I feel like writing. My car, backpacking trips, my church, marketing strategy, WordPress code, movies I see on the weekend, etc. I have also been running a separate blog for a little over a year focused primarily on creative wri...
Your sites look nothing alike. Open those three links - and there is not a single element that binds all three sites together. Network of sites can benefit from consistent looks . You could use global "about" page that covers all of your activity and not just bits in context of specific site. Consider building landing ...
What's the Best Way to Structure a Multi-Content Blog?
wordpress
I was wondering if there is a way to edit the default field labels on a custom post, for example instead of the author field saying "author" have it say "keynote speaker" I found one solution listed below, but this obviously edits it across the entire backend. <code> add_filter( 'gettext', 'change_author_to_keynote' );...
you can use: <code> add_filter('gettext','custom_author_lable'); function custom_author_lable( $input ) { global $post_type; if( is_admin() &amp;&amp; 'your_post_type' == $post_type ) if ('Author' == $input || 'author' == $input) return 'Keynote Speaker'; return $input; } </code> just replace your_post_type.
Custom Post Type and Labels
wordpress
I currently grab an array of user data from a query. I then use a foreach to loop through them and apply styles and divs to output them to the page. This all works great but i would like to paginate the array into the wordpress paged option. So if the user has set the max posts per page to be 10 and the array contains ...
I ended up using this method... http://www.lotsofcode.com/php/php-array-pagination.htm This script will allow you to take an array and paginate across multiple pages. Works good for what i need. Just working on how to number each item in the array across the pages in a descending order...
Wordpress: paginating array using a foreach
wordpress
I am working with the qTranslate plugin to create a multi-lingual website. The plugin does a great job of translation except for on the <code> next_posts_link </code> &amp; <code> previous_posts_link </code> template tags. When a user has selected a different language the URL should change from: http://mysite.com/test/...
Thanks to the helpful tip from @t31os the issue can be fixed with the following code: <code> /*************************************************************** * Function qtranslate_next_previous_fix * Ensure that the URL for next_posts_link &amp; previous_posts_link work with qTranslate *********************************...
Filter the URL of next_posts_link & previous_posts_link
wordpress
i'd like to use excerpts but for some reason the excerpt editor is not visible when editing posts. i'm using wordpress v3.1 - already searched up the options but couldn't find anything .. :( do i need a plugin for using excerpts? shouldn't it be included by default in wordpress? thanks
Do you have the excerpt field enabled in screen options? Screen options is in the top right-hand corner the screen, next to the help button (under the logout link).
excerpt box not visible
wordpress
in this stackexchange-url ("question") i've found how to create a custom tab at the image uploader. this is the code: <code> add_filter('media_upload_tabs', 'my_media_upload_tabs_filter'); function my_media_upload_tabs_filter($tabs) { unset($tabs["type_url"]); unset($tabs['library']); $newtab = array('ell_insert_gmap_t...
So i decided that for me, i can settle for changing an input field on the top.parent for it to be used with the native options. i used this for the function of the iframe tab: <code> function media_upload_choosebackground_form() { media_upload_header(); ?&gt; &lt;h3 class="media-title"&gt;HTML Form&lt;/h3&gt; &lt;img s...
send information from the thickbox image uploader second tab
wordpress
I pretty much got my answer in my last question, but not quite. I was supposed to add one last code to my source and it would have worked but the person helping hasn't replied now and I don't know what to do :S stackexchange-url ("Form to Add Posts to Custom Post Type") So can anybody tell me where to put <code> wp_red...
You need to put the form processing part of the code at the top of the page before anything else and <code> wp_redirect(get_permalink($pid)); exit; </code> Right after <code> $pid = wp_insert_post($new_post); </code>
Form to Add Posts to Custom Post Type (Again)
wordpress
It seems like stupid question. But, I can't figure it out :(. I need to display button at home that goes to custom post_type's archive URL (archive-{post_type}.php). How do I do that?
Hi @Silent: Turns out there is a function in WordPress 3.1 that does exactly what you want and it is named <code> get_post_type_archive_link() </code> ; here's how you'd call it (assuming a custom post type named <code> 'product' </code> ): <code> &lt;a href="&lt;?php echo get_post_type_archive_link('product'); ?&gt;"&...
Get custom post_type's archive URL
wordpress
I am implementing a custom Meta box that allows the user to add images via a simple file input field (based around code on this site: Meta Box Script ). This code allows multiple images to be added as attachments to the page and it does it without the full upload dialogue box, you just select the image file and publish...
even if you had included the all of the needed files you will still have to create your some extra hidden fields like _nonce to pass the <code> check_ajax_referer( "set_post_thumbnail-$post_ID" ); </code> also you would need to create an action hidden field to identify the case of Ajax call with the value : <code> "set...
How can I add the "Use as featured image" to a custom metabox?
wordpress
In my last question, I asked stackexchange-url ("How to build a post and comment editing form in a page?"). But in order to edit the custom post type (called Question) I have to reference the edit page and the ID of the custom post type. I created a file called edit-question.php (located in the theme's folder). And cre...
Regularly You have this: <code> &lt;?php edit_post_link( $link, $before, $after, $id ); ?&gt; </code> In this example use "echo" <code> &lt;?php echo $post-&gt;ID ?&gt;"&gt; </code> Instead: <code> &lt;?php $post-&gt;ID ?&gt;"&gt; </code>
Problem creating an edit link for a custom post type
wordpress
i'd like to list my 10 most recent posts but from certain categories only - anyone can tell me how to do this? thanks
simply add this above your loop <code> $args = array( 'posts_per_page' =&gt; 10, 'category__in' =&gt; array( 2, 6 ), //change and add the category ids here 'orderby' =&gt; 'date', 'order' =&gt; 'ASC') query_posts($args); </code> and you can read more about query_posts Parameters http://codex.wordpress.org/Function_Refe...
query recent posts from several categories
wordpress
Seem to be having a few issues with this project lately so sorry for spamming questions! I needed to give the category edit page in the admin a few additional fields to allow my client to manage them better. The extra fields I added are 'Category Features' and 'Category Applications' and the following code seems to be ...
Sorted this myself! May help some people... <code> $cat = get_query_var('cat'); $prod_extras = get_option(Category_Extras); $this_application = $prod_extras[$cat]['Category_Extras_Applications']; if(!empty($this_application)) { echo $this_application; } </code> Cheers, Dave
Custom Fields to Category edit page, then displaying them in a template correctly
wordpress
I'm having problems setting up a single WordPress template page to display post data outside of the Loop. The page has a left sidebar in which I want to display post meta data, tags and navigation links to previous and next posts, followed by a main column with the post title and content: <code> &lt;html&gt; &lt;head&g...
did you call rewind posts? I've done something similar on a site and used css to solve. The site uses 960 grid (960.gs), which comes packaged with "push" and "pull" classes that let you rearrange content relative to its position in the markup. In our case, the sidebar content is coming from a sidebar template and is ca...
Including post data in a sidebar occurring outside of and before the Loop
wordpress
I am trying to access data from some custom fileds in my MySQL db so that I can add them to a webpage that will be printed out. The data is held in a column called "paypal_user" and I need to access one piece of data and print that along with the user id of the user. I've had a little help with the code but I am stuck ...
For one thing, you don't have to include wp-config or wp-db when you use wp-load. And as t31os says, single-quotes around variables will keep them from being interpreted by PHP. <code> &lt;?php include_once('wp-load.php'); ?&gt; &lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xht...
Call to undefined function get_user_meta() - trying to access data in MySQL from custom fields
wordpress
i'd like to have a small news box in my sidebar - so i need to display just a few lines of text, separated from the actual the_content() - how could i do that? it should be somekind of quicktag which will be hidden in the full post content. thanks
Use this widget: http://wordpress.org/extend/plugins/recent-posts-with-excerpts/
definining own teaser text for post
wordpress
I'm building a WP theme that requires a splash graphic "slider" widget (similar to what you see on cnet.com). I'd like to build one myself, mainly so I can have full control over the bits, but if there are any available with licensing options for inclusion in commercial shipping software, I'd consider those as well. Do...
If you can use a plugin, Take a look at the Smooth Slider plugin. It is very good with the ability to add content and/or photos. You can reorder them, and it allows you to use custom post types, pages or posts. It has a lot of customization and using your owns stylesheet you can style it quite well. You can see two dif...
jQuery slider widget similar to cnet.com
wordpress
Hey there, I have 5 different sites with 5 different IP's on cyberwurx shared account. How can I install wordpress multisite and use the domain mapping plugin and also keep my sites on different IP's? Any ideeas? Ty!
WordPress won't care about the IPs, It's Apache's job to map IPs to your vhosts. You need to look at the Apache config: set up either 5 separate <code> VirtualHost </code> entries that all point to the same <code> DocumentRoot </code> , or tell Apache to listen on all available IPs, and use a wildcard match on a single...
WordPress Multisite domain mapping with different IPs
wordpress
So I have been building a child theme for a site. Wanted to add post formats to a twentyten child theme. Now, the goal of my child theme is to copy over the absolute least amount of code/templates from the parent as possible. I originally figured if I added additional post formats to a twentyten child theme, using a cu...
Try bumping the priority of your hook, like so: <code> add_action( 'after_setup_theme', 'voodoochild_setup', 11 ); </code> This will ensure that it runs after the TwentyTen formats setup, so that it gets the last laugh. That's how I do it on WordPreh.com.
Adding post-formats to Twenty Ten child theme
wordpress
I've used this method to enter the first editor: on functions.php: <code> function add_admin_theme_styles() { wp_enqueue_style('thickbox'); } add_action('admin_print_styles', 'add_admin_theme_styles'); wp_enqueue_script('jquery'); wp_enqueue_script('media-upload'); wp_enqueue_script('thickbox'); wp_enqueue_script('word...
It sure wasn't easy but here it comes. (1)I couldn't get the media button to work in any other way with the editors, while excluding the media buttons from one of the editors, but not from all of them, so i had to use the the_editor(); the JS is conflicting while implementing multi instance of tinyMCE with the_editor()...
two tinyMCE editors in the same page
wordpress
I've been using the Rss widget in my site, and suddenly a few days ago, the admin part stopped responding. That is, I'd change the link to the Rss and it wouldn't get saved (and therefore would show the old Rss in the site). Or I would add another Rss widget, but after I refreshed the admin page, I'd see the widget, bu...
I found that I had to disable 2 plugins: WP-Polls and Search &amp; Replace
Are there plugins that interfere with the admin part of Rss widget?
wordpress
First of all, sorry if I'm making a mistake. I already asked this on the ServerFault forum, but got no answers at the moment and I thought it would be a good idea to ask the question here, considering that it is a WordPress specific question. I have a WordPress site that runs fine, but there's a strange behaviour: one ...
Sounds like your expires headers are set to far in the future. The following rules can be added to your .htaccess Expires rules can be added to your Nginx server file to shorten the expires time down to 180 seconds. <code> location ~* \/[^\/]+\/(feed|\.xml|.html|.HTML)\/? { expires 180; } </code> I would also suggest i...
My WordPress site always displays a cached version of its homepage
wordpress
I have a problem. My database server isn't working right. On a wiki, it gives an error, and on my wordpress site, the pages don't show up. I am wondering if WordPress caches the DB data in any way, and if so, how do I clear it. I am hoping that will either totally break it or clear it. I am able to disable plugins and ...
Thanks all for your input. This may help someone else who has this problem. As for me, the problem has fixed itself (well, not exactly, but it is gone), so it must have been the DB. The wiki is still down, but it says that a table is marked as crashed now.
Site does not work right, pages not showing up, even for root admin
wordpress
In stackexchange-url ("another question") I was talking about using theme options to modify CSS. This is a separate but related question. When a user sets a link colour in my theme, here's how I'm including their choice: <code> &lt;?php $options = get_option('mytheme_theme_options'); _e( 'a, a:link {color: #' ); echo $...
There's no need to be using <code> _e() </code> that's for text that's to be translated, you don't translate CSS, it only comes in one language... With regard to your if/else'ing, try this.. <code> &lt;?php $options = get_option('mytheme_theme_options'); if( isset( $options['linkcolour'] ) &amp;&amp; ( !empty( $options...
Using if/else statements with output from theme options
wordpress
I'm working on a client site and need the following: A custom post type called 'Agreements' On the Agreements edit panel, show a list of "Offices" checkboxes. Users can select multiple Offices per Agreement. Here's the rub. I want the admins to be able to add/edit Offices, which would each have a title, abbreviation an...
Hi @FriendlyWP: I'd recommend you consider creating stackexchange-url ("a Custom Post Type") of <code> 'office' </code> and use one of the following custom post relationship plugins to maintain relationships between Agreements and your Offices: ZigConnect Custom Post Types Relationships Post Type Linking Posts 2 Posts ...
Custom post type / custom fields
wordpress
when attaching eg. files to a post, how can i edit/delete them afterwards? couldn't find anything in the post editor. thanks
Use the Media Uploader. Press Upload Photo above the editor. See the tab "Gallery( number-of-items-attacched )" Manage / Rerrange order To delete: show an item and press Delete (it's at below of the window)
how to edit attachments?
wordpress
I'm setting up a website for a client where they want several different sections, like so: <code> Regular Site (/) - Section 1 (/section_1/) - Section 2 (/section_2/) ... - Section X </code> The regular site will have all of the main content, but I want to be able to override certain pages if they exist in the specifie...
I managed to solve the problem. Here's how to do it, in case anyone else ever needs this solution. ** Updated Mar 10 3:30am EST ** The previous function that I had here was displaying the page properly, but was returning a 404 error code. I've replaced the bad code example with a working one that does not return a 404....
If a page does not exist, include a different page?
wordpress
I'm using the_post_thumbnail(); (aka featured image) to show a news source logo. If I use that image, I'd like to output the name of the news source. For example: if the_post_thumbnail is "new-york-times.jpg" echo "New York Times" elseif the_post_thumbnail is "cbs-news.jpg" echo "CBS News" etc... Any help writing this ...
If You need title from media use something like this: <code> &lt;?php $thumb = get_post(get_post_thumbnail_id()); echo $thumb-&gt;post_title; </code>
If the_post_thumbnail(); is this - echo this text
wordpress
How do I 301 redirect private pages, rather than 404 them? If a post is private, WordPress filters it out in the SQL query, so there are no $post variables to work with. I'd like for this code to work, but doesn't: <code> add_action('wp','redirect_stuffs', 0); function redirect_stuffs(){ global $post; if ( $post-&gt;po...
Sorry guys, I found my answer: <code> add_action('wp','redirect_stuffs', 0); function redirect_stuffs(){ global $wpdb; if ($wpdb-&gt;last_result[0]-&gt;post_status == "private" &amp;&amp; !is_admin() ): wp_redirect( home_url(), 301 ); exit(); endif; } </code> Posts/Pages are removed from the sitemaps, but the page stil...
How to 301 private posts rather than 404?
wordpress
How can I get the slug of a page or post?
Inside of your loop you can do: <code> global $post; echo $post-> post_name; </code>
How can I get page slug
wordpress
Is it possible to customize how my gallery shortcode works. eg. have a div for showing the image then a list of thumbnails at the bottom or side? Or perhaps I can create a custom template file to loop through my page's gallery images?
You may complete override your gallery shortcode using the filter <code> post_gallery </code> . The return is displayed in your page and no further processing of the shortcode is done. You may iterarate through the image attached to your post to build your own gallery. See the implementation of gallery shortcode here: ...
Is it possible to customize the layout of Gallery Shortcode?
wordpress
This plugin enables you to submit a custom post type called 'Questions' using a form that can be embeded in a page via shortcode. Is there a way of accomplishing the same, but this time, building a form and embedding it on a page to edit this custom post type and comments? (it doesn't have to be a shortcode). Reference...
To edit is a bit harder then just creating, but not that hard first you only display the edit link to the author so you add something like this to your loop: <code> global $current_user; get_currentuserinfo(); while (have_posts()) : the_post(); //regular loop stuff //and check if the post author is the current user if ...
How to build a post and comment editing form in a page?
wordpress
I am trying to get an array of site users sorted by a custom meta value (an int). I can query the users just fine and get them back to use in a foreach. I currently have the query results come back sorted already by display_name from the users table. I want it to sort by the custom usermeta value. Any ideas on how to m...
You won't get a proper sort on the <code> meta_value </code> column because the values stored there aren't treated as integer values, but you can use a method similar to how it was done it WordPress back when we were using <code> meta_value_num </code> to do sorting, which basically involved adding a number onto the fr...
mysql query two database tables, users and usermeta and sort by custom meta int value
wordpress
I have a network of sites and have recently added another site. When I upload an image it uploads to the correct directory but is showing a broken image link when viewed within the library or on the site. I checked the site's setting and everything looks correct. file actually uploads to blogs.dir\7\files\2011\03\1551-...
Looks like I needed <code> &lt;rule name="WordPress Rule 1" stopProcessing="true"&gt; &lt;match url="^index\.php$" ignoreCase="false" /&gt; &lt;action type="None" /&gt; &lt;/rule&gt; &lt;rule name="WordPress Rule 2" stopProcessing="true"&gt; &lt;match url="^([_0-9a-zA-Z-]+/)?files/(.+)" ignoreCase="false" /&gt; &lt;act...
Uploaded images not displaying in network site
wordpress
I'm working with a church that uses WordPress to manage their website and podcast. So far, they have a 200-step process every week for publishing the podcast (I exaggerate, but it is a huge step-by-step list). Among other things, they have to: Record the sermon Master the sermon recording Create an MP3 Upload the MP3 v...
70-80MB is really not that large. Easily handled by the Flash uploader if your server is properly configured. Hell, I have a 2 gigabyte upload limit on my site. :) When they're writing the new "post", they just click the add media button above the toolbar and upload it. It gets saved as an attachment that's tied to the...
Large Uploads in WordPress
wordpress
Well I made a plugin that uses <code> template_redirect </code> for the custom post type <code> squeezepages </code> and it works all fine and dandy, but I copied the exact same code, put it in a new plugin, activated it (with a few minor adjustments, for example I changed the custom post type to <code> newpages </code...
I solved my own problem. I needed to put <code> flush_rewrite_rules( false ); </code> after my <code> register_post_type </code> function. The reason it wasn't working is because it was returning the page with a 404 error, so I figured out it was a permalinks problem and the code above solved it for me.
template_redirect not working, apparently for no reason
wordpress
Basically, I need a plugin that let you edit posts and comments the same way you do in StackExchange sites (questions and replies)? Because by default Wordpress sends you to the back-end.
Yes, try the Front-end Editor by Scribu!
Is there a plugin that let you edit Posts and Comments in a front-end page?
wordpress
One section of my website is going to be completely different visually than the rest of the pages, is there a way to apply a WP Theme to specific page templates ?
In fact there is, using <code> template_redirect </code> , which you would put in the functions.php file - Here's what I use: <code> function uniquename_default_template() { if(get_post_type() == 'posttype') : /* You could use is_single() instead of get_post_type() == '' or any type of conditional tag) */ include(TEMPL...
Can I apply a WP theme to a specific custom page template?
wordpress
This is a shortcode to add a question form in the Question and Answer Forum plugin for Wordpress: <code> [question_form width='x' bordercolor='x' style='x']question form title[/question_form] </code> This short code calls this: <code> //allow short codes [question_form] function question_form($atts,$content = "") { glo...
I think you're looking for the <code> do_shortcode() </code> function. It allows you to paste a shortcode directly into a template file. http://codex.wordpress.org/Function_Reference/do_shortcode
Shortcode doesn't work if I directly paste its function in a template file?
wordpress
problem: Only some blogs did not show the dashboard (but did show all other admin pages). I have left this problem for some time (months) since Googling did not bring up anything relevant and I was too lazy to investigate (and could work around it by logging in, getting a 500 error and then press back and click comment...
The transient is in place just fine, see <code> get_dir_size() </code> source . Note that if you have enough files for this to cause major performance issues you are probably better disabling upload limit or it might mess up other related functionality like uploads.
How to solve 500 Error on WordPress Admin Dashboard due to time-out on getdirsize
wordpress
We would like users to be able to upload the post thumbnail when editing posts. How would this be done. I would imagine it would make use of the ajax functions of wordpress. Any ideas, Marvellous
Uploading files in ajax is a bit tricky because it is not possible to upload files using the browser's XMLHttpRequest object so you need to use some kind of Ajax upload plugin and the easiest one would be the the JQuery Form Plugin which makes things much easier and it's included in WordPress. So to use it you need to ...
Upload post thumbnail from the front end
wordpress
I need the following: two different 1-5 star rating fields, for one of my custom content types. The ratigs will be stablished by the admin, so I dont need a real voting system. The fields are more like indicators than polls. I tried gd-star ratings but its aimed at community voting and rating systems which is not at al...
Take a look at Easy Review Builder for WordPress Review Ratings they both work as shortcode.
I need to have two 1-5 star rating fields, only editable by admins. Which plugin should I use?
wordpress
I am having trouble with multiple loops and sticky posts in wordpress. The first loop I just want all the sticky posts. <code> &lt;?php query_posts(array('post__in'=&gt;get_option('sticky_posts'), 'cat' =&gt; '-15,-17, -5, -2')) ?&gt; &lt;?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?&gt; &lt;?php $d...
your problem is that in the first loop you overwrite <code> $do_not_duplicate </code> for each post in the loop so at the end you only have the id of the last post. if you change $do_not_duplicate into an array then you can add each post to the array: <code> //before the loop $do_not_duplicate = array(); //in the loop ...
Multiple loops with / without sticky posts and different post limits
wordpress
Can someone explain what a subpage is in wordpress? Does it look any different from a regular page? What is its purpose and what does it do? Thank you
The only difference between a page and a subpage is that a subpage contains it's parent in the URL, as will any pages that sit as children to the child page... For illustration. Regular page: example.com/a-page/ Subpage: example.com/a-page/a-child-page/ Sub Subpage: example.com/a-page/a-child-page/another-child/ and so...
What is a subpage in WordPress?
wordpress
A recent upgrade to wordpress 3.1 broke a custom plugin written to make use of shortcode in order to generate easy embed html for brightcove videos. Can anyone see what is happening in the following code that is incompatible with 3.1, and what needs to happen for it to be fixed? It was working fine in 3.0 prior to upgr...
You didn't add the shortcode via the shortcode API. WordPress only recognizes shortcodes if they are added with: <code> add_shortcode( 'yourshortcode', 'yourshortcodefunc' ); </code> I personally would not use preg_replace for this because it is more of a hit and miss. You should follow the official guidelines off the ...
Custom Shortcode Broken in Wordpress 3.1
wordpress
I'm using the following code to get ONLY posts with the post_type question and the current user who is logged in. But if no use is logged in all the posts are displayed anyways. Any suggestions? Code: <code> &lt;?php global $current_user; ?&gt; &lt;?php get_currentuserinfo(); ?&gt; &lt;?php echo 'Username: ' . $current...
The variable is not valorize: <code> $current_user-&gt;ID </code> is <code> 0 </code> , so the query extracts all post, try to give it a non existent integer value Try to substitute <code> $current_user-&gt;ID </code> with <code> ($current_user-&gt;ID==0) : -1 ? $current_user-&gt;ID </code> It assign -1 to the author, ...
Showing only posts from the current user who is logged in?
wordpress
I have a custom query and I am filtering out events by custom field: event-month. I simple filter our the events that dont have a month_number = to date("n"); Its a pretty great little query, but I need to orderby another custom field, event_date. Do I need a custom function or something to get this done. I simply want...
Despite <code> meta_key </code> being deprecated, it is still required to get the orderby to work correctly. First and foremost though, there's an error with your code, and that's in using <code> order_by </code> and not <code> orderby </code> (there's no underscore in the orderby arg). Give this a shot and see how it ...
can I orderby one custom field and meta_query another in the same query
wordpress
I'm trying to exclude a category because I have a post that i have in multiple post. How do I like for example I have a post in the categories lastest news and pictures but I want to exclude latest news and show only the pictures name. I tried using $category = get_the_category(); echo $category[0]-> cat_name; but that...
actually I fingered it out this code worked. <code> &lt;?php //edit below for categories you want excluded $exclude = array("Latest News", "Uncategorized"); //how do you want the list separated? just a space is okay $separator = " | "; //don't edit below here! $new_the_category = ''; foreach((get_the_category()) as $ca...
Exclude a category name using cat name
wordpress
I've managed to add a custom tab to the media uploader, but for some reason it doesn't come with the same layout - it doesn't load the media-uploader-header that contain all the other tabs: <code> add_filter('media_upload_tabs', 'my_media_upload_tabs_filter'); function my_media_upload_tabs_filter($tabs) { unset($tabs["...
found it. in the automattic SVN for media.php i found the media_upload_header() function, and the only thing left to do is to echo it in the last function: <code> function media_upload_ell_gmap_form() { echo media_upload_header(); ?&gt; &lt;h2&gt;HTML Form&lt;/h2&gt; &lt;?php } </code> that's it.
custom tabs in media uploader
wordpress
Here's my very simple shortcode: <code> function box_shortcode( $atts, $content = null ) { extract( shortcode_atts( array( 'width' =&gt; 'auto', 'height' =&gt; 'auto', ), $atts ) ); return '&lt;div class="boxy-box" style="width:'. $width .'; height:'. $height .';" &gt;'.do_shortcode($content).'&lt;/div&gt;'; } add_shor...
You can postpone the wp_autop filter. Wordpress has this filter enabled by default. And it is processing before the shortcode output. <code> remove_filter( 'the_content', 'wpautop' ); add_filter( 'the_content', 'wpautop' , 12); </code> Add this to your <code> functions.php </code> and check if the problem persist! See ...
Automatically added brs and paragraphs?
wordpress
I include this logic in my template all the time <code> if (have_posts()): //show content else: //show content not found endif; </code> But recently i began to doubt its necessarity, wordpress will turn to 404.php when no post found, it seems no need to add this logic in normal templates, "else" will never be triggered...
When I look at <code> WP::handle_404() </code> , I think that the <code> 404.php </code> template will not be loaded, even if there are no posts, if: We are on the homepage It is a search It is a taxonomy term that exists, but has no posts attached to it (and it's not paged) It is an author that exists, which has writt...
Do we still need to include a "if (have_posts())" in templates?
wordpress
Is it possible to have a multisite wide post type without duplicating the posts? That is a post type that is the same no matter what blog you are on? Theoretical example: StackExchange has many sites (blogs) but wants their site-wide news post type, I'll call it <code> sitewide_news </code> , to be the same on every bl...
I've been using this plugin , which works really, really well.
Multisite wide post type?
wordpress
i know stackexchange-url ("similar") stackexchange-url ("questions") have been asked before, but the answer's to them don't quite satisfy my needs, so i'm re-iterating the question: I'm looking for a modern Event Management plugin with the following criteria: simple, WP-like UI (Event Calendar 3 is excellent in that re...
Unfortunately, there's really nothing out there that's going to solve all of your problems out of the box. Whatever calender solution you choose will require some amount of customization. The one that I've found fills most needs is The Events Calendar . It's not perfect, but it's a lot better than many other events cal...
The holy grail of Event Management Plugins?
wordpress
OK, I'm using posts_query() to display posts. The problem is, at least in my case, posts_query() always outputs something. For example: <code> &lt;?php $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; query_posts("posts_per_page=1&amp;paged=$paged"); global $more; $more = 0; while ( have_posts() ) : the_...
query_posts() ALWAYS displays something? No it doesn't at least not for me, i've tried the code you posted inside my child theme and was unable to reproduce the issue described. Firstly, i tried... <code> while ( have_posts() ) : the_post(); ?&gt; &lt;!--- DO NOTHING ! --&gt; &lt;?php endwhile ?&gt; </code> ..and got n...
query_posts() ALWAYS displays something?
wordpress
I just imported a blog from blogger to wordpress recently. The blog consisted of about 3500 tags in total. On importing them into wordpress, they were converted to categories for some reason. I have installed and the categories to converter plugin by wordpress that allows you to convert them to tags. On the converter p...
You can always perform the transformation at the database level (field taxonomy in wp_term_taxonomy classifies a taxonomy term in a category or tag )
Wordpress “Categories to tag converter” not working on imported Blogger posts
wordpress
I've scoured the Codex, failed to get get_page_by_title() to work and am quite surprised that there doesn't seem to be a standard WP function for this task. I need to get the ID of any given post/ cpt or page using either the slug of the post/ page title. Ideally I'm looking for the following: <code> get_post_ID_by_tit...
you can use this function that jumps by google "get post by title" <code> /** * Retrieve a post given its title. * * @uses $wpdb * * @param string $post_title Page title * @param string $post_type post type ('post','page','any custom type') * @param string $output Optional. Output type. OBJECT, ARRAY_N, or ARRAY_A. * @...
How do I get a post (page or CPT) ID from a title or slug?
wordpress
What is theme-editor.tmp? It is located under wp-content.
.tmp-files are temporarly files created by incomplete Wordpress- or plugin actions. These files appear also in general computing. In this case, they are often created during plugin updates that are performed from the Wordpress backend (wp-admin). If the plugin upgrade fails for some reason, or termitated by the user, t...
What is theme-editor.tmp?
wordpress
Basically I want to display a form on my blog (on a certain page) that will allow anyone to fill it out and it will create a post in a custom post type. I saw the answer once before but I can't find it now.
posting from the front-end is a matter of displaying a form and processing it: form: <code> &lt;!-- New Post Form --&gt; &lt;div id="postbox"&gt; &lt;form id="new_post" name="new_post" method="post" action=""&gt; &lt;!-- post name --&gt; &lt;p&gt;&lt;label for="title"&gt;Title&lt;/label&gt;&lt;br /&gt; &lt;input type="...
Form to Add Posts to Custom Post Type
wordpress
question is simple (i don't know is aswer too ;) I just want to check that, does a category has child (or is ancestor) from its cat-id with a function. Eg. <code> function check_category ($catid){ ............ ...//true if is ancestor, false if not return $result; } </code> Note: I can only pass cat-id parameter for fu...
You can do something like this: <code> function category_has_parent($catid){ $category = get_category($catid); if ($category-&gt;category_parent &gt; 0){ return true; } return false; } </code> and use it like this: <code> if (category_has_parent('22')){ //true there is a parent category }else{ //false this category has...
Check is category parent or not from its ID
wordpress
I'm building a website that will only have one post type called Work. This post type will need a field as well. Should I just use the default post type (post) and use custom fields or hide the default post type and create a brand new one called Work? If the former, is there a way to change "Post" to "Work" in the dashb...
There is no need to create a new post type and remove the regular post, just rename post to work, <code> add_filter('gettext','rename_post_to_work'); function rename_post_to_work( $input ) { if( is_admin() &amp;&amp; 'post' == $input || 'Post' == $post_type ) return 'Work'; return $input; } </code>
custom post type - use default or create new?
wordpress
I would like to let the user edit their comments using TinyMCE. Is there any way of doing this?
I've used this plugin before: Tiny MCE for Comments . The plugin page says it's only been updated to WP 2.8.4, so not sure if it's working for more recent versions. Try it and see!
How to add TinyMCE to a front-end textarea?
wordpress
I am trying to use the wordpress menu setup and have a working horizontal menu with a drop down submenu. Unfortunately the sub enu is quite long so I wanted to split it into columns I can do it if I hardcode the menu into header.php but that means I have to add new items rather than letting the client do it. This is a ...
I think it would be easier for you if you'd stick with the old menu output and used css to emulate your submenu columns. You can left-float the elements in your submenu (while giving them an appropriate with - e.g. 33% for 3 columns), which sorts them horizontally rather than vertically, but otherwise will give you a c...
nav-menu-template and columns in sub menu
wordpress
Struggling with this code, the conditions work, the only way I can get the wp_get_attachment_url is to loop through it but then this outputs as many images from the media library and I only want one? <code> &lt;div class="tvimage"&gt; &lt;?php if ($imgurlbase != '' ) { ?&gt; &lt;img src="&lt;?php bloginfo('template_url...
If you want to exit the loop after you find an attachment, use <code> break </code> . <code> // Define $programme and pull up $attachments as above $attachment_url = ''; foreach ( $attachments as $attachment ) { if ($attachment-&gt;post_title == $programme) { $attachment_url = wp_get_attachment_url($attachment-&gt;ID);...
Get an image from the media library. Struggling with the code?
wordpress
I recently moved my WordPress-based site from DreamHost VPS to a Linode VPS running Debian + LEMP. After getting the site up again, I noticed many erroneous characters in posts; characters like " and - were being replaced with gibberish. After doing some looking, it seemed clear that the issue was something related to ...
After spending the entire day working on this, I finally found a guide that worked perfectly: http://www.blogsuccessjournal.com/blog-tips-and-advice/wordpress-tips-advice/seeing-weird-characters-on-blog-how-to-fix-wordpress-character-encoding-latin1-to-utf8/ Before that, I tried following @Rarst's information, tried ex...
Character encoding issue after changing servers
wordpress
I've asked a question about listing all sub-pages before: stackexchange-url ("Listing all sub-pages?") But all the questions were wrong. Anyways, I have now simpler question. <code> global $post; echo $post&gt;ID </code> Works totally fine, but while on pages sidebars only. When it's next to the blog loop (in a blog se...
If i understand correctly you are trying to display a list of child pages of a page in a widget, if so then first check if you are on a page using the conditional tag <code> is_page() </code> then you can use $wp_query-> get_queried_object_id() like t31os has pointed out so your widget display function should look like...
$post> ID displays wrong post ID
wordpress
I'd like to optionally replace some RSS item titles with a headline meta field I've added to certain post types. I have the post types showing up in the feed using: <code> function myfeed_request($qv) { if (isset($qv['feed']) &amp;&amp; !isset($qv['post_type'])) $qv['post_type'] = array('post', 'interviews', 'reviews')...
Something like this (not tested): <code> add_filter('the_title_rss', 'custom_feed_title'); function custom_feed_title($title) { $headline = get_post_meta(get_the_id(), 'headline', true); if (!empty($headline)) return $headline; return $title; } </code>
How can I modify RSS item titles to be either the title or a custom meta field?
wordpress
Just playing around with adding "custom menu" support to my theme. I'm super excited about it. HOWEVER, Check this out > <code> &lt;ul id="menu-my-main-menu" class="menu"&gt; &lt;li id="menu-item-12" class="menu-item menu-item-type-custom menu-item-object-custom current-menu-item current_page_item menu-item-home menu-i...
You can use the <code> nav_menu_css_class </code> filter to remove the classes that you want from your menu-item. See the example below, to remove ALL the CSS classes that are appended to you menu items: <code> add_filter('nav_menu_css_class','remove_nav_menu_classes'); function remove_nav_menu_classes($classes) { retu...
How to remove class attributes from custom menu markup?
wordpress
<code> add_action() </code> and <code> add_filter() </code> are major functions. However in some scenarios add one more function and hook it somewhere approach gets bulky and inconvenient. I had determined for myself several use cases that can streamline code with wrappers on top of <code> add_* </code> functions. Thin...
I had released my code as Advanced Hooks API plugin in official repository. View source in trac . Some examples: <code> add_action_with_arguments('test', 'printf', 10, 'boo%s', '&lt;br /&gt;'); do_action('test'); // boo add_filter_return('test2',10,'boo'); echo apply_filters('test2','not boo') . '&lt;br /&gt;'; // boo ...
Implementing advanced add_* function wrappers
wordpress
I generated a new MetaBox for all standard posts in WordPress 3.1. There I generate a input:text field with the ID <code> _meta_fotos[pic] </code> , which should hould the image url generated by the standard media-uploader. I want to use the standard media-uploader from the standard post window. So I generated the foll...
I hate it to answer my own question. But after hours of searching and trying I found a solution that works. I offer this solution, because it can't be interesting for others having the same problem. And for discussion, if there is a better way to get rid of the problem. Perhaps it is not very elegant, but it works ;-) ...
How to get the image-URL from Media-Upload in a post?
wordpress
Is it possible to sort pages in the loop using the admin's order field (under page attributes)?
Yes, use the <code> orderby </code> clause in your query posts. <code> query_posts( array('orderby'=&gt;'menu_order' ) ); </code> See: http://codex.wordpress.org/Function_Reference/WP_Query#Order_.26_Orderby_Parameters for reference
Sort pages in loop by admin's page attributes order field?
wordpress
So I just updated a site to 3.1 that uses several custom post types. When I had made the site I had not noticed at the time the <code> $post_type </code> parameter for <code> register_post_type </code> has to be in all lowercase letters! ( it was not well written in the codex but now it is bold ). http://codex.wordpres...
To avoid this from happening simply add <code> flush_rewrite_rules( false ); </code> after your register_post_type function. you can read about it more here http://en.bainternet.info/2011/custom-post-type-getting-404-on-permalinks
Custom post type permalinks breaking due to 3.1 bug fix
wordpress
I'm trying to change the permalinks to my attachments in the same way as stackexchange-url ("this question"), and the given solution works great except for one problem: if the permalinks settings on my site contain %category%, the solution doesn't work at all and I get a "This page isn't redirecting properly" error. Th...
It seems like what I want is something that WordPress's internal permalink code isn't prepared to deal with. After reading this writeup by Otto , I've come to understand that having my permalinks start with %category% could create a performance issue down the road and I would have to create a function that further alte...
How do I rewrite attachment urls when permalink structure contains %category%?
wordpress
I have a query_posts call in a WP template. Through the use of the More Fields Plugin I can give the site admin the ability to create an event (custom post type) and then enter a date which is formatted: YYYY/mm/dd. The main question is; what value should I pass to the value option in the meta_query array? I am current...
I wound up going with the following. I setup a event-momth field and comparing from there. thanks for the help <code> &lt;?php $event_query = new WP_Query( array( 'post_type' =&gt; 'event', // only query events 'meta_key' =&gt; 'event-month', // load up the event_date meta 'order_by' =&gt; 'event_date', 'order' =&gt; '...
what is the correct way to compare dates in a WP query_posts meta_query
wordpress
I'm currently running this query to get pages (not posts) from the site section: <code> query_posts("post_type=page&amp;post_parent=6"); </code> I'd like to remove one page, 271, from this query. Based on stackexchange-url ("this stack") I tried: <code> query_posts("p=-271&amp;post_type=page&amp;post_parent=6"); </code...
Update: You must use exclude the page using <code> post__not_in </code> paremeter. Rewrite your query using the array parameters <code> query_posts(array( 'post__not_in'=&gt;array('271'), 'post_parent'=&gt;6, 'post_type'=&gt;'page' ) ); </code> See this page for reference.
WordPress: query pages except remove one page
wordpress
I would like to apply layout templates to my posts, just like I can do with pages. For example, I have a template-wide.php that does not include sidebars and adds a special "wide" class to the content div. At present, I can only use this template for pages. Is it possible to make it available to posts as well?
Use the Custom Post Template Plugin .
Possible to add "Template" selector to posts?
wordpress
I need to add pamarameters to URLs that are read by javascript widgest/gadgets run on the site. Whenever I just add them e.g. the original URL is <code> http://example.com/blog/page/ </code> and the parameter is called foo with a value called bar . The new URL becomes: <code> http://example.com/blog/page/?foo=bar </cod...
I found the answer to my question. There is no need register query vars for this but instead to take care to not use some of the core query vars as this will break things. In my case it was the year query variable which caused the 404.
How to add URL-Parameter for Javascript Widgets?
wordpress
This question is following on from a question I stackexchange-url ("posted previously"), Ok, the html code that I'm trying to output is the same as the previous question - stackexchange-url ("here"): The current outputted html is this: <code> &lt;div id="nav"&gt; &lt;ul id="drop-nav"&gt; &lt;li&gt;&lt;a href="#"&gt;Abo...
See my Answer to your other question...i think you're better off with a custom walker. Edit: I should perhaps mention explicitly here that i tried writing a walker for you, so check out the other question to find it.
Select first child/subpage item in wp list pages
wordpress
Im putting together a portfolio site and have come across something that i would like to implement, but im unsure of how i can set around doing it. Basically as the site stands now (in development) the user never has (or will have) to access wp-admin to change any of their details, they can do that via a user-profile p...
http://wordpress.org/extend/plugins/role-scoper/ This plugin is great for fine tuned control of content. I have not, however, tried what you are requesting. So I can only suggest it as something to look into.... I'm not sure if it gives such fine tuned control over comments....
Users moderate own comments
wordpress
Here is the WMD Editor implementation for Wordpress . When the users writes a post everything is displayed OK: The problem is when the user clicks EDIT: The HTML version is the one displayed (I think it is a normal behaviour since WMD Editor turned the Markdown version of the post into HTML). What are the steps to fix ...
that is the normal way for it to work, when you save it turns the markdown text to html, so when you edit you need to reverse the html back to markdown text. there is an outdated plugin that has most of the functions you need it http://wordpress.org/extend/plugins/markdown-for-wordpress-and-bbpress/ that would be a goo...
Problem enabling the user to edit Markdown and displaying the HTML output (WMD Editor plugin for Wordpress)
wordpress
i am trying to make a little referral sort of system for my site. so for that i settuped an extra parameter in the registeration url as : www.domain.com/wp-login.php?action=register <code> &amp;register_me=site_name </code> and one is adding ip address while registeration, at first i thought it would be a simple form i...
I've recently written an affiliate plugin where i had to do pretty much the same stuff. Here's a chopup of the relevant parts: To process the extra info you get from the registration form: <code> add_action('user_register', 'my_handle_signup', 10, 2); function my_handle_signup($user_id, $data = null) { $reg_ip = $_REQU...
Adding extra info via GET while registeration in wordpress
wordpress
My sidebar widget code in functions.php looks like this... <code> if ( function_exists('register_sidebar') ) register_sidebar(array( 'name' =&gt; 'Home Sidebar', 'id' =&gt; 'home-sidebar-widget', 'before_widget' =&gt; '&lt;div class="menu side %2$s"&gt;', 'after_widget' =&gt; '&lt;/div&gt;', 'before_title' =&gt; '&lt;h...
There doesn't seem to be an easy way to do this. However, you can try this rather hackish approach: <code> add_filter('dynamic_sidebar_params', 'my_sidebar_params_cb'); function my_sidebar_params_cb($params) { global $my_widget_counter; if (empty($my_widget_counter)) $my_widget_counter = 1; else $my_widget_counter++; $...
How can I add an incremental class identifier to my sidebar widgets?
wordpress
I am running some of the WP functions directly inside a plugin, including wp_insert_post(), if something goes wrong, this returns a WP Error object, what is the correct method to catch this error? Either using built in WP functions or PHP exceptions or whatnot..
Assign return of the function to the variable. Check the variable with <code> is_wp_error() </code> . If <code> true </code> handle accordingly, for example <code> trigger_error() </code> with message from <code> WP_Error-&gt;get_error_message() </code> method. If <code> false </code> - proceed as usual. Example from C...
How to catch/what to do with a WP Error Object
wordpress
I have another PHP application in a folder named <code> app </code> inside my Wordpress installation, and I need to disable all Wordpress rewrite rules for that folder and it's content. So that when I go to <code> www.domain.com/app </code> I get my application page, instead of the standard Wordpress 404 page. I know t...
The default .htaccess-file will already support the behaviour you want; <code> # BEGIN WordPress &lt;IfModule mod_rewrite.c&gt; RewriteEngine On RewriteBase / RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] &lt;/IfModule&gt; # END WordP...
htaccess disable Wordpress rewrite rules for folder and its contents
wordpress
I post my codes from different programing languages. Now, I want to highlight syntax of codes with different colors. But, doing it manually is time consuming. Is there any plugin or method which could do this automatically? Strictly, it should be done in CSS way.
There's a whole bunch of plugins that do that. After some reading i decided to go with Syntax Highlighter Evolved .
How to automatically highlight syntax of code in a post?
wordpress
I coded a wordpress shortcode for columns that basically inserts html via a shortcode. Problem is that wpautop adds stray p elements that renders the code invalid. To test put this into your functions.php: <code> function static_col_container($atts, $content) { extract(shortcode_atts(array( 'foo' =&gt; 'bar' ), $atts))...
Remove the filter from the the_content and run it after the shortcode are processed. Try: <code> remove_filter( 'the_content', 'wpautop' ); add_filter( 'the_content', 'wpautop' , 12); </code> Usually shortcodes are processed after wpautop is applied to the content. See http://core.trac.wordpress.org/browser/tags/3.1/wp...
stray elements
wordpress
I put up a quick splash page with <code> index.php </code> and added a link in that splash page to index2.php and when I go to <code> index2.php </code> , I get a "page not found" error. Getting rid of the splash is not an option right now. Is there anything I can do to get this to work?
Try to just use a index.html file and use <code> &lt;META HTTP-EQUIV="Refresh" CONTENT="5; URL=http://example.com/wp-content/themes/your_theme/index.php"&gt; </code> in your <code> &lt;head&gt; </code> section. Let's see if the easy stuff works. edit: to be on the save side, always display a link to the index.php file ...
index2.php in root causing 404 error
wordpress
I'd like to display content from a custom meta box that appears for a particular custom post type in the sidebar, when a single post of that type is being displayed. I know how to normally display that content in the post content area, but I'm assuming that using that same code in a widget won't work, since the sidebar...
Well, you could access the <code> $post </code> variable with <code> global $post </code> and then access it's meta values with <code> get_post_meta($post-&gt;ID) </code> or something close to that. If you just want that to be accessed when you are viewing a single post, you can use <code> if(is_singular('my_custom_pos...
Is there a way to display content from a post meta box in the sidebar?
wordpress
Is it possible to only display the author's name and description (aka bio) if the description contains text? This code doesn't work (it doesn't return the name or description) but hopefully it can be edited to accomplish this goal: <code> &lt;?php $authorDesc = the_author_meta($post-&gt;ID, 'description', true); if (!e...
<code> &lt;?php $authordesc = get_the_author_meta( 'description' ); if ( ! empty ( $authordesc ) ) { ?&gt; &lt;a href="&lt;?php echo get_author_posts_url( get_the_author_meta( 'id' ) ); ?&gt;"&gt;&lt;?php the_author(); ?&gt;&lt;/a&gt; &lt;?php echo wpautop( $authordesc ); } </code>
Output author and description if description is not empty
wordpress
I have two groups of talented designers that I am trying to nudge away from doing Dreamweaver sites — AKA static pages that are based on "templates" — and toward WordPress. In both cases I have encountered what I can only describe as fear. This fear seems to be based on (a) a concern that they won't be able to "cut it"...
Why not just ask them to estimate how much it will cost to change the layout for 600+ pages. And then ask them if they think their customer will pay for that, versus a designer using Wordpress. One important thing to point out is that Dreamweaver is a tool on your computer for creating the design. Wordpress is a CMS fo...
How do you present WordPress to a designer who is afraid?
wordpress
I've searched and found posts that have asked and answered how to merge different categories into an RSS feed. What I need to know is how to exclude specific categories from the RSS feed? Specifically, I use WP to post blog articles and to post portfolio items onto my site. I want to exclude the portfolio category from...
It's been broken since 3.1, see: http://core.trac.wordpress.org/ticket/16622 and also http://wordpress.org/support/topic/wp-31-breaks-rss-customization-via-exclude_category NOTE: Otto's suggested fix in that thread doesn't work for me. Ticket suggests patch will go in for 3.1.1 and i can confirm that currently filters ...
How Can You Exclude Categories From Your RSS Feeds?
wordpress
One of my posts has the following content: <code> This is a test post. Nothing more, nothing less. Three lines before the jump &lt;!--more--&gt; And a couple of more lines after the jump. </code> Note : these were written as you see them, in the WP editor, using the HTML tab - so we have no hidden <code> &lt;br&gt; </c...
the_content() and the_excerpt(), unlike their 'get_' brothers will process the content through some functions, one of them is wpautop() that will add p tags for you. To get the same formatting for both excerpt and content: <code> if ( has_excerpt() ) { the_excerpt(); } else { the_content(__('Read more')); } </code>
Excerpt vs content formatting woes
wordpress