INSTRUCTION
stringlengths
11
999
RESPONSE
stringlengths
0
999
SOURCE
stringlengths
16
38
METADATA
dict
Unable to nest categories in menu I have an issue with the new custom menu in WP3. Suddenly the nesting of categories stopped working and even though it's possible to nest them in the UI, when I press Save, then they all go back flat. Any chance someone has experienced this and know a way to fix it? Thanks.
First, **try disabling all of your plugins**. If that fixes it, re-enable them one by one until you find the culprit.
stackexchange-wordpress
{ "answer_score": 1, "question_score": 0, "tags": "menus" }
use add_settings_field properly? I'm using add_settings_field to add some more details to a settings menu, but not sure how I save the settings, or call them back in my theme. Here is the code thus far add_action('admin_init','vimeo_setup'); function vimeo_setup(){ add_settings_field('vimeo_id','Vimeo ID','display_vimeo','general'); } function display_vimeo(){ echo '<input type="text" name="vimeo_id" id="vimeo_id" value="" size="30" style="width:85%" />'; echo '<p><small> Enter your Vimeo ID here.</small></p>'; }
Documentation for add_settings_field() Says following: > **You MUST register any options** used by this function with register_setting() or they won't be saved and updated automatically.
stackexchange-wordpress
{ "answer_score": 4, "question_score": 4, "tags": "admin" }
how to display an excerpt of the latest post on the homepage? I've got a CMS-style wordpress setup where the homepage is not the main blog posts page. However, I would like to display the first paragraph of the latest blog post on the homepage, with a link to the post. How would I do that? I'd also like to display, above this excerpt, the first image within the post, but I'm guessing that might be harder... or I'll have to use the 'featured image' or a custom field...?
To show the excerpt from the latest post you can use query_posts. **Example Query Posts Showing the Latest Post with the Featured Image:** <?php query_posts('showposts=1'); ?> <?php while (have_posts()) : the_post(); ?> <h3 class="home link"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3> <?php the_post_thumbnail(); ?> <?php the_excerpt(); ?> <?php endwhile; ?> You will need to reset the query if you want to show content entered into your home page's post editor. <?php wp_reset_query(); ?>
stackexchange-wordpress
{ "answer_score": 4, "question_score": 0, "tags": "custom field, posts, cms" }
Are there any 'Coming Soon' themes for Wordpress 3.0? I have a website I am starting to build on Wordpress, but I want a placeholder theme to put up while I develop the theme. I had some links to some good "Coming Soon" themes for 2.X, but I lost them. Any good "Coming Soon" themes for Wordpress 3.0? I would prefer it to have a place for the visitors to sign up for updates via email.
**@Martin** There are a few "Coming Soon" themes available on The WordPress.org theme repository. One of them is Ready to Launch . My recommendation is to use one of the "Coming Soon" plugins instead. _**Why Use a Plugin?_** The advantage to using a plugin is that it allows you to work on the site while the public sees the coming soon page. Anyone who is logged in will be able to see the progress on the theme. I use CSS Jockey's Custom Coming Soon Page because it allows complete control over the coming soon landing page and includes a simple email sign up and jQuery countdown timer. This allows my client to add content and see the progress of the site while it's being built. Here are a few more plugin choices * Simple Coming Soon and Under Construction * Under Construction
stackexchange-wordpress
{ "answer_score": 5, "question_score": 1, "tags": "customization, themes" }
How to change the wording in wp-admin back-end? I don't want to edit core files in order to change the page where a user enters new posts, so is there a way to do it within a theme, perhaps within functions.php ..? Specifically, I'm trying to change the wording of the 'Set featured image' text to something like 'Set featured image - 50 pixels by 50 pixels'
You can use the filter `admin_post_thumbnail_html`: function custom_admin_post_thumbnail_html( $content ) { return $content = str_replace( __( 'Set featured image' ), __( 'Set featured image - 50 pixels by 50 pixels' ), $content ); } add_filter( 'admin_post_thumbnail_html', 'custom_admin_post_thumbnail_html' );
stackexchange-wordpress
{ "answer_score": 11, "question_score": 4, "tags": "wp admin" }
Wordpress Image Editor not working - conflict? I am having a strange issue with the built in wordpress image editor. I have no problem uploading files or preforming any other media functions. The only thing I seem to be unable to do is utilize the image "edit" capabilities (the area where you can crop, resize, rotate...) When I click on "edit" for an image I see the editor and I see the thumbnail on the right, wordpress just won't show me the actual image in the main area and thus I can't utilizing any of the editing capabilities. I am assuming this must be some type of JavaScript conflict however I not sure the best way to diagnose this other than what I have already done (disabling all plugins and ensuring no functions.php file is modifying a setting or including other javascript). How can I diagnose this issue to see what might be going wrong?
I have actually managed to resolve my own problem. For anyone else that might ever read this the problem which caused this was that my `functions.php` file had a closing ?> at the very end. For whatever reason this is what cause the issue and by removing this last line it was working again.
stackexchange-wordpress
{ "answer_score": 12, "question_score": 7, "tags": "media, editor, images" }
Using wpdb to connect to a separate database I want to connect `wpdb` to another database. How do I create the instance and pass it the database name/username/password? Thanks
Yes it's possible. The wpdb object can be used to access any database and query any table. Absolutely no need to be Wordpress related, which is very interesting. The benefit is the ability to use all the wpdb classes and functions like `get_results`, etc so that there's no need to re-invent the wheel. Here's how: $mydb = new wpdb('username','password','database','localhost'); $rows = $mydb->get_results("select Name from my_table"); echo "<ul>"; foreach ($rows as $obj) { echo "<li>".$obj->Name."</li>"; } echo "</ul>";
stackexchange-wordpress
{ "answer_score": 164, "question_score": 106, "tags": "database, wpdb, mysql" }
What is a better way to backup files than FTP? I want to backup my WP flies but the FTP is really slow. Is there a better solution ? (assume CRON and SSH in a managed VPS)
(assuming that FTP is slow due to amount of files) I use SSH to remotely give command to compress WP directory in single archive and then fetch that file. On Windows this is relatively easily scriptable with WinSCP ( scripting documentation ). This method greatly speeds up transfer, makes it secure, requires no plugins server-side, timestamps backups and is easy to schedule or launch with single click. (assuming FTP is slow in general) I would suggest to research backup plugins that can email backups (although size can get restrictive) or upload them to file storage service.
stackexchange-wordpress
{ "answer_score": 2, "question_score": 8, "tags": "backup" }
Minimal custom permalink structure I'm aware that there are posts discussing this issue already (e.g. What is the best permalink structure for SEO?) but I have a specific set of requirements according to my wordpress site structure, namely: 1. 6 pages 2. A small number of posts (~ 3 at launch, maybe 1 new one per month) I'd like to include the post name in the URL (for both SEO and easier stats analysis), but I've seen references to 'problems' arising from using _just_ the post name. * Would this be the case, even on such a small site? * Would `/%post_id%/%$postname%/` be a 'better' alternative? I notice that, even with this configuration, the Pages don't use the post_id in their URL.
Hi * _@Bobby Jack_ :* **You'll have absolutely zero problem** given your number of pages and posts. If you were looking at 5000, 10k, 25k pages or more, then start to worry. And the real problem is with categories as the URL base in the current implementation of WordPress' URL routing (which I hope to see changed in v3.2 or v3.3): * **Category in Permalinks Considered Harmful** **In Summary, nothing to worry about.**
stackexchange-wordpress
{ "answer_score": 5, "question_score": 5, "tags": "permalinks, seo" }
Why does blog page not reveal it's template? I've got a CMS style setup. The blog part is not on the home page. I'm trying to add certain things to the side-bar according to which template the page is using. That all works fine, except for the blog page, which does not even reveal its template name. echo get_post_meta($post->ID,'_wp_page_template',true); // produces nothing for blog template blog-page.php, but does show standard-page.php if ( is_page_template('blog-page.php')) { // show blog sidebar stuff.... never gets called } if ( is_page_template('standard-page.php')) { // show blog sidebar stuff.. this works } What else can I use to check if the page is a blog page rather than then template? UPDATE Doesn't seem to be actually using blog-page.php, but index.php instead... what if statement can i use to check if its a blog-style page?
You probably want one of the conditional tags. Possibly `is_single()`, or maybe `get_post_type() == 'post'` depending on how complex your setup is.
stackexchange-wordpress
{ "answer_score": 3, "question_score": 0, "tags": "cms, templates" }
Searching Only Blog Posts From a WordPress Site's Main Posts Page? On my CMS-style setup, I have the standard search box which searches everything. However, on my blog page, I would like to also have another search box which searches just the blog... is this possible, and how would I go about it? **EDIT** I used this code within a text widget which goes on my blog page: <form id='searchform' method='get'> <input style='margin-top:5px;' type='text' name='s' id='s' placeholder='Search (blog only)'> <input type='hidden' name='post_type' value='post' /> </form> This has the advantage that the results page is styled like the blog, and not the standard search page. (though I don't know how to indicate that the page is showing search results.. how to show this?)
Hi **@cannyboy** : There's a plugin called **Search Unleashed** that gives lots of different functionality. One of my clients was using it and I was impressed with the control it gave. Not 100% sure it will give you what you need but it's worth checking out. If your blog only has post_types of "post" and you don't use them for the rest of the site you could use _@TerryMatula_ 's suggestion but with `$post_type` => `'post'` instead, i.e.: > `<input type="hidden" name="post_type" value="post" />`
stackexchange-wordpress
{ "answer_score": 2, "question_score": 2, "tags": "cms, search" }
Is there a hook attached to general settings save? I want to add a field to the general settings page, but I can not save the field because I can't find a hook for the pages save. Any ideas?
You just need to `register_setting()` on your setting and it will be saved automatically. See the Settings API for more info. Here's a complete example: function spw_cb() { if( !($value = get_option('sprockets_per_widget')) ) { $value = 7; } ?> <input type="text" size="3" name="sprockets_per_widget" value="<?php echo $value; ?>" /> Numeric only! <?php } function spw_init() { add_settings_field('sprockets_per_widget', 'Sprockets per Widget', 'spw_cb', 'general'); register_setting('general', 'sprockets_per_widget', 'intval'); } add_action('admin_init', 'spw_init');
stackexchange-wordpress
{ "answer_score": 6, "question_score": 4, "tags": "plugins, options" }
Method/Plugin/Hack to Start a Post with an Writing Outline? I'm looking for a method/plugin/hack to auto-insert an outline when I start a new post in Wordpress. I've searched online for ideas as well as the WP Plugin repo with no luck. Essentially, many of my posts have a similar structure, and it would be nice not to have to paste it each time, but to have it embedded in the body of the "Add New Post" page. Of course, it should be editable.
Your question is very similar to this question: * **Creating a Custom Post Type for Inserting Preset Content into Post & Pages?** You might find the solution to be what you need; I extended my **WP Boilerplate Shortcode** plugin to meet the needs of the person asking the question; you might find the solution fits your needs as well.
stackexchange-wordpress
{ "answer_score": 0, "question_score": 0, "tags": "plugins, posts, automation" }
Plugin uninstall: why run dbDelta after $wpdb->query($drop_sql) i am reading professional wordpress. their code for uninstalling a plugin is //build our query to delete our custom table $sql = "DROP TABLE " . $table_name . ";"; //execute the query deleting the table $wpdb->query($sql); require_once(ABSPATH .’wp-admin/includes/upgrade.php’); dbDelta($sql); my question is why run `dbDelta` after `$wpdb->query($sql);`
This is indeed bizarre. I think they first tried it with `dbDelta`, found it doesn't work with `DROP` queries, and went with a straight `$wpdb` query instead. They then just forgot to take out the `dbDelta` stuff. It appears `dbDelta` collects creation queries in `$cqueries` and insert queries in `$iqueries`, but silently ignores the rest. What a lovely function... To be sure, you could ask this question on the book forum, hopefully the authors hang around there. Don't forget to mention you first asked it here, so we get some publicity!
stackexchange-wordpress
{ "answer_score": 3, "question_score": 2, "tags": "plugins, uninstallation" }
Why do I need to check if wp_nonce_field() exists before using it i dont really understand why the check if the nonce function exists before running it ... if ( function_exists('wp_nonce_field') ) wp_nonce_field('gmp_nonce_check'); i understand its for backwards compatibility ... > Also notice how you are verifying that the `wp_nonce_field` function exists before trying to call it for backward compatibility but wont it break anyway if on post back i check if ( isset($_POST['submit']) ) { check_admin_referer('gmp_nonce_check');
The answer is that you should not check if wp_nonce_field() exists before using it! The recommendation to perform the check assumes that you want to be compatible with versions of WordPress from before the function existed. If Rarst is right that it was introduced in 2.0.4 then you should NOT be supporting earlier versions, as they are all absolutely insecure and anyone using them needs to upgrade RIGHT NOW. Usually you should not have to check for existence of functions from inside WP, unlike functions from plugins that might not be activated. Where did you see that comment you quoted? It should be removed.
stackexchange-wordpress
{ "answer_score": 5, "question_score": 1, "tags": "plugin development, security" }
What's the difference between esc_* functions? I've read _Professional WordPress_ and it says: > `esc_html` function is used for scrubbing data that contains HTML. This function encodes special characters into their HTML entities > > `esc_attr` function is used for escaping HTML attributes > > `esc_url`. This function should be used to scrub the URL for illegal characters. Even though the href is technically an HTML attribute What's the difference between these? If I have <script>alert('hello world!');</script>this is some content Would all `< >` be converted to `&lt; &gt;`? Will the URL be something like `%xxx`?
`esc_html` and `esc_attr` are near-identical, the only difference is that output gets passed through differently named filters ( `esc_html` and `attribute_escape` respectively). `esc_url` is more complex and specific, it deals with characters that can't be in URLs and allowed protocols (list of which can be passed as second argument). It will also prepend input with ` protocol if it's not present (and link is not relative).
stackexchange-wordpress
{ "answer_score": 8, "question_score": 8, "tags": "security, escaping, sanitization" }
Why can't I add this feed to the RSS widget? I wish to use the following RSS in my widget, but it seems to not pick it up: < I imagine there is a problem in the feed. So: * What is it? * And can it be fixed? Thanks.
Maybe you can test with the plugin RSSImport, this has two different parser and more flexibility and also an debug-function for locate problems. The feed ist valid and I think, you must use this with a widget.
stackexchange-wordpress
{ "answer_score": 1, "question_score": 2, "tags": "widgets, rss, feed" }
Changing my permalink structure - will new layout conflict with existing page? My site has a blog page at `/blog/`, with links to blog posts. A post will have a URL starting at the root of the site, which is a bit jarring. I'd like to have the posts URLs appear as if they are within the blog section of the site. My site currently has a permalink structure like the following: `/2010/09/11/sample-post/` I'd like to modify it to include a `blog` prefix: `/blog/2010/09/11/sample-post/` As I understand, WordPress should be able to handle the appropriate redirects. My issue is the fact that I have the blog **page** at `/blog/` If I change my post permalink structure, is there going to be any conflict with a page having a similar URL?
I just tested it (briefly) on local test install and having static page at `/page/` and pretty permalinks starting with `/page/` doesn't seem to cause any issues.
stackexchange-wordpress
{ "answer_score": 1, "question_score": 2, "tags": "posts, permalinks, pages" }
How do I install two versions of WordPress on 1 server? I am installing on a local machine using `localhost`. I have a "learning" version of WordPress @ ` and I want to create another version of WordPress (@ ` I want to test and maybe move to a real server later. I found that when I extracted a fresh copy of WordPress into `localhost/jiewmeng`, it probably detects the WordPress database and uses that? All the data I get is from the "learning" version of WordPress. How do i set this up so that the 2 installations of WordPress are separate?
The database connection constants are defined in the wp-config.php file. Whether the 2 wp-config.php files in the jiewmeng directory and the WordPress directory are the same? You need to create 2 different databases and set their constants in the respective wp-config.php files.
stackexchange-wordpress
{ "answer_score": 6, "question_score": 4, "tags": "installation" }
What specific database privileges does WordPress need? I want to create a new database user for my WordPress installation. Usually on localhost, i can just use root, but it is good practice to use a user with as little rights as possible. What are those rights? I was wondering if WordPress needed to have installed plugins etc. It may require `CREATE` & `DROP` privileges as well. !alt text
If your database is set up to deny remote connections (i.e. only applications on the same server can interact with the database) then there's no danger in giving your WordPress user full access. As a matter of fact, most automated installation scripts used by web hosts grant full access to their WordPress user by default. Keep in mind that your database "user" is not actually a site user ... and unless you're manually administering your database via phpMyAdmin, the login credentials will never be used by anything but WordPress. That said, there's no guarantee that future versions of WordPress won't need the features you're disabling. If you use your WordPress user to manually administer the database, you might need these features as well. My recommendation would be to grant full access to your WordPress user, but use a highly complex password for the user.
stackexchange-wordpress
{ "answer_score": 2, "question_score": 4, "tags": "mysql, installation, privileges, phpmyadmin, customization" }
Problem installing plugin: unexpected T_STRING, expecting T_FUNCTION i am trying to install plugin tumblrize and got the error > Parse error: syntax error, unexpected T_STRING, expecting T_FUNCTION in D:\Projects\Websites\jiewmeng\wp-content\plugins\tumblrize\tumblrize.php on line 636 Call Stack: 0.0005 332520 1\. {main}() D:\Projects\Websites\jiewmeng\wp-admin\plugins.php:0 0.2249 3035904 2. plugin_sandbox_scrape() D:\Projects\Websites\jiewmeng\wp-admin\plugins.php:160 on line 636 is register_activation_hook(__FILE__, 'tumblrize_activate'); i dont see anything wrong with that, just learnt to develop plugins and that line looks ok? there is the function on line 611 function tumblrize_activate () { ... i am using wordpress 3.0.1 + PHP 5.3.2 btw
Now this one was really really hard to notice bug. I basically brutforced it by cutting/pasting blocks of code. Long story short - line 462 has wrong code opening tag `<?` instead of `<?php`. Which causes some kind of cascading tag mismatch, which seems to go unnoticed by any kind of syntax checker, but wreaks havoc on execution.
stackexchange-wordpress
{ "answer_score": 2, "question_score": 0, "tags": "plugins, installation, debug" }
Whitelisting Commenters I have a blog that gets the usual spam, which Akismet is pretty good with. Not good enough for me to turn off moderation just yet. I am wondering is there a way to "whitelist" a list of readers so their comments can skip moderation and just get posted?
In `Settings` > `Discussion` Uncheck `An administrator must always approve the comment` Check `Comment author must have a previously approved comment` This way comments from people (identified by combination of name, email and site) who have previously approved comments will not require moderation. Rest of comments will.
stackexchange-wordpress
{ "answer_score": 3, "question_score": 3, "tags": "comments" }
Widget constructor: about $id_base and $options in the book professional wordpress, they use something like $options = array( 'classname' => 'pp_widget', 'description' => '...' ); $this->WP_Widget('pp_widget', ..., $options); but in most tutorials $this->WP_Widget(false, ... is used. i wonder is there a reason to specify the `$id_base` param? i see that if i dont, an `id` will be generated. also, is there any need to specify the `classname` option? on a side note, i asked a related question on stack overflow: PHP: `parent::somefunction` or `$this->somefunction` if someone got an answer let me know :)
The reason is simply customization (these values end up in widget's HTML markup). If someone needs to change this stuff (for example to be compatible with some script without adding wrapper layers) the option is there. As for methods calling - `parent::` explicitly calls method from parent class, `$this->` calls method from current class. Since widgets do not redefine WP_Widget method there is no practical difference.
stackexchange-wordpress
{ "answer_score": 1, "question_score": 0, "tags": "widgets" }
How to limit image size for the entire website ? But without editing the post (css/plugin?!) I have a post here: < Where the image is overlapping the sidebar. I wish to shrink the image, but I want something that will do this without me editing the post (why? because the author is not me - and I want an automated system) Is there a plugin or a CSS solution that can do this? (as cross browser as possible?)
Quick fix via CSS would be using max-width property to style images inside posts. Unfortunately it is very unreliable in Internet Explorer. `.entry img { max-width:500px !important; }` Also in your specific case image has size defined with inline style and it interferes. Plugin method would involve scanning and changing posts content on the fly, which would probably bring in performance issues, etc. In my opinion it is better to fix such things consistently on content level. If you have no authority to edit posts show the issue to person who has.
stackexchange-wordpress
{ "answer_score": 2, "question_score": 0, "tags": "plugins, css, images" }
How do you remove Link backs on Theme settings page? How do we edit and remove link backs to theme Developers from theme settings page ? Some themes which we install on site has link backs .How do you edit them from multisites? Does any body have Idea on removing these links? I want to edit the Links Like "Mystique 2.4.2 by digitalnature" .
Basic idea is to search theme files for text of the link and remove code that inserts it. * Best case scenario it would be single line to remove. * Worst case scenario - link would be added by highly obfuscated code and rigged to break theme if link is removed. Since theme you referenced is in official theme repository it would be unlikely to have obfuscated code.
stackexchange-wordpress
{ "answer_score": 2, "question_score": 2, "tags": "themes" }
Self Develop or Plugin as first option? One of the things that attracted me to the WordPress platform was the plugin API and large selection, but more recently I have been self developing before looking for plugins, only using plugins for things that I don't feel I would be able to complete on time and in budget. So what do you do when you need functionality? Do you first think how you can do it yourself, or do you dive into the plugin repo straight away, the 'never reinvent the wheel' mentality? I think both have valid arguments.
There are several things I consider when making such choice (in no particular order): * does task involve general functionality (plugin) or processing my specific content (develop) * is there **the** plugin for the task from known developer and well-maintained (plugin) or there is fractured field of numerous plugins (develop) * do I want full range of related functionality (plugin) or single specific tweak (develop) In general I will always do at least quick search through plugins to assess how likely it is to get task done with them. There is no rule of a thumb here. I both use plugins for tasks that can be easily coded (for example page titles) and coded from scratch some really beaten things (for example anti-spam protection).
stackexchange-wordpress
{ "answer_score": 4, "question_score": 5, "tags": "plugins" }
What plugins are in use on wordpress.com is there a list of plugins that are in use on WordPress.com somewhere? It would be very interesting to see how they have implemented specific widgets and functionality.
Not an easy question to answer. That stuff is mostly private and they seem to use greatly modified versions of some public plugins. wordpresscom tag in repository has several. Also see this topic for more ideas and places to check List of plugins used on WordPress.com
stackexchange-wordpress
{ "answer_score": 4, "question_score": 2, "tags": "plugins, wordpress.com hosting" }
Is there a way (plugin?) to restrict a user to being able to edit just one page? We use wordpress like a CMS and would very much like to allow users to have a "homepage". Ideally they'd be prevented from mucking up the whole site. Is there a simple way to limit users editing rights to a single page? I'm currently using the Members plugin to do other permission-based stuff, so it'd be great if a solution could either neatly augment this, or replace it entirely. Bonus points for automatic creation of a homepage when a new user is created. * * * UPDATES: I should clarify that these pages need to be confined to a specific area of the site (i.e. all children of the same page). Also, after speaking to some users it seems that they'd find it useful to create sub-pages branching from their home page.
_Sorry to do this, but I stumbled across the answerin the wordpress forums._ It turns out that Role Scoper does this really well. The author of that forum post said it best: > To enable a user to edit one particular page, but not anything else: > > 1. Give them a WordPress role of Subscriber > 2. Manage > Pages > Edit their page > 3. Expand the "Editors" tab under "Advanced Options" > 4. Check the non-braced checkbox to the left of your user's name (if child pages will be created, also check the braced checkbox {[]}, which assigns the role for all current or future child pages) > 5. Save the Page >
stackexchange-wordpress
{ "answer_score": 4, "question_score": 9, "tags": "plugins, users, pages, permissions" }
How do you add Read more ... link to posts? How do you add Read more ...link to a particular post or to all posts in a blog ?
`Read more` links usually appear under following conditions: 1. Template uses `the_content()` function for display. 2. Post has `<--more-->` tag in content, which creates `teaser`. Result is `teaser`, followed by `read more` link. Sometimes such links are created artificially by appending them to output of `the_excerpt()` function in template. So to precisely answer your question - it depends on your template tags and how you use `excerpts` and/or `teasers`. See post (by me) for writeup on excerpt/teaser differences and mechanics.
stackexchange-wordpress
{ "answer_score": 6, "question_score": 10, "tags": "posts" }
How would I add a link to the profile editing page of the dashboard? Our passwords are handled by an external LDAP server and the plugin we're using to therefore removes all references to the ability to change passwords. What I'd like to do then, is add a link to the users profile editing page (where they get taken after clicking on their name) which points to our password change page. How do I add a link here?
I assume you mean `/wp-admin/profile.php` page and want to hide native password fields. Try this (just test if form works ok with it): add_filter( 'show_password_fields', 'modify_profile_password' ); function modify_profile_password( $show ) { ?> <tr id="password"> <th>Change your password at</th> <td><a href="">password change page</a></td> </tr> <?php return false; }
stackexchange-wordpress
{ "answer_score": 3, "question_score": 1, "tags": "admin, links" }
How can i get the title i specified in add_options_page for my header i have add_options_page('Post Products Settings', 'Post Products Settings', 'administrator', 'pp_settings', 'pp_settings_page'); anyway i can get whats specified in the 1st parameter for use in my page header? i know i can hard code it tho, but just curious
There are a few ways you can do this. My preferred way of doing this is using Object Oriented Programming (OOP) to structure the plugin. For example, I might do this: class JPBTitle { var $page_title = "Post Products Settings"; function __construct(){ add_action( 'admin_menu', array( $this, 'admin_menu' ) ); } function admin_menu(){ add_options_page( $this->page_title, $this->page_title, 'administrator', 'pp_settings', array( $this, 'pp_settings' ) ); } function pp_settings(){ echo "<div class='wrap'>\n\t<h2>$this->page_title</h2></div>"; } } $JPBTitle = new JPBTitle(); There are many many advantages to using object oriented programming in plugins; however, if you don't want to use OOP, I would suggest either setting a global variable or defining a constant with the value you want to use for that string.
stackexchange-wordpress
{ "answer_score": 4, "question_score": 2, "tags": "plugin development" }
Adding first / last CSS classes to menus is that possible, without javascript hacks? like this: <ul class="my_menu"> <li class="first"> ... </li> <li> ... </li> <li> ... </li> <li class"with_sub"> ... <ul class="my_menu_sub"> <li class="first"> ... </li> <li> ... </li> <li> ... </li> <li class="last"> ... </li> </ul> </li> <li> ... </li> <li> ... </li> <li class="last"> ... </li> </ul>
A better and simpler approach: function add_first_and_last($items) { $items[1]->classes[] = 'first-menu-item'; $items[count($items)]->classes[] = 'last-menu-item'; return $items; } add_filter('wp_nav_menu_objects', 'add_first_and_last');
stackexchange-wordpress
{ "answer_score": 14, "question_score": 15, "tags": "php, menus, css" }
When should you use WP_Query vs query_posts() vs get_posts()? It seems like half the tutorials in the Codex and around the blogosphere use `query_posts()` and half use `WP_Query`. They all do similar things, so when should I use one over the others?
* `query_posts()` is overly simplistic and a problematic way to modify the main query of a page by replacing it with new instance of the query. It is inefficient (re-runs SQL queries) and will outright fail in some circumstances (especially often when dealing with posts pagination). Any modern WP code should use more reliable methods, like making use of the `pre_get_posts` hook, for this purpose. TL;DR **don't use query_posts() ever**. * `get_posts()` is very similar in usage and accepts the same arguments (with some nuances, like different defaults), but returns an array of posts, doesn't modify global variables and is safe to use anywhere. * `WP_Query` is the class that powers both behind the scenes, but you can also create and work with your own instance of it. A bit more complex, fewer restrictions, also safe to use anywhere. ![](
stackexchange-wordpress
{ "answer_score": 738, "question_score": 454, "tags": "wp query, query posts, query, get posts" }
Building a Member Directory Site on WordPress with Facebook API Integration? I'm looking to build a member directory for one of my WordPress sites that hooks into the Facebook API. Site users would be able to browse through the directory of members and view their Facebook profile and information such as e-mail address, phone number, website, etc. Basically, I'm thinking that members will need to login to facebook from the site and "allow access." Then, WordPress can pull member data from Facebook such as e-mail address, phone number, website, etc. and store it as custom meta in WordPress. One problem with this approach would be when a user updated their facebook profile, the WordPress site wouldn't get updated until they log back into the site and the "update" process kicks off again. Am I way off base? Is there an easier way to do it? Is there anything that would get me started with this, or would it need to be built entirely from scratch?
Hi **@Nate Dudek** , I think you'll likely want to start with **BuddyPress** as it is essentially a _"Facebook-in-a-Box"_ , albeit a much more limited version of Facebook. It'll have more of the data structures you need to integrate with Facebook in the manner you describe. Beyond that you might find these articles helpful: * **How To Integrate Facebook With WordPress** * **12 Useful Facebook Wordpress Plugins For Bloggers** * **6 Best Facebook WordPress Plugins** * **10 Must Have Facebook Plugins For WordPress** * **WP-FacebookConnect Plugin** * **Plugins on WordPress.org tagged with "Facebook"** Hope this helps!
stackexchange-wordpress
{ "answer_score": 1, "question_score": 1, "tags": "facebook" }
Live blogging plugins? What do you all use for live blogging? I've found Live Blogging by Chris Northwood (more than I need) and Twitter LiveBlog by Mashuqur Rahman (I want it to stay within WordPress). Are these really the only two games in town?
I wrote my own Liveblogging platform, which turned out to be very simple to do indeed. Sadly, it's not ready for release yet. In practice, all you need is a page with a form which writes to a database. Now; liveblogs tend to get hammered, so I created a page which used my templates as a flat file (so no database calls). Whenever I updated the liveblog with another entry, it wrote it to a flat file, and it showed the flat file to the user. Rather simple, but brutally fast. Stood up to very high traffic on a small tech site you may have heard of.
stackexchange-wordpress
{ "answer_score": 2, "question_score": 2, "tags": "plugin recommendation" }
How to display a shortcode caption somewhere other than the_content I want to disable shortcode captions for posts in one of my themes, and display the content elsewhere, such as in a sidebar. The images aren't uploaded to wordpress, but they're linked-to using the post editor's add an image -> from URL functionality resulting in the following shortcode: [caption id="" align="alignnone" width="300" caption="Leonard Nimoy has done far more thing than just play Mr. Spock"]<a href=" src=" alt="Leonard Nimoy in a black suit" title="Leonard Nimoy" width="300" height="228" /></a>[/caption] Any thoughts? I'm assuming using a filter on `img_caption_shortcode` somehow, but I don't know if that's the way to approach this.
Try this: $caption_info = array(); add_filter( 'img_caption_shortcode', 'capture_caption', 10, 3 ); function capture_caption( $blank = '', $attr, $content ) { global $caption_info; $caption_info[] = array('attr' => $attr, 'content' => $content ); return ' '; } It will save info from all captions into global `$caption_info` variable and suppress their display in content (space is returned because filter result is ignored if empty).
stackexchange-wordpress
{ "answer_score": 1, "question_score": 0, "tags": "images, attachments, captions, shortcode, filters" }
Are captions stored anywhere? In regards to my previous question about shortcode captions, it doesn't appear to me that the actual text of a caption is stored anywhere other than in the post content within the shortcode itself. I would have thought that `wp_get_attachment_metadata` would store the info for an attachment, but it doesn't. Am I wrong? Or does WordPress not store the actual caption anywhere?
Yes, it stores the caption in it's own place in the DB. I can't quote the exact location but in Wordpress, "Attachments" are a post type and it stores each attachment just like a post. For an attachment post type, it treats the Image Caption as `the_excerpt` the Image Description as `the_content` and the Image Title as... `the_title`.
stackexchange-wordpress
{ "answer_score": 4, "question_score": 6, "tags": "attachments, captions, post type" }
What is a settings group actually for? say i have an option update_option('pp_options', $options); when i want to create a form for that, i learnt that i have to create a settings group register_setting('pp_options_group', 'pp_options'); then in the form do settings_fields('pp_options_group') but i dont really what is the settings group actually for? i know its to do with sanitization but why the need to create a group for sanitization?
Sanitization is secondary function. Main is: > The register_setting and unregister_setting functions add and remove options from a whitelist of allowed options that the form is able to save. They can also name a sanitize callback function as a security measure to check each option's value. ( Register settings ) Technically `$option_group` argument is used for: * array key in global array of whitelisted options * part of filter name to run sanitization callback
stackexchange-wordpress
{ "answer_score": 3, "question_score": 3, "tags": "plugin development" }
Questions about meta box: nonce and parameters available 1st question is: is a nonce required for a meta box? i read on the wordpress codex `add_meta_box` and they have a nonce for the meta box, i'd thought that maybe the add post form will already include a nonce? echo '<input type="hidden" name="myplugin_noncename" id="myplugin_noncename" value="' . wp_create_nonce( plugin_basename(__FILE__) ) . '" />'; 2nd question is: whats the parameters available for the function that creates the markup of the meta box. from what i read in profesional wordpress looks like function pp_meta($post, $box) how will i know what parameters are available in such functions? and what does `box` refer to?
Not sure about nonces. As for arguments it is probably their usage of add_meta_box(): > **$callback_args** _(array) (optional)_ Arguments to pass into your callback function. The callback will receive the $post object and whatever parameters are passed through this variable. Default: null So `$post` is post object and `$box` is whatever they are passing in `$callback_args`
stackexchange-wordpress
{ "answer_score": 1, "question_score": 0, "tags": "plugin development" }
Import and export links from WordPress.com to private site Is there some way to export/import links from a wordpress.com site to a private site? I have a rather large directory of links. I fetch the opml file and the category levels are there, but when I use the Bloggroller importer, it doesn't create the categories? Help would be appreciated.
If you're going from WP to WP, then you want to use the built-in exporter and importer. Your links should come along with it. I'm not sure about the categories with it, but this might help <
stackexchange-wordpress
{ "answer_score": 2, "question_score": 3, "tags": "wordpress.com hosting, links, import, export" }
How to check if certain plugin exists and in expected version I've created plugin that goes to wordpress plugin repositories. Now, I need to create another plugin (sub plugin or child plugin you may call) that require this certain plugin to be already installed and activated. I know I can use `register_activation_hook`. However, how do I check using that hook? Or, maybe there's another solution exists?
There is `is_plugin_active()` function. Other method is to check if functions or classes, specific to required plugin, exist. Some plugins explicitly define their own constants for this, typically with version number and/or other identifying info. There has been some developments to make extension dependence logic more generic, such as Plugin Dependecies, but they hadn't gained widespread adoption so far.
stackexchange-wordpress
{ "answer_score": 3, "question_score": 2, "tags": "plugin development, hooks" }
Which Blog Client for Windows/Linux has the best support for backing/restoring your posts? I started using Akeeba Remote Control for Joomla and was really impressed with it. When I went to look for something similar for Wordpress, I found these Weblog clients. Which one is the best for backing/restoring up your content? (Existing and content that you add to the blog via the Weblog client)
It is not really direct answer to your question, but I think complete (database plus files) backup/restore is more comprehensive and important. Content backup is only content. Database is all of your blog, which can help you go from nuked database back to normal in no time (speaking from sad practical experience, that would be much more sad without complete database backup). Would you like to keep your question about clients alone or expand it to backup/resotre in general (it's marked as community wiki so I am trying to establish scope) ?
stackexchange-wordpress
{ "answer_score": 1, "question_score": 1, "tags": "backup" }
How Can A Widget With Only One Instance Be Defined? How can a widget which of which only one instance can be used?
Simple way would be to set some global variable on first widget run and check for it. Output nothing or informational message if it is already set. Proper way would probably be to work with interface and remove widget from available when you add it to sidebar, but that is way out of my league.
stackexchange-wordpress
{ "answer_score": 2, "question_score": 0, "tags": "customization, widgets" }
Limit the amount of main pages Hay, i have a site which has been designed to only have 8 main pages across the main navigation, however these pages can have as many subpages as they want. Is there a way to limit the amount of main pages an admin can create?
Won't it make more sense to limit number of pages that navigation displays? There are many instances when page is not wanted in navigation but still needed somewhere (I have privacy policy set up this way at my blog for example).
stackexchange-wordpress
{ "answer_score": 1, "question_score": 0, "tags": "pages, homepage" }
XML parser plugin I have an XML data source that updates daily. Is there a plugin that will allow me to create a query and update it daily with the least programming possible and display the data on a page?
XML as in generic XML? I mostly mess with RSS (for which WordPress has SimplePie bundled). Maybe SimpleXML (PHP 5+, not WP specific) will do? Also quick repository search found this: Advanced XML Reader
stackexchange-wordpress
{ "answer_score": 3, "question_score": 0, "tags": "plugins" }
Plugin for editing options on multisite? does anyone know of a plugin for mass editing of settings on a multisite installation? Something like Plugin Commander for Settings?
i think this is what you looking for: <
stackexchange-wordpress
{ "answer_score": 1, "question_score": 8, "tags": "multisite, plugins, options" }
How can I show my scheduled posts in Google Calendar? I typically schedule posts well in advance before they get published. At times I can have as many as 5-10 scheduled posts set to be published within the coming weeks. Is there a way to show a calendar with all my scheduled posts? Ideally I would like to see them in Google Calendar.
It's not Google Calendar, but the Editorial Calendar plugin works really nicely. !Screenshot of Editorial Calendar plugin borrowed from the plugins directory
stackexchange-wordpress
{ "answer_score": 3, "question_score": 1, "tags": "scheduled posts" }
Is there a way to upgrade a theme without losing custom templates? I recently updated the main theme of a production site. Unfortunately, the upgrade process deleted all our custom templates. Is there any way I can prevent this happening again?
Child themes might be your best bet.
stackexchange-wordpress
{ "answer_score": 4, "question_score": 0, "tags": "themes, templates, updates" }
How can I remove specific custom post meta from the "Custom Fields" fieldset? I've created a custom meta box to handle certain custom post meta fields and I don't want the clutter of having these custom fields duplicated down in the "Custom Fields" area. How can I remove specific custom post meta from the "Custom Fields" fieldset?
To hide a custom field from the "Custom Fields" section, prefix it with an underscore. So `add_post_meta($id, 'name', 'value');` becomes `add_post_meta($id, '_name', 'value');`. Here's a good reference for backup: * How to Hide Your Plugin's Custom Fields
stackexchange-wordpress
{ "answer_score": 2, "question_score": 1, "tags": "theme development" }
Add Google Analytics manually, or use a plug-in? Our situation is that we only dabble with Wordpress, however one of our Wordpress customers wishes to add Google Analytics to his site. I'm assuming we can do this manually, relatively easily. And our instincts would be to go down that route. The customer is only small scale and won't need to do anything especially sophisticated, at least at this stage. We want to keep this simple. Is it best to avoid a plugin? ## Update Thanks for all the great answers- in the end we did use a plug-in. As promised by the experts who answered below it was super straightforward.
I'd suggest either a plug-in or a drop-in section of code in your client's `functions.php` file. The advantage of a drop-in is that you can add it once and never have to worry about activating or managing the system once it's up-and-running. Here's a quick explanation of how to add the Google tracking code to your theme's `functions.php` file. The code itself will be automatically added to the footer of every page, archive, and post. This is essentially what a plug-in will do, without requiring you to activate/administer the system within the WordPress UI. Alternatively, you could use Google Analytics for WordPress to do the same thing within the UI. The choice between plug-in or drop-in is entirely up to you. A drop-in takes about 10 seconds to add with copy-paste. A plug-in takes only slightly longer. The actual setup process within Google Analytics to get your tracking code will take longer than either approach.
stackexchange-wordpress
{ "answer_score": 12, "question_score": 21, "tags": "plugins, google analytics" }
Are there any hooks that alter the 404 logic? Provided you have a 404 page defined in your theme, Wordpress will display a 404 page if "tag" is defined in $wp_query->query_vars, and there are no posts matching that tag. I'm writing a plugin that displays some information on each page, in addition to posts. I'd like to alter the 404 logic so that the 404 page gets displayed if there are no posts matching a tag _and_ the plugin cannot pull up any data matching that tag. If the plugin can find data, I'd like to show a normal page, regardless of whether there are posts on that page or not ... I've been Googling, reading code, reading the codex, and poking around here, and haven't been able to figure out where Wordpress triggers that 404, and how I can override it. (I have a feeling it might have something to do with status_header() in functions.php, but it's not clear how and when I need to hook into it). Any help/ideas/enlightenment appreciated. Thank you, ~ Patch
After a bit more slogging through code and Googling, I found the answer. It's contained in this thread (see Otto42's post), but for the record, adding the following to your plugin will override the 404 handling for the conditions you specify: add_filter('template_redirect', 'my_404_override' ); function my_404_override() { global $wp_query; if (<some condition is met>) { status_header( 200 ); $wp_query->is_404=false; } } Note that you need to set "is_404" to false before PHP outputs headers, which is why hooking it in the template_redirect logic is a good idea. ~ Patch
stackexchange-wordpress
{ "answer_score": 33, "question_score": 32, "tags": "hooks, plugins, 404 error" }
Problem in logging in as admin When I am trying to login as admin to my site I am redirecting to another unknown page. The login page is pointed to a page-Id2 .I don't understand why it is happened and how to solve it. The links to admin page are redirecting to that page Id-12 . Could any one help me to resolve the issue
The problem has been solved when I deactivated some plugins .
stackexchange-wordpress
{ "answer_score": 0, "question_score": 0, "tags": "multisite, errors" }
Plugin to edit htaccess file Is there anyway I can edit my htaccess file without using ftp?
Here are a couple of options: * WP htaccess Control \- will let you manually edit your `.htaccess` file * All-in-one htaccess Plugin \- will let you dynamically create an `.htaccess` file based on which modules/features you want set up _When all else fails,turn to Google ..._
stackexchange-wordpress
{ "answer_score": 3, "question_score": 3, "tags": "htaccess, ftp" }
Post-by-mail similar to WordPress.com or Posterous? A standard WordPress installation has very basic support for posting via e-mail. Is there a plugin that gives the same functionality as WordPress.com (especially attachment handling)? My client is in love with Posterous, and I could set up the XML-RPC bridge so new posts go to WordPress, but I'd rather stay in WordPress so I could add advanced handling of custom post types and taxonomies myself once we get the basics running.
Try Postie. < It has lots of features (including handling attachments and inline images)
stackexchange-wordpress
{ "answer_score": 5, "question_score": 1, "tags": "plugin recommendation, posts, wordpress.com hosting, email" }
Weird Issue with load balanced WP 3.0 setup I have a wordpress MU (3.0.1) setup (upgraded from 2.9.2). It runs on 4 instances, load balanced, and all 4 connect to same database. Now, when only one instance is running, it is working fine... When I run multiple instances, I am not able to trash or undo trash or even do any change in settings .. I get this message: Are you sure you want to do this? Please try again. the URL when this occurs is mblogs.com/testblog/wp-admin/post.php?post=9&action;=trash&_wpnonce=8f5a697d1e What could be the issue and how to fix it?
Likely this is result of `check_admin_referer()` function not recognizing your request as coming from admin area. Since your query clearly contains nonce it is likely what is not being recognized. > Nonces can be locked down in many ways. They are **unique to the WordPress install** , to the WordPress user, to the action, to the object of the action, and to the time of the action (24 hour window). That means that if any of these things changes, the nonce is invalid. ( Mark Jaquith ) My theory is that your load-balanced installs don't count as same install for the purpose of generating nonce. If possible try to limit admin area to single server and see if that helps.
stackexchange-wordpress
{ "answer_score": 3, "question_score": 4, "tags": "multisite" }
Menu with Automatic Pages Included from Custom Post Type Question - How can one utilize the wordpress 3.0 Menu system to automatically have new pages from a custom post type included within the menu (I am referring to the Menu Management area of wordpress for the public website). I believe this currently works for the regular "pages" if you check the automatically incude box but is there a way to also hard code it to work for pages from a custom post type?
This is accomplished by `_wp_auto_add_pages_to_menu()` (in `\wp-includes\nav-menu.php`) function that is hooked to `transition_post_status` hook. Unfortunately it is hardcoded for `page` post type and is not easy to extend. On other hand since it works through generic hook it isn't hard (relatively, menus internal code is pain) to engineer analogue for custom post type.
stackexchange-wordpress
{ "answer_score": 3, "question_score": 1, "tags": "custom post types, menus" }
SEO - Two WordPress websites on same domain name Would there be any negative SEO effects for having a wordpress website at example.com and having another website at example.com/anothersite? 1. Would the site "anothersite" be indexed in search engines (assuming I did all the seo strategies for them)? 2. Any negative effects for either site? Thanks in advance
1. Yes 2. Whatever negative means to you. I tend to say not more then with a single site. The search engine will basically spoken not differ between one or more sites. The spider is just indexing pages not sites. So this can have positive effects while the content of one site pulls / pushes the URLs of contents of the other one. So the arrangement of the sites in URLs on that domain (URL Layout) and it's contents will have the SE influence, not the number of sites you run on the domain.
stackexchange-wordpress
{ "answer_score": 1, "question_score": 2, "tags": "seo" }
get_term_by seems to be failing Code: print_r($wp->query_vars); echo "<br><br>".get_query_var('term'); echo "<br><br>".get_query_var('taxonomy'); $term = get_term_by('slug', get_query_var('term'), get_query_var('taxonomy') ); echo "<br><br>$term"; Output: Array ( [titles] => windows-powershell-v2 [taxonomy] => titles [term] => windows-powershell-v2 ) windows-powershell-v2 titles As you can see, the first three lines run fine. The fourth line fails with no error - but it terminates page execution. The specified term does indeed exist in the taxonomy; this is being reached with the URL /titles/windows-powershell-v2/. Any idea what I'm doing wrong?
`get_term_by()` returns object by default. Which should end up in `Catchable fatal error: Object of class stdClass could not be converted to string` if you try to echo it. Likely you have errors suppressed. Try `var_dump( $term );` instead of `echo`.
stackexchange-wordpress
{ "answer_score": 2, "question_score": 0, "tags": "taxonomy" }
In WordPress 3.x, I can't access posts from all blogs in the network I use WordPress a ton, but I'm somewhat new to multisite. Now that 3.0 has brought multisite into the main core, shouldn't there be an easy loop function that allows you to display the most recent posts from across your network, in a loop, for me to output in PHP as I want? Does anybody know if this exists and I'm just missing it?
Wordpress doesn't (and won't) support this natively. The alternative is to write your own template with a custom request. (You might even have to drop down into MySQL - I'm not sure the built in Wordpress query system will be capable of this.) Check out this plugin though: WordPress MU Sitewide Tags Pages It might give you an acceptable compromise, or it might give you a starting place when coding your own approach. Good luck!
stackexchange-wordpress
{ "answer_score": 2, "question_score": 0, "tags": "customization, multisite" }
Create posts using markdown? Can I replace the WYSIWYG editor with a markdown editor? If so, what plugin can I use?
I'm not sure about the version of Markdown, but here's some plugins I use markdown-for-wordpress-and-bbpress to get wordpress to render posts and comments in markdown format. For editors, I prefer markdown-quicktags. It has a bunch of auto-complete features, and seems to be the most actively updated markdown editor plugin. You might also try wmd-admin for the wmd editor (Same markdown editor as the stackexchange) or wp-markitup (not markdown specific)
stackexchange-wordpress
{ "answer_score": 9, "question_score": 25, "tags": "plugin recommendation, markdown" }
If your blog was an app on Facebook If you were to turn your blog into a Facebook app, what features would it have? What would the UI look like? What are the significant dealbreakers you'd need to satisfy to extend your blog to a social networking platform? I'm marking this as a community wiki because I'm not looking for one answer, but for an array of "best practices" that developers should consider when taking their blog online through a social network. One feature/UI element/dealbreaking necessity per answer please.
My number 1 feature would be to have the ability to use WordPress to manage a fan page. It would have to have the ability to use a WordPress page to create a Facebook page application tab. Published posts would auto publish to the Facebook wall and comments would sync between WordPress and Facebook.
stackexchange-wordpress
{ "answer_score": 7, "question_score": 4, "tags": "facebook, customization, user interface" }
What archive plugin works with W3 total cache? All plugins I've tried makes the page go blank. I tried so far: * Smart Archives Reloaded * Clean Archives Reloaded * Better Extended Live Archives Thanks. Tal
**@Tag,** To answer your question directly, Smart Archives Reloaded works with W3 Total Cache. I have thoroughly tested it on my test bed and it works fine with W3 Total. I was even able to easily add the js to my minify settings. Version 2.0 removed the caching from the plugin. Have you tried it with the latest version? > No more buggy caching > > Older versions of the plugin stored the generated HTML in a text file, instead of generating it on each page load. Unfortunately, this relied on two rather unreliable things: file permissions and wp-cron. Thus, it was the biggest source of problems for users. So I decided to remove file caching completely. > > If you want caching back, the best solution is to use a dedicated plugin, such as WP Super Cache. It will make your entire site load much faster. It seems that some of the other archive plugins use some sort of caching mechanism which might cause a conflict with a dedicated caching plugin like W3 Total.
stackexchange-wordpress
{ "answer_score": 1, "question_score": 0, "tags": "plugins, cache, plugin w3 total cache" }
How can I add Expire headers to images? I'm trying to speed up my site a bit. How can I add Expire headers to images I upload? Must this be done with Apache configuration, or is there a setting or plugin to do the job?
This can be done with Apache configuration, I have used this snippet in the past in .htaccess: ExpiresActive On ExpiresByType image/gif "access plus 1 month" ExpiresByType image/png "access plus 1 month" ExpiresByType image/jpeg "access plus 1 month" Can be set up with plugin as well. W3 Total Cache (which I currently use) can do that among other things. Overall this is not a huge performance factor. Modern browsers are smart enough about caching images even without expires set.
stackexchange-wordpress
{ "answer_score": 2, "question_score": 1, "tags": "plugins, cache" }
Any built-in function to associate a post to category through a plugin? I have a post ID and I'm just trying to find a function ( I was thinking of something similar to wp_update_post() ) where I can just pass a post ID and maybe a category ID or slug and have it associate the post to the category. Does that exist or have you seen a plugin doing that where I can peek at what they did?
`wp_set_object_terms()` is native function that assigns term from taxonomy to post.
stackexchange-wordpress
{ "answer_score": 1, "question_score": 1, "tags": "plugins, categories, posts" }
Stop underlining image links One my widget bar, I have an image which is hyperlinked. The problem is that CSS underlines it. How do I remove the underline? Update: Just noticed that this is what is causing the underline: } .entry a, .secondaryColumn a, #commentsContainer h3 a, .commentlist .comment-author a { border-bottom: 1px solid #ddd; color: #3c6c92; font-weight: bold; } .entry a:hover, .secondaryColumn a:hover, #commentsContainer h3 a:hover, .commentlist .comment-author a:hover, .commentlist .comment-meta a:hover { color: #3c6c92; border-bottom: 1px solid #3c6c92; } changing the border-bottom to 0px does the trick, but then it takes off the border across all widgets. I use Grid-focus with a wee bit of customization @ thunderror.com
By definition it isn't really hyperlinked image. It is hyperlink tag `a` that contains image tag `img`. Most probably it is a link that is really underlined, image is just inside it. You need to create new CSS rule that matches your link with image and specifies no underline (it could also be border-bottom property by the way, some recommend it over underline for better typography looks). If possible please give link to the site. CSS in theory is even worse than PHP in theory. :) I assume it's about twitter image at top of sidebar? Try this: .textwidget a, .textwidget a:hover { border-bottom: none; } But this will affect all text widgets. It is probably better to assign individual class to link like <a href=" class="twitter-link"> and style it.
stackexchange-wordpress
{ "answer_score": 2, "question_score": -1, "tags": "images, css, links" }
How to Move the Author Metabox into the "Publish" metabox? About a year ago I remember seeing a plugin or some code which allowed you to add an author dropdown menu to the post "publishing" metabox instead of it being on its own. I can't seem to find this code anymore and was wondering if anyone knows how to easily do this? In an ideal situation I would like to essentially add an additional row under the "Visibility:" row within the Publish metabox stating "Author:" along with the current authors name and an edit link after the name. Upon clicking on the edit link a drop down would show up with the same information as is available in author metabox. In any case, I would greatly appreciate to know how this can be done.
I somewhat suck with admin stuff so test this carefully. I had some issues with users not coming up in dropdown, but it fails with default meta box as well - probably because of my messed up test stack. add_action( 'admin_menu', 'remove_author_box' ); add_action( 'post_submitbox_misc_actions', 'author_in_publish' ); function remove_author_box() { remove_meta_box( 'authordiv', 'post', 'normal' ); } function author_in_publish() { global $post_ID; $post = get_post( $post_ID ); echo '<div class="misc-pub-section">Author: '; post_author_meta_box( $post ); echo '</div>'; }
stackexchange-wordpress
{ "answer_score": 8, "question_score": 3, "tags": "menus, metabox, editor" }
How to create a mini directory in WordPress? I'm looking to create a simple directory, something similar but not so powerful as SOBI2 for Joomla. Is there something like this for Wordpress? I want to store informations like: * Name * URL * Address (country, region) * Details (text) People should be able to browse or search such a simple directory. Is there something like this available for WordPress?
Sounds like what you want is to use **Custom Post Types** with custom fields to create your own directory. Here's an answer I wrote about exactly that: * **Tips for using WordPress as a CMS?** * **Implementing a CrunchBase.com Clone using WordPress?** Also, take a look at the **SimpleFields** plugin for WordPress which can help you create these custom fields: * **SimpleFields Plugin**
stackexchange-wordpress
{ "answer_score": 2, "question_score": 3, "tags": "custom post types, post meta, directory" }
I need a plugin in wordpress like google tasks I need a plugin like google tasks, in which we can add in to do tasks on the wordpress page
I don’t know Google Tasks. But a Task Manager I use on nearly every blog is Cleverness To-Do List. You can order tasks by custom categories and by priority, assign tasks to specific users and set the progress for each task. Really useful, saves me hundreds of mails from my clients. ;)
stackexchange-wordpress
{ "answer_score": 1, "question_score": -2, "tags": "customization, plugin recommendation" }
Which plugin can do horizontal scrolling of RSS feeds in WordPress I need a plugin which can do horizontal scrolling of RSS feeds in wordpress, I have got a vertical scrolling RSS feeds but cannot find a horizontal one
Things that present headlines in a horizontal scroll tend to be called tickers. (Probably due to there resemblance to old-school ticker tape printers.) Anyway, try these: * < * < (may not do RSS) * < They should all do pretty much the same thing, but they will differ in their appearance. If you don't mind about the appearance, I would recommend the first due to the ease of management.
stackexchange-wordpress
{ "answer_score": 2, "question_score": 0, "tags": "plugins, customization, javascript, rss, feed" }
How to create custom message on plugin update I saw this message today when accessing my plugin page: !custom plugin update message So, how do I create this if I want to update my own plugins that's hosted on wordpress?
This message is created by `W3_Total_Cache->in_plugin_update_message()` hooked to `"in_plugin_update_message-$file"`in `wp_plugin_update_row()`. It does some nifties to parse readme and display info from changelog, but overall you can just echo some stuff as with any other hook.
stackexchange-wordpress
{ "answer_score": 9, "question_score": 11, "tags": "plugins, updates" }
How to get last_updated and newest_blogs in WP 3.0 We were using WPMU version 2.9.1, in which we had a plugin - Fimii WPMU Stats mu-plugin - that showed us last updated blogs, and newest blogs. We now upgraded to Wodpress 3.0, and the commands for the plugin don't work anymore. Does anyone know of a replacement for that plugin? Or something else that will show the data?
We found 2 plugins that work: < and <
stackexchange-wordpress
{ "answer_score": 3, "question_score": 2, "tags": "plugins, customization, multisite" }
How to get current_cat in navbar, in single post In a site I have using Wordpress 3.0, when I'm in a single post, the navbar showing the categories doesn't give the parent category the class of "current_cat" and therefore that category is not highlighted. How can I make Wordpress give the parent category that class in single_post mode?
I found the answer here. Add to functions.php the following function and hook: function sgr_show_current_cat_on_single($output) { global $post; if( is_single() ) { $categories = wp_get_post_categories($post->ID); foreach( $categories as $catid ) { $cat = get_category($catid); // Find cat-item-ID in the string if(preg_match('#cat-item-' . $cat->cat_ID . '#', $output)) { $output = str_replace('cat-item-'.$cat->cat_ID, 'cat-item-'.$cat->cat_ID . ' current-cat', $output); } } } return $output; } add_filter('wp_list_categories', 'sgr_show_current_cat_on_single');
stackexchange-wordpress
{ "answer_score": 5, "question_score": 6, "tags": "customization, categories" }
How do I add my own custom shortcodes? I'm looking to reuse some small portions of html inside several pages/post but I don't know how to obtain this on WordPress. It would be nice if I could have a helper in the editor to include them, but this is only a nice to have feature, for the moment I need a solution for this.
So far I found the Shortcoder plugin that allows me to add 20 shortcodes. For the moment this is enough and I hope the developer will solve this limiation soon. For some reason this plugin does not appear when I search by its name on Wordpress website. Also, I'm open to accept new suggestions/alternatives.
stackexchange-wordpress
{ "answer_score": 1, "question_score": 2, "tags": "shortcode" }
Applying roles to an admin sub-menu (eg Appearance -> Menus) Long time lurker, but first time poster. I've searched Google extensively and just can't seem to come up with an answer on this problem. I use Justin Tadlock's excellent 'Members' plugin for roles and permissions on several client installations of WP. I've recently deployed a theme where the client should only have access to the Appearance -> Menus item, but none of the others sub-items in the Appearance menu of the admin. When enabled, the role 'edit_theme_options' enables the user to access 'Themes', 'Widgets', and 'Menus'. How would I go about filtering the submenu so that if the role 'edit_custom_menus' is assigned, the 'Menus' link will show?
Upon further searching and after discovering the $submenu global variable, I've managed to find a helpful tutorial on removing sub-menus from the WordPress admin. I'll post with code when I get a full solution implemented and integrated with the plugin.
stackexchange-wordpress
{ "answer_score": 1, "question_score": 1, "tags": "permissions, capabilities, user roles" }
How often does the RSS widget get updates? I am asking since I am trying to understand if this widget is causing my server to overuse CPU or memory. But either way - it's interesting to know.
RSS widget uses `fetch_feed()` function, which is setting default cache lifetime to 43200 seconds (12 hours). Since this value is filtered it can be overridden (as can feed cache overall). I did encounter plugin once, whose developer citing _performance reasons_ completely disabled feed caching for all feeds.
stackexchange-wordpress
{ "answer_score": 2, "question_score": 1, "tags": "rss, memory, widgets" }
What is the "Advanced" $context in add_meta_box? In the codex it lists the parameter $context for the add_meta_box as having the following options: 1. normal 2. advanced 3. side What does "advanced" do? I don't see any difference between it and "normal".
The difference between normal and advanced is that normal will be placed on the page before advanced. For example the following will display "One" before "Two" function admin_init_test() { add_meta_box('one', __('One'), 'test_one', 'post', 'advanced'); add_meta_box('two', __('Two'), 'test_two', 'post', 'normal'); } add_action('admin_init', 'admin_init_test'); function test_two() { echo "<p>test_two</p>"; } function test_one() { echo "<p>test_one</p>"; } If you switch the context parameter around, then "Two" will display before "One" on the edit page: add_meta_box('one', __('One'), 'test_one', 'post', 'normal'); add_meta_box('two', __('Two'), 'test_two', 'post', 'advanced'); Also if you reorder the meta boxes yourself by dragging them around then that order is saved and seems to take precedence over the 'normal' and 'advanced' contexts.
stackexchange-wordpress
{ "answer_score": 16, "question_score": 12, "tags": "metabox" }
Prompting for review / reapproval of page content I have a fair amount of content in wordpress pages that gradually gets out of date over time. I can have an 'offline' process to set reminders in my calendar to remind me to review particular pages and bring them up to date. However I was wondering if there is a way (with a plugin perhaps) to have WordPress put the pages into a 'needs review' state a certain amount of time after it was last edited. This would keep the page live, but prompts me to review the content.
I tend to look for simple solutions so my suggestion is to query pages, sort by modified day and display in Dashboard widget. add_action( 'wp_dashboard_setup', 'add_old_pages_widget' ); function add_old_pages_widget() { wp_add_dashboard_widget( 'oldpages', 'Oldest Pages', 'old_pages' ); } function old_pages() { $pages = get_pages( array( 'sort_column' => 'post_modified' ) ); echo '<ul>'; foreach ( $pages as $page) { $edited = human_time_diff( strtotime($page->post_modified) ); $link = get_edit_post_link( $page->ID ); echo "<li><a href='{$link}'>{$page->post_title}</a> ( edited {$edited} ago )</li>"; } echo '</ul>'; } Can be modified to hide if no pages old enough, etc, etc.
stackexchange-wordpress
{ "answer_score": 1, "question_score": 0, "tags": "pages" }
Allowing a user to write a post from another website? The idea here is to have a site (any site) which somehow has the user's WordPress user-name and login (maybe as part of a sister site) to allow him to write a post on his own blog. The idea I have now is basically a simple form sent (perhaps with curl or socket) to the user's blog admin_ajax.php, even though it is strictly not an AJAX call. Are there any other methods which I could try or is there something built into WordPress itself already?
WordPress supports XML-RPC protocol for such things. That is how desktop blogging clients work. Alternatively you can try to set it up via post by email.
stackexchange-wordpress
{ "answer_score": 3, "question_score": 2, "tags": "posts" }
setting comments off as default for pages and custom post types? I want to turn the comments off by default with pages and custom post-types Initially I simply used conditionals in the comments display function to avoid displaying the block on these pages, but I need the user to be able to turn the comments back on as required.
From what I understand, you want to set pages and some custom post types to have commenting 'off' by default, while posts will still use the default option (i.e. commenting 'on'). If this is the case, the following function will do it. function default_comments_off( $data ) { if( $data['post_type'] == 'page' && $data['post_status'] == 'auto-draft' ) { $data['comment_status'] = 0; } return $data; } add_filter( 'wp_insert_post_data', 'default_comments_off' );
stackexchange-wordpress
{ "answer_score": 9, "question_score": 21, "tags": "comments" }
My new WordPress plugin version is not showing up in the plugin directory. It's been 4 days what could the problem be? Hi to all I made a wordpress plugin amtythumb post. All previous versions are reflected at worpress SVN within some hours. But this time 5.5 version of my plugin is not being reflected on wordpress plugin site even after 3-4 days. just check wordpress plugin site wordpress.org/extend/plugins/amty-thumb-recent-post/ And SVN for confirmation, < Please let me know what to do...
@articlestack According to the trac revision log you added a new directory under your root with the same name as the plugin. It looks like your whole root directory got copied to the new directory because it contains all the tagged versions and trunk. The plugin bot will not be able to find your newly tagged version unless it's in trunk or the new version is tagged in root/tags. You can fix it by moving 5.5 back into the root tags dir. `my-local-dir/$ svn cp amty-thumb-recent-post/trunk tags/5.5` then delete the extra dir `my-local-dir/$ svn del ampty-thumb-recent-post` and check it back in `my-local-dir/$ svn ci -m "tagging version 5.5"` !alt text
stackexchange-wordpress
{ "answer_score": 5, "question_score": 2, "tags": "plugin development, svn, repository" }
Redirecting traffic from old ".WordPress.com" blog to privately hosted WordPress blog? I've got a blog hosted on .wordpress.com, ie the free version. I'm thinking of re-activating my hosting package so I can have my own WP installation, and therefore have more customisation options open to me etc. I'm getting traffic from search engines, how can I redirect this traffic to my new location? Once I have the new one setup, I would prefer people to view that instead of my old site, what can I do to achieve this, whilst retaining my position in search engines?
Didn't try this myself (self-hosted from the start), but this seems fitting guide for your situation: How to Migrate your Blog from WordPress.com to a Personal Domain ( Digital Inspiration )
stackexchange-wordpress
{ "answer_score": 3, "question_score": 3, "tags": "wordpress.com hosting, seo, migration" }
Many users with strange names register, but don't leave comments. Should I be afraid? Many users with strange names, register on my blog, but don't leave comments. Should I be afraid, that this might be attack of some sort. Maybe someone found some sort of bug in Wordpress which allows to penetrate security? Are there any actions I should take?
Spam bots will always try to register. They basically just input data into any form they can find in hopes it will pull their URL on to your page so they can build trackbacks and score higher in Google rankings. There are a couple of things you can do to prevent this: 1. If you don't need people to register for your site (most don't) just turn off new user registration. 2. Install a captcha plugin for your registration form. It won't catch everything, but it should decrease the number of bogus registrations you're seeing. A good one I've heard of is Sabre. You might also want to read this good article by Lorelle discussing anti-spam techniques with WordPress. It's from 2007, but the tools and tips are still very relevant. First things first, though, would be to delete these bogus users from your database. All they are is clutter ... if they're not real people, they don't need to be there in the first place.
stackexchange-wordpress
{ "answer_score": 5, "question_score": 2, "tags": "customization, user registration, bug tracking" }
Does WP show me if I'm logged in from multiple locations? Does word press show me if I'm logged in in another location? Related: Limiting sessions to one IP at a time
When WordPress logs you in, it creates a cookie on your system to keep you logged in if you want. However, being logged in from another location doesn't have much meaning in this context. When you go back to your WP site, WordPress will check for the existence of this authentication cookie on your system. If it's there and valid, you'll be logged in. If it's missing or invalid, you'll have to log in again. However, WordPress doesn't track if you're logged in on one machine versus another at the same time. You could probably set up a plug-in of some sort to track which users are logged in using sessions or transients ... but this isn't WordPress' default behavior.
stackexchange-wordpress
{ "answer_score": 4, "question_score": 0, "tags": "security, login, ip" }
Privilege escalation bugs in 2.9? Are there any known privilege escalation bugs in WP 2.9 to be careful for?
## There are no known security vulnerabilities in 2.9.2 If any new vulnerabilities are discovered the fix will be packported. (This has not happened but if it did we would get a version 2.9.3) WordPress does not have a backport policy that goes further than the previous major release so it is unknown when the 2.9 branch will stop being supported. WordPress does not maintain lts versions. Matt likes to call them Long Term Suckage and most in the community agree that there is really no reason to keep running out dated versions.
stackexchange-wordpress
{ "answer_score": 2, "question_score": 0, "tags": "security, permissions" }
Including CSS and JS on Admin Screen of Custom Theme Options I am creating a custom theme with a theme options page. I would like to style the options page and do not want to include inline styles. Is there any way to include an external stylesheet from say TEMPLATEPATH . '/css/admin.css' I have also found this chunk of code and it seems to work - link function admin_register_head() { $siteurl = get_option('siteurl'); $url = $siteurl . '/wp-content/plugins/' . basename(dirname(__FILE__)) . '/yourstyle.css'; echo "<link rel='stylesheet' type='text/css' href='$url' />\n"; } add_action('admin_head', 'admin_register_head'); What is the best way?
If you create an admin theme plugin from the Codex steps, you will notice it says not to insert stylesheets as per above - although the above will work. If you place the following inside your admin theme file, it will serve the same purpose, but uses the wp_enqueue_styles approach: function add_admin_theme_styles() { wp_register_style($handle = 'mytheme-theme-admin-styles', $src = plugins_url('wp-admin.css', __FILE__), $deps = array(), $ver = '1.0.0', $media = 'all'); wp_enqueue_style('mytheme-theme-admin-styles');} add_action('admin_print_styles', 'add_admin_theme_styles');
stackexchange-wordpress
{ "answer_score": 3, "question_score": 4, "tags": "theme development, admin" }
Importing media medium setting image gallery / image attachments I have recently imported an image gallery to a clean WP install as I am deploying the site to a live domain. I have imported the posts but the images use the medium size for attachements. I would like to get these all to revert to the settings I had set up in the development install. Does anyone have a idea on how to change the size on already imported image attachements? Thanks in advance, J
You can use this plugin: <
stackexchange-wordpress
{ "answer_score": 3, "question_score": 2, "tags": "customization, attachments, import, images" }
How do I read the value of a custom field of the page? When creating custom page templates, how do I get the value of a custom field of the displayed page?
Use the get_post_meta function.
stackexchange-wordpress
{ "answer_score": 2, "question_score": 2, "tags": "custom field, customization, page template" }
Any official way to create an admin theme? I was wondering whether there's a common way of customising the aspect of the admin panel. I know you can play with the css and js files but what I was looking for is some kind of "admin theme" like with drupal. I´m asking so that you can personalize the admin panel while keeping your WP easily updateable. Thanks in advance.
There is currently no way to create admin themes like Drupal. Here are some tips which cover most of the basic admin panel customization needs: <
stackexchange-wordpress
{ "answer_score": 4, "question_score": 5, "tags": "themes, theme development, menus, customization, admin" }
Is there a way to limit the number of top level items in a custom menu? I wish to implement the wordpress 3 menus API in a client site, but the designs has restraint on the width of the top level menu items. How can I be sure the client won't exceed that limit?
The easiest way to accomplish this would be to filter `wp_nav_menu_items` or more precisely `wp_nav_menu_{$menu->slug}_items` and cut extra items from output. It would probably me more pretty and proper to limit/warn user in admin area, but at moment I have no remote idea where to start with that. I should learn up on admin side some time. :)
stackexchange-wordpress
{ "answer_score": 2, "question_score": 4, "tags": "menus" }
How do you enqueue a Visual Basic script using wp_enqueue_script? Internet Explorer will have errors with VB script files en-queued using wp_enqueue_script. This is probably because the output of enqueue script set the script type to 'language/javascript'. Are there any solutions besides manually including the VB script with the theme?
`WP_Script` always adds `text/javascript` to the `<script>` tag, and applies no filter before it returns, there is not much you can do there. You could try to create a subclass of `WP_Scripts` that has this functionality. If you change the global `$wp_scripts` to your new class, this _might_ work.
stackexchange-wordpress
{ "answer_score": 2, "question_score": 1, "tags": "wp enqueue script" }
Removing the number in a category slug I have a category that ends with -2, and there's no way I can change it back to the plain word. I know there are problems with numeric slugs, but this is just a word. I also know that a common answer is to look in the trash, but there's no trash for categories as far as I'm aware
You probably have a tag with the same slug. You can't have any taxonomies with duplicate slugs. Either delete that other taxonomy, rename/change its slug, or change/rename this category. EDIT Ok, it turns out you can do this, if you don't mind programming the fix or directly executing the SQL or messing with PHPMyAdmin. What you need to do is add a new row in `wp_term_taxonomy` that uses the term with the slug you want to use as the `term_id` and the new taxonomy (category in this case) as the `taxonomy`. This is necessary because, if the slug already exists, WP creates a new term rather than using the same term with a different term_taxonomy relationship.
stackexchange-wordpress
{ "answer_score": 5, "question_score": 2, "tags": "categories, slug" }
Using WP rather than .htaccess to redirect pages/posts I run a site with over 100 specific redirects in the htaccess for legacy html files that were subsequently brought into WP. There are also rules for pages within a date range to redirect to the home page, and all sorts of other nasties. Given that WP handles redirects and permalinks internally, and without using a plugin, what would be the best way to programatically redirect these links and keep my .htaccess file clean?
The best way to "programatically redirect these links and keep [your] .htaccess file clean" would actually be with a plugin. I know you stated "without using a plugin," but you'll get the same functionality from a plugin that you would if you wrote the code yourself. And, considering how non-user-friendly the WP rewrite scripts are, I _strongly_ suggest you don't try to write it yourself (I'm an experienced WP developer and I still have trouble with the clanky rewrite engine). So if you're willing to go with a plugin, I recommend Redirection. Redirection has a very intuitive UI that allows you to create, display, and manipulate all of your custom redirects. It also keeps track of any 404 errors your site generates by mistake. I use Redirection on my site to redirect legacy links from my ancient static site to the new dynamic WordPress links. I've also used it on several client sites after helping them migrate to WordPress.
stackexchange-wordpress
{ "answer_score": 3, "question_score": 2, "tags": "permalinks, url rewriting, redirect, htaccess" }
Double thumbnails? is it possible to use the thumbnail mechanic twice? I find the thumbnail API really useful for allowing users to place in there own graphics, so that I can control size and position easily. All they have to do is remember to click featured image. I would like two such mechanisms on my page, any idea how I could do this? Preferably hand coding.
Checkout the multiple post thumbnails plugin. It will allow you to define multiple post thumbnails for specific post types.
stackexchange-wordpress
{ "answer_score": 2, "question_score": 3, "tags": "images, post thumbnails" }
Unable to upload/install any WordPress themes I have a version 3 installation of wordpress on my hosting package that I installed myself Everything else so far seems ok such as posting etc, but I'm unable to install any new themes I have tried to install a theme from clicking one of the "featured" themes, and have tried to upload a ZIP from the wordpress themes website, but each time it just hangs on "Unpacking" or "downloading" and nothing ever happens, I don't get any errors I've noticed that under `/wp-content/uploads` I can see a zip I select for upload, its filesize seems ok Any ideas?
This problem most notably occurs on systems running PHP4. If you can, upgrade your server to PHP5 (if you're on a hosted server, there's usually a setting in cPanel or whatever administrative tool you have to switch from PHP4 to PHP5).
stackexchange-wordpress
{ "answer_score": 6, "question_score": 0, "tags": "themes" }
How to get the "stats" plugin that comes with a .wordpress.com blog? On the free version of wordpress, ie the one you setup for free and get hosted at "myblog.wordpress.com", it has a very nice module on the dashboard for tracking statistics. It displays a nice hit-counter graph and shows search engine terms used etc, without any clutter Is it possible to get this for a self hosted install of wordpress? I can't see it installed by default
Not installed by default, but available as plugin from repository: WordPress.com Stats
stackexchange-wordpress
{ "answer_score": 3, "question_score": 1, "tags": "plugins, statistics" }
Strategy to get post meta for use outside the loop I need to know solutions for the question above. There are cases, when we need post meta information outside the loop. Let's say, I'm developing theme that will display ads from certain vendor on that page (everywhere on that particular page) based on post meta information. Because, I've bilingual blog and I will use different vendor for each language (for CTR reason). So, do you guys have a solutions for this kind of problem?
Do you mean meta like in custom fields or information from post in general? Basically as long as you have post id you can get anything you want, not tied to the Loop. For custom fields there is `get_post_meta()`. For general information (like title or content) there is number of functions (many template tags can be explicitly passed post id, they just default to current Loop item) and there is `get_post_field($field, $post);` (can't find in documentation, but self-explaining).
stackexchange-wordpress
{ "answer_score": 2, "question_score": 4, "tags": "theme development, loop, post meta" }
Changing attachment urls? How can I change the format of attachment page urls from `/[post-url]/[attachment-name]/` to `/media/[attachment-name]/`? I understand that I can override the output of `get_attachment_link` via the `attachment_link` filter, but I guess I need to change the redirect structure so WordPress knows how to handle these urls?
You can do the following: /* add new rewrite rule */ function attachment_rewrite( $wp_rewrite ) { $rule = array( 'media/(.+)' => 'index.php?attachment=' . $wp_rewrite->preg_index(1) ); $wp_rewrite->rules = $rule + $wp_rewrite->rules; } add_filter( 'generate_rewrite_rules', 'attachment_rewrite' ); /* redirect standard wordpress attachments urls to new format */ function redirect_old_attachment() { global $wp; if( !preg_match( '/^media\/(.*)/', $wp->request ) && isset( $wp->query_vars['attachment'] ) ) { wp_redirect( site_url( '/media/' . $wp->query_vars['attachment'] ) , 301 ); } } add_filter( 'template_redirect', 'redirect_old_attachment' );
stackexchange-wordpress
{ "answer_score": 7, "question_score": 6, "tags": "attachments, redirect, urls" }
Making the Post/Page Content Editor Box Bigger? I'm having difficulty in creating a big post since the editor box is quite small. I want to make it bigger. Can I?
You have a couple of options. First, you can always click on the bottom right corner of the post edit box and drag to resize: !alt text However, you can also make it so that the post box is larger by default. Go to Settings > Writing, and change the value for size of the post box: !alt text
stackexchange-wordpress
{ "answer_score": 8, "question_score": 2, "tags": "editor" }
Code markup plugin like the .wordpress.com blogs offer? The free wordpress blogs (those hosted at wordpress.com) have a build in code formatting plugin Is it possible to get this on private installs of wordpress? I've copied all my posts across but the code formatting feature doesn't work out of the box I'm primarily looking for Java syntax highlighting
This is the plugin used on WordPress.com: <
stackexchange-wordpress
{ "answer_score": 3, "question_score": 3, "tags": "plugins" }
i want multiple blog, themes and database i am running < I want to create a separate blog say help.article-stack.com. Again, it should have 2 portion. One for discussion and another for information. I am planning to install wordpress in 2 more direcotries. Both will have separate database. Tell me is you have some better solution It will be helpful if you can suggest me some free theme for discussion. I am aware with twitter like theme p2. But it is not suitable for me. I want stackexchange type of site. So if someone helps others they must get their credit. It helps to motivate them and others. Thanks in advance
Since version 3.0 capabilities to run multiple site on single installation had been included in WordPress core. See Create A Network in documentation. I have nothing to suggest on theme and I advise to split that part in separate question.
stackexchange-wordpress
{ "answer_score": 1, "question_score": 0, "tags": "themes" }