question
stringlengths
0
34.8k
answer
stringlengths
0
28.3k
title
stringlengths
7
150
forum_tag
stringclasses
12 values
I'm building a theme that is going to show excerpts on the homepage for potentially dozens of posts. I don't have manual excerpts on all of my posts, so <code> $post-&gt;post_excerpt </code> is empty for many posts. In the event that there isn't a manual excerpt, I would like to use the built-in get_the_excerpt() funct...
<code> wp_trim_excerpt() </code> has a little curious mechanics - if anything is passed to it then it does nothing. Here is basic logic behind it: <code> get_the_excerpt() </code> checks for manual excerpt; <code> wp_trim_excerpt() </code> chimes in if there is no manual excerpt and makes one from content or teaser. Bo...
Using wp_trim_excerpt to get the_excerpt() outside the loop
wordpress
I'm creating a theme that would need some settings on the client side. So I need a admin interface where they can set some values. (like, source of image, title, or numbers) so in my theme, I can just set some variables like <code> &lt;img src="IMAGE_SOURCE" title="TITLE" size="NUMBER" /&gt; </code> If you can point me...
The newest and most complete tutorial to the settings API can be found here . I'd suggest to take a look there. I used a pretty similar way myself. Sidenote: You should really mark some answer a solution. "0% acceptance rate" will people hold back from answering your Qs anymore.
how do you create an admin interface in plugin for your theme
wordpress
I'm not sure if this is the right place to ask this but last night i made a post on my wordpress powered blog here: http://blog.twostepmedia.co.uk/css3-still-novelty-or-usable-in-everyday-web-development/ then this morning i see this: http://buzzgamesnews.blogspot.com/2011/01/css3-still-novelty-or-usable-in.html Is thi...
Yes, they can. There is nothing strange or technically complex about that. And before you ask - no, it's pretty much unrealistic to protect public web page from being copied. My process to deal with such goes roughly like this: Contact blog owner and point out that your posts are not meant to be copied and that is not ...
Wordpress blog post cloned and stolen?
wordpress
I'm writing a plugin called 'Featured Releases' for a client. The user fills out a short form in the admin area which inserts some text and an image id into the wordpress database via $wpdb-> insert. On my development machine it works fine, but on the production server (which has over 500 posts of all sorts, mostly ima...
Great advice Rarst! The output of $wpdb-> queries was exactly what it should be: <code> "INSERT INTO `wp_featured_releases` (`fr_band`,`fr_album`,`fr_album_description`,`fr_image_id`,`fr_shop_url`,`fr_modified`) VALUES ('','','','504','','2011-01-14 10:49:58pm')" </code> 504 is the correct id for the image, but the val...
$wpdb-> insert is changing a value
wordpress
How do I limit the query by two custom meta fields, a start date and an end date? This is what my data looks like: meta_key | meta_value | ------------------------| start_date | 20100131 | //Jan 15, 2010 end_date | 20100206 | //Feb 6, 2010 ------------------------' $today = date(YYYYMMDD); The post will show if <code> ...
Edited again to demonstrate adding and removing filters: Include these general functions in your functions.php . These are the filters you will invoke for the loops where you want to limit your query by these two meta values: <code> function date_check_join( $join ) { global $wpdb; $join .= " JOIN ".$wpdb-&gt;postmeta....
Query between two meta values?
wordpress
Okay I posted a question yesterday, that can be found stackexchange-url ("here"). I've found some code on the wonderful internet that I think is really the ticket for me, but I don't know how to develop into what I really need. Here is the breakdown - I need three separate vote links. I need to change the word "Vote" o...
Here's a simple solution. Append the ratings to the end of the post content: <code> add_filter('the_content', 'add_ratings_to_content', 4); // remove ratings from excerpts add_filter('get_the_excerpt', create_function('', 'remove_filter("the_content", "add_ratings_to_content", 6); return;'), 5); function add_ratings_to...
WP 3-way voting system: On to something! Please help!
wordpress
I've been looking into using the Wordpress Repository for one of my larger plugins, the problem is that it's using a lot of third party software. Video players/Slide scripts/Jquery includes, some of which are commercial in nature. My question is related to the content that differs from the GPL v2. Id like to include th...
License Compatibility As a recent commenter pointed out on my site , it should be possible to distribute a plug-in that's not GPL so long as you don't distribute it with WordPress. However, the guys at WP.org have pointed out time and again that only GPL-compatible plug-ins must be compatible with version 2 of the GPL ...
Possibility of including third party software/plugins in the Wordpress repository
wordpress
(Please note I'm NOT asking about wordpress.org but about wordpress.com ) I just posted a new entry but my current theme has a fixed width which makes my post become buggy and surely myself and the readers won't like it very much! So, I'm looking for another theme that has the content width maximized. If you know ones,...
.com had recently got much improved catalog of themes with search, filtering and other nifties. See all themes with flexible width template . If nothing fits there is paid option to allow CSS customization.
Need a theme that let the posted content stretched maximum width
wordpress
I download and configure Wordpress for a development environment and a production environment. After it's set up on one server we check it into a subversion repo and then go and check it out on the production server. Deployment complete. The trouble is when I have to update. I'm supposed to delete wp-includes and wp-ad...
Externals, definitely. Set up your own SVN repo, then make WP as an external in the repo. I put it into a /wp directory. You can access the WP SVN as an external here: http://core.svn.wordpress.org/ I tend to use trunk. You can use a branch, if you really, really want. Branches get auto updated with minor releases (/br...
Managing updates when Wordpress is in your own svn repo
wordpress
I'm using a function to display all files attached to a post and listing them as links. The result is something like this: <code> echo '&lt;a href="' . wp_get_attachment_url($attachmentImage-&gt;ID) . '" class="dir-attachment" /&gt;' . wp_get_attachment_url($attachmentImage-&gt;ID) . '&lt;/a&gt;'; </code> As expected, ...
Try this: <code> basename(get_post_meta( $attachmentImage-&gt;ID, '_wp_attached_file', true)); </code>
Strip the folder path away from wp_get_attachment_url to show filename only
wordpress
How can I make a similar posts section in my theme, but without using a plugin. I'm going to be giving my theme away for free, so I don't want to have to force people to install plugins to use my theme. How can it be done?
Put this in your single.php: <code> $tags = wp_get_post_tags($post-> ID); if ($tags) { $first_tag = $tags[0]-> term_id; $args=array( 'tag__in' => array($first_tag), 'post__not_in' => array($post-> ID), 'showposts'=> 4, 'caller_get_posts'=> 1 ); $my_query = new WP_Query($args); if( $my_query-> have_posts() ) { while ($m...
Similar Posts - NO plugin
wordpress
I found a way to export my posts in text form so that I can move them to a blog with static pages. The only problem is that there are no paragraph tags, so every post is a huge block of text. I had been using line breaks and relying on wpauto to add paragraph tags automatically. Is there any way to add those tags into ...
a quick and dirty way to do this is by running this ONCE: <code> global $post; $posts = new WP_Query(); $posts-&gt;query(array('posts_per_page' =&gt; -1, 'post_type' =&gt; 'post')); while ($posts-&gt;have_posts()): $posts-&gt;the_post(); $post-&gt;post_content = wpautop($post-&gt;post_content); // replaces new line cha...
How do I add paragraph tags to all of my posts after relying on wpauto?
wordpress
I had asked a question earlier, on stackexchange-url ("getting post-thumbnails from another WP-site"). There, the awesome stackexchange-url ("Mike") coded a SQL query whose results are then passes on to a PHP array. The piece of code from that answer that I want to modify is this. <code> $post_urls = $wpdb-&gt;get_col(...
Calling <code> image_resize() </code> would be difficult, since it would search for the image in your main blog's upload directory. If it is a fixed image size I would just add it to the configuration of your photoblog, so it is created there when you upload new images (you can then stackexchange-url ("rebuild your old...
Styling images coming from another blog
wordpress
I've basically done a full plugin and now just "prettifying" it sort-of. One thing I'm doing is re-doing the columns for listing the "posts" I made. This part is fine, and all columns are replaced as needed, however, there's one column that puzzles me.. the title field. :/ <code> add_action( 'manage_posts_custom_column...
I did a slight hack for this to work. I added a hidden field named "post_title" as if I'm enabling Title support, though without actually having the ugly title bar positioned. <code> &lt;div id="titlewrap"&gt; &lt;input type="hidden" name="post_title" size="30" tabindex="1" value="" id="title" autocomplete="off" /&gt; ...
Custom Post Type, Custom Columns List
wordpress
I've done this with posts, but I can't find the proper way to reference the category table's columns. I'm trying to add a column titled "Image" to the table, so that when the table grid of categories is displayed, if there is a category image assigned to the category, it will appear in the grid. The first step for me i...
The filter is <code> manage_{$screen-&gt;id}_columns </code> , and <code> $screen-&gt;id </code> is <code> edit-category </code> , giving you <code> manage_edit-category_columns </code> . I found this by placing a <code> var_dump() </code> in <code> get_column_headers() </code> , which is called by <code> print_column_...
How can I add a custom column to the "Manage Categories" table?
wordpress
I'm questioning how i can get rid of the post-editor (visual + html). I tried to not register post type support, and it still appears (de-registering works fine with every other default meta box on post edit screen). I also tried to deregister it with remove_meta_box, which didn't work too (works for everything else ex...
Giving a blank array to 'supports' in the declaration of the post type should get rid of the editor and the title, along with every other default box in the edit post page. <code> $supports = array (''); $args = array( 'label' =&gt; 'people', 'supports' =&gt; $supports, 'hierarchical' =&gt; false, 'public' =&gt; true, ...
Custom Post Types: How-to get rid of editor (-meta box)
wordpress
I've currently been creating my Git repositories at the root level for each of my WordPress installations. Git of course then notices any core updates, plugins, and uploads. I'm considering just tracking the theme I'm working on or perhaps the entire themes directory. I'd like to hear from other WordPress developers as...
If I'm working on whole project for a client (WP install + custom theme + plugins), I put everything in one repository. My thinking is that I created one "solution" based on WP + some existing plugins + my added code, and thus I should track it as one solution. When WP or a plugin is updated I need to test it on a dev ...
Is it better to create a Git repository at the root level or in the WordPress theme directory?
wordpress
I have an excel spreadsheet that needs to get on a WP site PDQ and IE is choking on it. I tried making an html table, but it's huge. I looked into some kind a database plugin that would let me import a cvs and then let users browse it, but I can't even figure out the right search terms. I would appreciate any input. Th...
If you're using Google Docs, then this plugin Google Spreadsheet Viewer might be helpful.
I have a 1300 line excel spreadsheet that needs to get into a wordpress site ASAP - Looking for ideas
wordpress
I am inserting an image in a post and I want it to point to the post detail page, not the attachment. What should I do? Thanks in advance.
I think I understand what you want, and the problem you are having. I don't have code, but can point you toward some useful resources. I'm not sure how you are inserting an image into your excerpts on the homepage. My guess is that you are using the More tag in the post editor, inserted after the first paragraph + pict...
Make insterted image point to post url instead of attachment page
wordpress
I have a Theme Options page where the user can add certain options like Facebook links, etc. One of the options is for some ad code and when saving it as an option it gets escaped over and over again. What's the best approach for saving code inserted in an admin page <code> &lt;textarea&gt; </code> using <code> update_...
<code> stripslashes(wp_filter_post_kses(addslashes($_POST['sidebar_code']))); </code> but you should know that the kses filter is not 100% safe.
How to prevent escaping when saving HTML code in an option value?
wordpress
I got some problems during my loading priority/order that i already discovered. Now i ran into the problem that i can't use any post_thumbnail functions (get_post_thumbnail_id, has_post_thumbnail, the_post_thumbnail): "Call to undefined function"... Does anyone know at which point these functions are loaded? I would be...
These are included in <code> wp-settings.php </code> right after <code> after_setup_theme </code> hook and so should be available starting with <code> init </code> hook. Also check if you have <code> add_theme_support( 'post-thumbnails' ); </code> declared in your theme, otherwise these functions won't be included at a...
On what point (hook) does the_/has_post_thumbnail() load?
wordpress
I have this simple snippet to retrieve the categories (taxonomies) of my Custom Post Type 'portfolio' I need to display each taxonomy but it displays all the categories. I just saw this question stackexchange-url ("Filter get_categories() for taxonomy term in WordPress") and unfortunately I tried with no success. <code...
First, you are mixing up terminology a bit. Portfolio is <code> taxonomy </code> , but Work, Images, etc are <code> terms </code> (not <code> categories </code> ). So you need to adjust functions for your taxonomy. Try this: Replace: <code> $catid = get_cat_id('Images'); </code> Becomes: <code> $catid = get_term_by( 'n...
Filter get_cat_id for Custom Post Type
wordpress
I'm writing a plugin for work (still) and having one more issue. I've added my meta boxes as needed. However, the problem I'm having occurs when saving the post. My snippets for saving pretty much come from stackexchange-url ("this post"). I've also recieved a similar answer stackexchange-url ("here"), but it's just no...
I really like your clean class structure :-) But I have a suggestion that might fix things (based on my experience with nonces and meta boxes from a plug-in I built last weekend): Don't try to create the nonce field manually. You currently have: <code> $nonce = wp_create_nonce( plugin_basename( __FILE__ ) ); ... &lt;in...
Updating post meta for custom post types
wordpress
In the code snippet below, I trying to get the_excerpt to be written out without tags. However, the source formatting shows that the_excerpt is always wrapped in P tags. How can I pull the excerpt without tags? <code> foreach($myrecentposts as $idxrecent=&gt;$post) { ?&gt; &lt;li class="page_item"&gt; &lt;a href="&lt;?...
in your code above use <code> get_the_excerpt() </code> instead of <code> the_excerpt() </code> , because the last one will output the excerpt to the screen, and not pass it to your other functions...
How to echo the_excerpt without the P tag wrapper?
wordpress
In the code below represents a link list of recent posts. I'm just trying to write out the post name, along with the post excerpt if one exists. So I'm using the get_link_excerpt($post) function in order to determine if the current post in the for loop has an excerpt. It works fine if the post has an excerpt, however, ...
I got it working. Here's what I had to do in my utility function... <code> function get_link_excerpt(){ if(has_excerpt()){ $LinkExcerpt = strip_tags(substr(get_the_excerpt(), 0, 75 )); return ": ".$LinkExcerpt."..."; } return false; } </code>
get_the_excerpt() is not returning an empty string when the_excerpt is blank?
wordpress
I have been coding a custom profile page for users in wordpress. its a hard coded file called "myprofile.php" I am unable to get the username to show up in the page title.. take a look : http://www.designzzz.com/user/ayazmalik/ k i tried a few filters to add title to this page but didn't helped me :( . lets say the use...
<code> function my_doc_title($title, $separator){ if(is_author()) // &lt;- replace this with your custom page; maybe is_page_template('myprofile.php') ? $title = get_the_author_meta('display_name', get_query_var('author')).$separator.get_bloginfo('name'); return $title; } add_filter('wp_title', 'my_doc_title', 10, 2); ...
Adding page Title in a custom coded page
wordpress
I've got a custom php file that I want to call every time someone publishes a new post. How would I go about doing that? Can I write it into the functions.php of my theme?
<code> add_action('publish_post', 'call_my_php_file'); function call_my_php_file($post_id){ require_once("path/to/file.php"); } </code>
How would I got about calling a php file every time someone publishes a new post?
wordpress
In my WordPress plugin I have a php file that generates some stats about the blog and outputs it as a simple text file. To access WordPress functions I've included this at the top of the file: <code> define('WP_USE_THEMES', false); require(dirname(__FILE__) . '/../../../wp-blog-header.php'); </code> Now I'd like to hid...
Mark, I hate to say it, but you're going about this the wrong way. PHP files in your plug-in should never be accessed directly in this way. Instead, they should be loaded from within WordPress just like everything else. Here are some alternative paths you could take: Create an admin page that displays your stats This i...
Making a plugin file accessible via url rewrite?
wordpress
How can I add three menus to the Thesis theme ? I want a menu above the header image, one below the header image and one in the footer. A neat step by step instruction stackexchange-url ("like this for Twenty Ten") would be like the coolest answer.
A neat step by step instruction like this for Twenty Ten would be like the coolest answer. You can follow those instruction starting at Step 3 as your working with WordPress after all. I'm sure Themeatic has some sort of snazzy hook but you will have to ask them.
Creating Multiple Menus in the Thesis Theme?
wordpress
I have a custom post type created for a directory that will end up being sorted alphabetically. I will be sorting the posts in alphabetical order by title, so I want to make sure that the Title is entered as last name/first name. Is there a way to change that default help text -- "Enter Title Here" -- in my custom post...
There is no way to customize that string explicitly. But it is passed through translation function and so is easy to filter. Try something like this (don't forget to change to your post type): <code> add_filter('gettext','custom_enter_title'); function custom_enter_title( $input ) { global $post_type; if( is_admin() &a...
Change "Enter Title Here" help text on a custom post type
wordpress
Is it possible to make a meta box that attaches multiple images to a post?
That depends entirely on what you mean by "attach." Each WordPress post can already have multiple media attachments - photos, documents, etc. You upload these using the built-in uploader and they'll all be marked as "attached" to that specific post ID. You can refer to these later programatically elsewhere. For example...
Creating a metabox to upload multiple images
wordpress
I believe I could do this with either get_categories() or wp_list_categories() and passing a 'child_of' parameter, for example, but that would return a much larger dataset than I need. Is there a direct call that returns the child ids for any category as a simple list (1,2,3,5, etc)?
Try this: <code> get_terms( 'category', "child_of=$parent&amp;fields=ids" ); // should return an array containing the ID's of children of term $parent </code>
How to get a list of child ids for a named category?
wordpress
Is there any way at all to restrict direct access to files within a specific folder to only specific wordpress users that have that specific capability set?
The easiest php solution would be to make a download script. It checks if the user has the right permissions and serves the file to the webclient. Or my preference setup a folder outside your web root and put the files there. Set the file permissions with no anonymous access and let the webserver read them and output t...
Restricting access to files within a specific folder
wordpress
The built-in ability to restore revisions of posts and pages in Wordpress is great. Is there something that gives the same power to template files in the theme-editor? Perhaps a plugin?
Templates are only stored as files in the file system. They are not stored in the database so there is no core functionality for versioning template files. When you make changes, the file is overwritten with the changes. The easiest route would be to use an existing version control solution (SVN,CVS,Git,Hg, etc.) and m...
Best way to version control WordPress template files?
wordpress
My category descriptions are extremely long, so I don't want the descriptions to be used in the title attribute of my category lists. However, WP does this automatically when it outputs the default category widget in the markup. Is it possible to add a filter in functions.php that assigns the default value for 'use_des...
I was finally able to figure this out. Much easier than I thought... <code> function my_categories_filter($cat_args){ $cat_args['title_li'] = ''; $cat_args['exclude_tree'] = 1; $cat_args['exclude'] = 1; $cat_args['use_desc_for_title'] = 0; return $cat_args; } add_filter('widget_categories_args', 'my_categories_filter',...
How to add 'use_desc_for_title = 0' to all wp_list_categories calls?
wordpress
I'm using this plugin (http://wordpress.org/extend/plugins/wp-downloadmanager/) as my download manager. While it's very simplistic and does great for what i need, the statistics to output on the site lack a little. The only useful function really is: Display Most downloaded (of all time). While i do use this, it would ...
Simple answer: No. Complex answer: After looking at the plugin's source code , the downloads table used to store the stats is not structured such that you could just edit this single query to give you that kind of information. It would take a much more extensive rewrite of the plugin to handle your request. Possible Wo...
WP-DownloadManager - Query most download per week/month etc
wordpress
I'm successfully using the function below to trim the length of my category descriptions when viewing the manage category screen (thanks Rarst). Suppose I want to remove children of the "uncategorized" category from this listing. Would I simply insert a check in the for loop below to skip over those child items? UPDATE...
Yes, <code> $terms </code> contains all terms that are retrieved from database for display so whatever changes you make will cascade upwards to interface. One issue I am not sure about if that will affect pagination of results in this case.
How to filter manage categories listing
wordpress
The "manage categories" screen has two interfaces, one when you first click on "Categories" which is used to add a new category and another once you click on an existing category to edit it. I've added some custom fields to the Category editor, but I only want them to be present on the edit screen, not the "add" screen...
You can target <code> edit-tags.php </code> page and additionally check for that <code> edit </code> action. <code> add_action( 'admin_head-edit-tags.php', 'my_category_edit' ); function my_category_edit() { global $action, $taxonomy; if( 'edit' != $action || 'category' != $taxonomy ) return; // code goes here } </code...
How to conditionally include a custom field on category editor screen not category "add" screen
wordpress
I've added a "Custom Title" field to the Category editor in order to capture a keyword friendly title that can be used separately from the category name. It works great, but it appears as the last input element of the category screen. Ideally, I would like it to sit under the "Name" field (or at the very top). Is this ...
Hi @Scott B: WordPress doesn't provide the hooks you want but it you are willing to use PHP's output buffering and <code> preg_replace() </code> you can get it to work without hacking core. Here's an answer that talks about the general technique required: <a href="stackexchange-url Removing Unnecessary Text from Admin ...
How to alter the order of custom form fields
wordpress
I have tried changing the template of the attached page and changing which page is attached as the home page, no effect for either. The front page remains the same. I am at my wits end with this one!!
What is your setup for front page in <code> Settings &gt; Reading </code> ? Do you have <code> front-page.php </code> template in your theme? It will pretty much override anything, no matter what you choose in settings.
front page won't change templates
wordpress
Wordpress has a Text Widget (at least the theme I'm using does, and I think they all do?) In this widget I can add text or HTML. If I add HTML I can include JavaScript. This works fine (I'm hosting my own site). I want to add some text to the Widget using a script. However; document.write("Whatever") writes the text on...
Where are you using <code> document.write </code> ? Inside the text widget? If so, it should write text inside that widget, just like you want. <code> document.write </code> injects data where it's encountered. So if you're using it outside the document body it will produce unexpected results (like overwrite the docume...
Add text to Text Widget using Javascript
wordpress
I use the following function in order to retrieve tags of a post, remove an element from the array and then set the result to the post: <code> $post_tags = wp_get_post_terms( $post_id ); foreach ( $post_tags as $key =&gt; $tag) { $tag_string = http_build_query( $tag ); if( 0 != strpos( $tag_string , 'tag-to-be-deleted'...
Your code looks little clunky, <code> http_build_query() </code> is definitely not meant for such. Also what you are fetching is not simple array, but array of tag objects. My take: <code> $post_tags = wp_get_post_terms( $post_id, 'post_tag', array( 'fields'=&gt;'names' ) ); $pos = array_search( 'tag-to-be-deleted', $p...
Problem with removing post tags programmatically
wordpress
This is a similar question to stackexchange-url ("Sorting for each custom taxonomy"), but I don't feel like it was clearly asked or responded to. I have a custom post type "player" and a custom taxonomy "player_details". The player details consists of things like Height, Weight, Country, Jersey #, etc. I want to add a ...
This doesn't seems to be natively possible, even with upcoming improvements in WP 3.1. [...] That’s not what taxonomies are for. Taxonomies are for grouping, not for ordering by. If you want to order by something, it has to be something in the post itself, not a term in a taxo. Otto For this kind of data custom fields ...
Sorting the Loop by Taxonomy Value
wordpress
I am creating a post and would like to link to other post on my blog. What is the best way to do this? I don't want to hard link in case I update the post title. Is there a way to do this?
Use the ugly link instead of the pretty link. For example, if your post id is 123, you can link to http://www.yoursite.com/?p=123 . This will automatically get rewritten to your current pretty permalink. If you do it relative from the root, it also keeps the link intact if you change your domain name. (ex. href="/?p=12...
How to link to local post
wordpress
For a custom post type page I'd like to completely remove the slug so that the URL structure mirrors http://my-domain.com/CPT-title/ or http://my-domain.com/CPT-category/CPT-title . If I set the rewrite parameter to <code> 'rewrite' =&gt; array('slug' =&gt; '', 'with_front' =&gt; false) </code> Wordpress freaks out and...
You have to set 'slug' to false and not a blank string.
How do you remove slug altogether from custom post type?
wordpress
I'm running a multi-author wp site and I'm looking for a plugin that adds a "Follow me" button near the author name so the user can follow his favourite author. I need also to display the other users that are are following the author (i.e. "38 people are following Author_name -> click to view users). I know there is bu...
Hi @Andy: Are you up for developing something in PHP and jQuery? It should't be too hard to add a button that would do an AJAX submit to add How many total followers do you except anyone to have on your site. If the number is less than 1000 you might get away with just storing a comma separated list of <code> user_id <...
Twitter-like follow system, is there any plugin?
wordpress
I hope somebody would be kind enough to help. I currently have a page that orders all of the posts by comment count, but I want to change the loop to order the posts by view count. I have installed the 'wp-postviews.1.50' plugin and have got it to display the number of views on each post, so I know that side of it is w...
Just wanted to give an update. Someone was kind enough to show me how to update the code I posted above. It turned out to be quite simple (if you know what you're doing!). So I have posted it below for anyone that wants to do something similar. <code> &lt;?php $posts_per_page = get_query_var('posts_per_page'); ?&gt; &l...
How to Change Loop to Order Posts by Views (using wp-postviews plugin)
wordpress
I've tried disabling WP's auto-paragraph thingy using <code> remove_filter ('the_content', 'wpautop'); </code> but I am still getting my stuff wrapped in automatic <code> &lt;p&gt; </code> tags... What am I doing wrong? Its at the bottom of a functions file. Its not in functions.php, but in a file that functions.php in...
http://wordpress.org/extend/plugins/noautop/ I made this a while back, you can just install it and use it, or dig into the code (its a super small plugin) and see how I do it. The plugin adds the tag the_content_noautop(); which you can use in your template specifically when you don't need a paragraph tag.
Remove_filter ('the_content', 'wpautop') is not working
wordpress
I'm not looking for a sitemap, I'm looking to create an xml file that I can have a flash menu access, but I don't want to generate the XML file each time someone visits a page, I want to have a static XML to refer to for speed. And I'd like to have wordpress update the file whenever new content is posted(not comments)....
Hmm... not sure if there are any WordPress-specific functions for creating files. There's wp_handle_upload, but I'm not sure how you'd use it in this context. Depending on your server configuration, you can probably just use fopen and fwrite to do this. Keep the code you're currently using (with your custom loops...I'm...
Make wordpress generate a custom XML file(not a sitemap) that is updated only when new content is posted?
wordpress
When a site gets to a certain scale, storing categories on a per-blog basis starts to get a little messy. Assuming someone would want all WPMU blogs to share a single set of categories, how might one go about that? My gut it so store a set of "cannonical" categories in the root blog. Is there a more elegant or standard...
A more elegant solution would be to create a MU (must use) plug-in and drop it on the network. This plug-in would check (per-site) if the categories exist and, if not, add them as appropriate. Here's some untested example code: <code> &lt;?php $default_categories = array( 'my_first_cat', 'my_second_cat', 'my_third_cat'...
Can you have a single set of "canonical" categories shared by all blogs?
wordpress
my self-made admin panel works just fine, but it doesn't save values of form inputs. When I type something into textbox and click "save" it is still there after refreshing, thanks to PHP: <code> &lt;input type="text" name="header" value="&lt;?php echo get_option('header'); ?&gt;" /&gt; </code> So the PHP echoes its own...
This is really just an html question, not specific to WordPress. Look into <code> checked="checked" </code> (for check boxes) or <code> selected="selected" </code> (for selects, radio buttons, etc.) In your case, <code> &lt;input type="checkbox" name="showS" value="true" &lt;?php if (get_option('showS')==true) echo 'ch...
Saving checkbox/option list status?
wordpress
i need to display under every article in the main page, the respective number of post views. I tried with a plugin called wp.postviews but I cant figure out how it's works...it allow only the widget component. What I have to do to get the postviews? I think I have to use the plugin above and add some extra php code on ...
<code> if(function_exists('the_views')) the_views(); </code>
get postviews under every posts in the main page
wordpress
I think this must be a simple question, despite the seemingly broad title. My wordpress theme by default displays several social icons. (You can see them here , in the upper right corner.) I'm trying to add a new icon to the existing ones. I've already generated and uploaded a new image, modified all the css and php fi...
As @Ambitious Amoeba indicated above, what I was looking for was hardcoded in the footer template.
How does WP generate html?
wordpress
I have my permalink set to <code> %postname%/%location%/%course% </code> I want this permalink <code> %location%/%course%/%postname% </code> but due to this I get 404 on every page but not on posts, I decided to put this permalink <code> %postname%/%location%/%course%/%postname% </code> but I need to strip the starting...
Apologies that this doesn't directly answer your question but If I were you I would use the following structure: <code> /%post_id%/%location%/%course%/%postname% </code> Using the id should help to speed up the page load as it reduces the amount of processing that WP needs to do to select the correct page and you still...
htaccess strip url
wordpress
A custom shortcode i made is being forced to the top of the widget outside of the widget container. Any ideas why? This is my code... <code> function nktmediaplayer_func($atts) { extract(shortcode_atts(array( 'id' =&gt; rand(1, 900), 'language' =&gt; 'en', 'playlist' =&gt; 'no', 'media' =&gt; '3381', 'height' =&gt; '48...
For shortcodes you have to return the output for it to be written out where the shortcode appears. Either turn your HTML into a PHP string rather than breaking out of the PHP tags or you can use PHPs output buffering methods like so: <code> ob_start(); ?&gt; &lt;div id="player_&lt;?php echo $id; ?&gt;" class="video_pla...
Custom shortcode in widget forced to top of widget
wordpress
I am looking for a way to test if a post is a custom post type. For example, in say the sidebar I can put code like this: <code> if( is_single()) { //code here } </code> I want code were I could do this, only testing for a custom post type. Any help would be greatly appreciated!
Here you are: <code> get_post_type() </code> and then <code> if ( 'book' == get_post_type() ) ... </code> as per Conditional Tags > A Post Type in Codex.
If is custom post type
wordpress
I am using the PhotoSmash plugin to let users upload their own images and vote on them, and it works great. On one of my pages I use the following code to list the posts that have a certain category: <code> &lt;?php if (is_page() ) { $category = get_post_meta($posts[0]-&gt;ID, 'category', true); } if ($category) { $cat...
There is no need to juggle <code> $wp_query </code> object, store it in temp, etc. It is rarely good idea to directly mess with important global variables, unless you absolutely need to. You can just create your own arbitrary variable and init it with new <code> WP_query </code> <code> $some_variable = new WP_Query($ar...
Why doesn't PhotoSmash plugin play well with wp_query?
wordpress
I have Win7 32-bit Professional and I want to start learning to program and skin WordPress. My hosts will likely be LAMP, so I was going to run Win versions of those tools locally. Should I just get a linux VM, or will I be able to transfer what I do from the Win environment to the *nix hosting?
I'd recommend setting up XAMPP . It will allow you to run an Apache/PHP/MySQL environment on Windows. You shouldn't have any problem moving things over from your local XAMPP setup to a LAMP setup with your host.
Win7 Dev Environment
wordpress
I have a self-hosted Wordpress Blog (located at http://www.dougmolineux.com/wp if you're interesed :) I put a lot of Code Snippets on there, because I'm a programmer. How do I make these "snippets" code friendly? Right now, I am using a simple Blockquote around each one and it converts all single and double apostrophes...
Geshi In general the Geshi library is a popular library for formatting code ( http://qbnz.com/highlighter/ ) Geshi as a WordPress plugin For WordPress several authors "packaged" Geshi in a plugin. take your pick: http://wordpress.org/extend/plugins/search.php?q=geshi The one I use Personally I use this plugin: http://w...
Code Friendly Block Quotes
wordpress
I'm trying to add a new tab to my groups on BuddyPress. All the groups will have different content preferrably from the database. How can I accomplish this?
There's an example of this on the buddypress forums which is a good place to start looking for answers. http://buddypress.org/community/groups/creating-extending/forum/topic/can-someone-explain-how-to-add-tabs-to-the-profile-page/ For the sake of answering here though here goes: <code> bp_core_new_subnav_item( array( '...
BuddyPress: Adding a new tab in groups
wordpress
I have a custom taxonomy "Portfolio Categories", and a few these categories say "Cloth", "Shoes", ... When open some category page, i want the title to be like 'Site Name | Cloth', but with wp_title(), it becomes 'Site Name | Portfolio Categories | Cloth' How do i remove the "Portfolio Categories" from the title?
Hi @Edward: This is not a generic solution but will probably solve your needs. If you want to get rid of the <code> '| Portfolio Categories' </code> from your site's title just hook the <code> 'wp_title' </code> filter in your theme's <code> functions.php </code> file and remove that from the title string. Copy this co...
How to remove parent taxonomy name from the title generated by wp_title()?
wordpress
hey hii everyone, i have a function to fetch the videos from the rss feed of youtube, so that i can display selected videos to my blog for that i am using this youtube-search-feed url <code> http://gdata.youtube.com/feeds/base/videos?q=eminem&amp;client=ytapi-youtube-search&amp;v=2 </code> in the url, eminem is include...
Don't know if this is your only issue, but you're using <code> the_title() </code> to build your URI. This ECHOS the title, which is not what you want. Instead, you should be using get_the_title() . I'd also urlencode the title, as Jan suggested. Your best bet is to print out the YouTube URI after you build it, then tr...
feed url problem
wordpress
Is it possible to set configuration options such as DEBUG mode only for specific sub blogs in a wordpress multisite installation? If so, how?
Hi @Raj Sekharan: If I understand your question lets say you have three (3) subdomains on your multisite and you only want to debug the first? http://foo.example.com http://bar.example.com http://baz.example.com If yes then it's a simply matter of adding the following to your <code> /wp-config.php </code> file: <code> ...
How to set configuration options for particular sub blogs?
wordpress
I'd like this function to only return on certain pages. How might i do that? <code> // Retreats Accordion function retreats_accordion() { ?&gt; &lt;!-- accordion root --&gt; &lt;div id="accordion"&gt; &lt;?php global $post; $c = 0; $class = ''; $args = array( 'posts_per_page' =&gt; 6, 'post_type'=&gt; 'slide', 'slidesh...
Your code: <code> if( is_page(107) ) return; </code> checks for page and returns nothing on match, effectively it's exactly opposite of what you want. So if you reverse it and put this at start of function: <code> if( !is_page(107) ) return; </code> It will do nothing everywhere, but page 107 where it will proceed to r...
Return function only on certain pages
wordpress
I'm trying to determine how to retrieve custom values from wp_options when the values are stored in a single options array. For example, I've got the following data in wp_options for option_value where option_name = "my_category_fields_option". The i:n value represents the category id of the category that holds the cus...
<code> $term_id = get_query_var('cat'); // the current category ID $my_fields = get_option('my_category_fields_option'); echo $my_fields[$term_id]['my_title']; // the title corresponding to the current category </code> (assuming you're talking about stackexchange-url ("Any examples of adding custom fields to the catego...
How to retrieve a value via get_option when the option_value is stored in a multi-dimensional array?
wordpress
I have a custom post type ( <code> 'Model' </code> ) for a sports modelling agency, and it requires the model to enter sports they are competent at, and also rank their ability from 1 to 5. For example, given the information: <code> Model: Joe Soap. Football: 4. Archery: 2 </code> I would store this in the custom_post_...
Your question is focusing on the wrong thing. A metabox is just one way for a user to introduce some data. The more important question is how you should store that data in the database. You could make 'sport' a custom post type and connect it to models using the Posts 2 Posts plugin. Then, for each connection, you can ...
Is it possible to create relational metabox values in a custom post?
wordpress
I have a theme which includes some setup, using <code> after_setup_theme </code> but I'd like to write my own functions which also need to run <code> after_setup_theme </code> . I'd prefer to keep my stuff in a separate file. Can I call <code> after_setup_theme </code> multiple times?
WordPress hooks work like Hollywood: you don't call them, they call you. But unlike Hollywood, they keep calling everyone on the list. It's normal for an action or a filter to have multiple functions hooked to it, from different plugins, or even just different functions in the WordPress core that all do something speci...
How many times can I hook into the same action?
wordpress
I recently asked a stackexchange-url ("question") the other day and got what I was looking for. Today I put that knowledge to practice, but I can't seem to figure how to remove the title and editor fields from the "edit" page. Below shows the arguments I'm using with <code> register_post_type </code> . Logically, I thi...
You were close .) This works: <code> 'supports' =&gt; array( '' ), </code>
Custom post types - remove default post supports through empty array?
wordpress
Does anyone know of (or have) any scripts / processes they use for testing performance under load - especially of WordPress specific behaviours, like posting many comments nearly simultaneously, while under heavy simulated traffic. I typically use apachebench to test general performance (and to make sure caching is wor...
Just thought I'd throw in something I've been thinking about myself as a way of doing this: apachebench to simulate general viewing traffic a bit of PHP to add n comments per minute using WordPress (ie not directly inserting into the table). I'm also wondering if watir or selenium can't be put into action here instead....
Load testing for WordPress functionality
wordpress
A site I've built gets lots of comments in a short space of time - so perhaps 100 comments might be left in 5 or 10 minutes. This seems to cause a pretty heavy load on the database, especially when combined with recent comment widgets - I've seen server load rapidly spiral up to 40+, and using mtop I can see plenty of ...
MyISAM locks the whole page for writes and is not ACID compliant, while InnoDB sticks to locking rows as you point out, and is ACID compliant. This makes it sturdier when you've a lot of writes, as in faster and less prone to data corruption. It's slower for reads in my experience, though it handles concurrent connecti...
Would switching to InnoDB from MyISAM improve performance of comments table?
wordpress
If you were to build a StackExchange clone site using WordPress, how would you do it?
Using WordPress as a CMS (content management system), this would be relatively straight-forward. Just remember, straight-forward does not mean "easy" ... Custom Post Types One of the newest and best features of WordPress is custom post types. Rather than using a traditional post or page, I would make two kinds of custo...
StackExchange clone using WordPress?
wordpress
I'd like to add code to my functions.php to intercept all calls to wp_list_categories() AND the_category() so that it excludes "uncategorized" and any children of "uncategorized" (OR cat_id 1). I'd also like to limit the number of words returned in the "title" attribute of each list item anchor. Currently the default i...
I was finally able to figure this one out... Although I have to set the filter directly on the widget_categories_args method, so it does take two filter statements to do it. <code> function my_categories_filter($cat_args){ $cat_args['title_li'] = ''; $cat_args['exclude_tree'] = 1; $cat_args['exclude'] = 1; $cat_args['u...
filter out "uncategorized" from all category listings with one filter in functions.php?
wordpress
Can somebody tell me why this isn't working? I'm trying to get it to create a file in the plugins directory. After I get this working, I'll be trying to get this to create a file in the active theme's directory. Can somebody help me out here? EDIT I've changed my code, right now it creates the file but it does not inpu...
For unlinking, try: <code> function superDeactivation() { $myFile = "testFile.txt"; if(is_file("$myFile")) { unlink("$myFile"); } } </code> Or alternatively: <code> function superDeactivation() { $myFile = "testFile.txt"; unset($myFile); unlink("$myFile"); } </code>
Why is my plugins activation hook not working?
wordpress
Seems like a trivial problem but I can't get it to work. I need to add <code> class="last" </code> to every third post. Here is my code: <code> &lt;?php $count = 0; $my_query = new WP_Query('cat=-18,-7&amp;showposts=9'); while ($my_query-&gt;have_posts()) : $my_query-&gt;the_post(); ?&gt; &lt;article class="&lt;?php if...
I think you just need to start the <code> $count </code> variable from 1 and not zero. You'll get the opposite effect otherwise because 0 modulo 3 is 0. The first item of every 3 will be getting the class name.
Grid layout "last" class to every third item
wordpress
I'm using the TinyMCE Advanced plugin so that I can add my own custom styles to the Style dropdown in the Visual Editor. However, I don't want some of the styles that are included in the style.css file to be listed there, as they are 'internal' classes (for aligning pictures etc). Is there a way to stop these classes b...
This should be what you're looking for - put this code into your theme's <code> functions.php </code> file: <code> add_filter( 'tiny_mce_before_init', 'yourprefix_tiny_mce_before_init' ); function yourprefix_tiny_mce_before_init( $init_array ) { // filter styles: $init_array['theme_advanced_styles'] = "your_style=your_...
Stop certain classes showing up in TinyMCE Advanced Style dropdown
wordpress
I'm trying to figure out the best approach to add additional functionality that will only be utilized by admins via /wp-admin. What's the best way to implement so that resources aren't being wasted. I.E. if statement each page load or any other code execution on each page load for areas not even pertaining to the dashb...
There is number of dynamic hooks in admin-header.php that allows to precisely target on which pages to load your code. And naturally <code> current_user_can() </code> check so it only runs for admins.
What is the most efficient way of adding additional functionaliy for admin only
wordpress
Is there any way I can take a URL of an image and find the attachment or post id of that image in the database? Here is the situation: I'm in a loop going over all the 'img' tags that are surrounded by 'a' tags in my post content. if the src attribute of the 'img' tag does not match the href attribute of the outer 'a' ...
Massively improved function developed for plugin heavy on images: <code> if ( ! function_exists( 'get_attachment_id' ) ) { /** * Get the Attachment ID for a given image URL. * * @link stackexchange-url * * @param string $url * * @return boolean|integer */ function get_attachment_id( $url ) { $dir = wp_upload_dir(); // ...
Turn a URL into an Attachment / Post ID
wordpress
i have been working on a custom system for my site where users can have a seperate account, setting and profile page to make my site a bit more interactive and community type. with some other additional stuff. I am new to coding, i have managed to make the profile pages etc. Right now i am stuck in adding a check box l...
Justin Tadlock has a good tutorial to get you started: http://justintadlock.com/archives/2009/09/10/adding-and-using-custom-user-profile-fields There are some specifics to dealing with checkboxes however, and some custom code if you want to make checkboxes that correspond to tags/categories. To generate the form fields...
How to add/save Custom Field in user settings/profile "Checkbox list"
wordpress
I'm having a small issue with the custom post type entry screen. I'd like to bump up my metabox right under the content box, but I'm not sure if that's even possible (as the metaboxes in between are "defaults", i.e.; Excerpt, Discussion &amp; Author). I'm applying the standard code: <code> function ctp_admin(){ add_met...
Where you have the parameter 'normal' eg. the context parameter change that to read 'core'. <code> add_meta_box('cpt_meta', 'Meta Box', 'cpt_meta', 'cpt_function', 'core', 'high'); </code> The default meta boxes are registered as core and are listed first, followed by the 'normal' context. The docs don't actually say y...
Priority of Meta Box for Custom Post Type
wordpress
I’m still getting my head around buddypress, so far so good but I’ve hit a snag where I want certain users who are flagged as an ‘expert’ to automatically accept any friend requests people make. I’ve found a couple of functions related to this but I think I’m missing something that would make this simpler such as setti...
UPDATE try this <code> function bp_auto_accept_friend_request( $friendship_id, $friendship_initiator_id, $friendship_friend_id ) { $friendship_status = BP_Friends_Friendship::check_is_friend( $friendship_initiator_id, $friendship_friend_id ); if ( 'not_friends' == $friendship_status ) { if ( is_user_expert( $friendship...
How to auto-accept a friend-request in buddypress based on user meta
wordpress
This question got me thinking stackexchange-url ("Transient RSS feeds in wp_options not removed automatically?") Transients are supposed to expire and be deleted. However the only way I see this handled is when transient is expired and requested, then it is deleted during request. What if transient is expired but never...
They now are Starting with WordPress 3.7 expired transients are deleted on database upgrades, see #20316 Old answer If someone can't show me otherwise it seems that transients are not garbage collected after all. What makes it worse is that unlike options they are not guaranteed to be stored in database. So there is no...
Are transients garbage collected?
wordpress
Is it possible to fetch videos and images of a particular website and put it into post? i mean i am thinking of writing a function, where i will just write the website name, and then with the help of website url, all or latest images and videos are posted to my post. Is this possible?
The problem with this is that each sites content is formated differently. If there was only one site you were wanting to pull from you maybe able to use curl() and then sort though the content. A better idea may be to grab content from the sites RSS feed and sort though and grab what you need. You could probably write ...
fetch images and videos
wordpress
I just wrote a little plugin that detects if the user is on a mobile browser and if so detects them away from the WordPress site to a mobile (simple) version of part of the site. As I got to thinking I'm redirecting user who may want to see the full site. I can easily add a check by creating a URL such as <code> http:/...
As Ambitious Amoeba said, just do the check on each page load; it shouldn't be that expensive. Otherwise, another possibility to store a single bit of information would be to use browser cookies.
Append varible to url or set session
wordpress
I want to add a custom button to the tinyMCE toolbar in the 'Add New Post' screen which when clicked, will insert text into the new post. I have tried using this code (from http://tinymce.moxiecode.com/tryit/custom_toolbar_button.php ): <code> wp_admin_css('thickbox'); wp_print_scripts('jquery-ui-core'); wp_print_scrip...
Your problem i believe are the lines that follow the enqueues and print scripts, you're mixing Javascript with PHP.. Javascript goes inside the HTML section of a PHP file or inside an echo statement. This page of the codex gives an example for adding a button to TinyMCE inside WordPress. However that codex entry might ...
How to add a custom button to the tinyMCE toolbar?
wordpress
I have created a form within a Meta Box on the 'Add New Page' screen. I want the data from this form to be sent to an OData service on a central server. I can see that OData is supported on PHP ( http://odataphp.codeplex.com/ ) but it requires the OData for PHP SDK to be installed on the server. Because the server coul...
So basically what you're asking is how to create a php-based installer for the OData SDK, right? Or how to somehow package it with your plugin? First I thought you could just include the whole framework in your plugin folder, and include it directly from there. But it turns out (from reading the install docs) that inst...
How to send form data from WordPress (Meta Box) to an OData service?
wordpress
i try to build a form that users posts from frontend, everything works fine but i need to know if it's possible, if i play with the <code> 'post_date' =&gt; date('Y-m-d H:i:s') </code> ? if i add a hidden field that generates the expiration day (+30 days from the post day) and then add it to the post with <code> add_po...
The post by itself is only data, it cannot perform such action as expiring itself. So you need some form of external control to act on it. You can use WP Cron (see <code> wp_schedule_event() </code> and related) to run periodic task that will query for posts by your custom field and perform wanted action on them (trash...
Set Expiration Date of a Post from the Frontend with wp_insert_post
wordpress
I have to set up a small website, it's a porfolio for a design company with just the standard sections: home, about us, services, portfolio and contact. That's it, no blog, no dynamic sections, no big deal. I thought I could do it using WordPress, but I think it maybe an overkill. On the one hand, WP maybe useful for a...
I don't think it's overkill. IMHO even a small site can benefit from running WordPress. World wide web is a very dynamic environment and your site should stick to this flow. You can keep your site up to date when it comes to terms of usability, security and other standarts just by keeping your WordPress core updated. I...
Using wordpress for a four-page website may be an overkill?
wordpress
I'd like to decrease the default RSS cache time for a widget plugin i've made that outputs RSS feeds. I'm no php expert, I just copy and paste and understand little bits. I'm using this code to output the RSS <code> function widget($args, $instance) { // outputs the content of the widget extract( $args ); $title = appl...
Why not just use native RSS widget? Also while Chris_O is absolutely right on filter to use, it is better practice to change cache time for specific feed URL rather than globally: <code> add_filter( 'wp_feed_cache_transient_lifetime', 'speed_up_feed', 10, 2 ); function speed_up_feed( $interval, $url ) { if( 'http://mys...
Decrease RSS cache time in plugin?
wordpress
I'm in archive.php and attempting to write out the current category's description with full html. However, category_description() prints without the html markup. How can I force it to retrieve the full description complete with the html tags?
Found the answer here > http://www.laptoptips.ca/projects/category-description-editor/ <code> echo get_term_field( 'description', get_query_var( 'cat' ), 'category', 'raw' ); </code>
How to echo category_description() without stripping out html tags?
wordpress
My category descriptions consist of whole pages of content. When I view the manage categories screen, the grid does not truncate the text but rather, shows all of it. I realize I could turn off the description field in "screen options", however, I'd like to be able to truncate the amount of text that shows up there. Ho...
That field is not filtered in template. One way would be to filter <code> get_terms() </code> on that page (but I am not entirely sure that won't break something): <code> add_action( 'admin_head-edit-tags.php', 'admin_edit_tags' ); function admin_edit_tags() { add_filter( 'get_terms', 'admin_trim_category_description',...
How can I limit the amount of characters used for description in the manage categories grid?
wordpress
I am completely noob with WordPress so I apologize in advance if my questions sounds completely stupid. Background I have a small business catalog site that I wrote long ago in plain HTML. Now I want to add some SEO and improve the design therefore I am looking to use a CMS for easy content management. Questions Is Wor...
Is WordPress a right choice for my requirements? Is it only for blogging or can be used for any kind of site? (corporate, portfolio, catalog, personal info etc.) WordPress can absolutely be used for any kind of site. But note that while things like post and pages are ready out of the box and simple to use, it takes som...
WordPress for a business catalog site
wordpress
I couldn't seem to find a plugin with both functionality so I created mine(not a plugin) thru the help of my old friend google. My code works but there's a small glitch, the title of the posts are the same for all recent comments. <code> $comments = get_comments('status=approve&amp;number=5'); ?&gt; &lt;ul&gt; &lt;?php...
Use <code> $comment-&gt;comment_post_ID </code> instead of <code> $comment-&gt;post_id </code> . Also you don't need get_post(...). Just use get_the_title instead of your <code> $post_obj </code> and related code...
Display recent comments with gravatar and excerpts?
wordpress
When writing out the category description in my theme (on archives and special category listings) for example, there are times I need the description in full html mode and others when I need it returned stripped of any html. In the code below, I actually need the stripped version of the description, however $category->...
Have you tried something like this? <code> strip_tags($category-&gt;description) </code> Here the reference page for the strip_tags function
How to obtain the html stripped version of $category-> description?
wordpress
I'm using this autocomplete script https://github.com/agarzola/jQueryAutocompletePlugin within my wordpress theme. I have a form in a page where the user could specify some tags. Actually, this is the code I'm using and it's working good. <code> &lt;script&gt; jQuery(function() { var data = '&lt;?php global $wpdb; $sea...
don't include WP like that. use <code> $_GET </code> instead: <code> ... $("#tags").autocomplete("&lt;?php echo add_query_arg('get_my', 'terms', home_url()); ?&gt;", ... </code> theme's functions.php: <code> add_action('template_redirect', 'terms_for_autocomplete'); function terms_for_autocomplete(){ if(isset($_GET['ge...
jQuery Autocomplete in Wordpress
wordpress
I want to use dd belatedpng so the PNG's on my website appear properly on IE. The script I've always used on non-wordpress websites was <code> &lt;!--[if lt IE 7 ]&gt; &lt;script src="js/dd_belatedpng.js"&gt;&lt;/script&gt; &lt;script&gt; DD_belatedPNG.fix('img, .ir'); &lt;/script&gt; &lt;![endif]--&gt; </code> Now tha...
WordPress has a <code> $is_IE </code> global variable: <code> global $is_IE; if($is_IE) enqueue_script(...); </code> Personally I prefer the IE conditional comments. Other browsers ignore them anyway, so there's no reason to use PHP for browser detection. You might also want to consider using 8 bit alpha PNG images ins...
Enqueue script only for IE
wordpress
Where should I put an administration page that should only be used once? I am creating a plugin that will index all used HTML tags in your posts, so you can cleanup posts if you change themes and want to replace old incorrect <code> &lt;font&gt; </code> tags with headers or other semantic markup. When you install this ...
Putting it under Tools seems reasonable to me. Hiding it after a certain action might cause confusion.
Where should I put "run once" plugin pages?
wordpress
I'm attempting to move some code from a plugin over to my theme's functions.php file, but when I attempt to wrap it in the is_single() wrapper inside of functions.php, it never fires. What am I missing? <code> if (is_single()) { echo "hello world"; } </code> I can't get the echo to fire from any inside post page. This ...
All that I can think of is to verify that you are in fact on a single post page ( echo out an else conditional, make sure that you are actually hitting your block of code ). <code> if ( is_single() ) { echo 'Hello World, Is Single'; } else { echo 'Not Single'; } </code> Where exactly are you placing the code (Header, B...
is_single() works in plugin, not in theme?
wordpress
I am in the process of moving a site made up of asp pages to a completely redesigned Wordpress site. It has come time to create the 301 redirects for those old pages, so I don't break any links that are out there. I do have the redirection plugin installed as well. I've tried using it to do these types of redirects. I'...
In case anyone else stumbles upon this, the issue had to do with a setting in my provider. All of the comments above were correct on how to do redirects, but the problem was on the server side. I am using Rackspace cloud sites to host the wordpress site. In order to have ASP or ASPX pages redirect to PHP, you have to e...
Moving an ASP Site to Wordpress - Looking for Help on Redirects
wordpress
Hi I am writing a small plug-in which I get some content from outside of WordPress and I want a small script to trigger whenever a new post, page or comment is added. Also if any Widgets, themes and Plug-ins are Activated or De-Activated. My guess is that I should be using the action hooks for this but since there are ...
If you want to hook into multiple actions, you have to call <code> add_action </code> multiple times. However, this is not so hard. Let's take your plugin class as an example: <code> class WPSE6526_getStatic // Always prefix your plugin with something unique, like your name. Here I used the question number { var $_rend...
How to get multiple Action Hooks in an Array
wordpress
In the code below, rather than writing out the entire description field ($category-> description), how can I call the equivalent of the_excerpt? I'm placing the "more" tag after the first paragraph of the category description and using a visual editor to edit my category descriptions. <code> function show_category_inde...
<code> wp_html_excerpt($category-&gt;description, 25) </code> . Or you can create your own function. I'm using this: <code> /** * Filters content based on specific parameters, and appends a "read more" link if needed. * Based on the "Advanced Excerpt" plugin by Bas van Doren - http://sparepencil.com/code/advanced-excer...
How can the_excerpt (or equivalent) be called on a category description?
wordpress