INSTRUCTION
stringlengths 11
999
| RESPONSE
stringlengths 0
999
| SOURCE
stringlengths 16
38
| METADATA
dict |
---|---|---|---|
User Login System with File Delivery?
I'm wondering if it's possible through a plugin, or otherwise, to allow people to register on my WordPress site for an account. And then through my control panel, I can manage their accounts. Here's a little backstory of what I'm trying to accomplish.
My client runs a dance competition. They would like to be able to upload audio critiques, videos and media. And they'd like to be able to deliver that content just to specific accounts. For instance, a mother goes to the site and registers an account. She logs in and is able to get media related to her son or daughter from a control panel that my client uploaded specifically for them.
Is this within the realm of possibility in WordPress? Does a solution already exist? And if not, if anyone could suggest a workaround that would be great.
Any help would be greatly appreciated. Thanks! | you can achieve this very easily with simple using my plugin **User Specific Content** which lets you display specific content per user name, user id or by user role. | stackexchange-wordpress | {
"answer_score": 1,
"question_score": 1,
"tags": "login"
} |
Recommendation for a Dynamic Table Plugin
Can anyone recommend plugin that I can use to add a table to a page? I've seen ones that use static data-- you hardcode the figures in the table. I want to pull the data from a custom db table and put it in a table.
I looked at WP Table Reloaded, but I'm not sure whether, it's possible to use it with dynamic data.
Any suggestions?
Thank you. | Set up a custom page template and in the content of the template use WPDB to query your table.
Example to get a row:
$mylink = $wpdb->get_row("SELECT * FROM $wpdb->links WHERE link_id = 10"); | stackexchange-wordpress | {
"answer_score": 2,
"question_score": -1,
"tags": "plugin recommendation, pages"
} |
Customize category query in widget
I would like to exclude a category from my categories sidebar widget. If I understand the way this works, the sidebar.php code is not in use since the widget is displaying the categories. (something similar was discussed in this support topic: < ).
How can I modify the query used by the widget; or is there another means of excluding specific categories from inclusion in the category list? | I'll answer my own question so that the results are in the discussion thread.
All of the suggestions I've seen don't seem to work with the current version of WordPress (3.2). There are some widgets which will execute PHP script directly, used in conjunction with the correct query, this qualifies as a solution.
Plugins with PHP capability:
* PHP Code Widget <
* Exec-PHP <
I used PHP Code Widget myself.
The query:
<?php wp_list_categories('show_count=1&exclude=12,24&title_li='); ?>
(or similar).
You still need to lookup the value of the category or categories to exclude; in this case, I excluded categories 12 and 24 | stackexchange-wordpress | {
"answer_score": 0,
"question_score": 0,
"tags": "categories, widgets, exclude"
} |
How *not* to show the last post on the latest posts list
An image speaks for a thousand words so please bear with me: <
The last post appears twice. Once as the feature post and then again on the "main blog part" where the ten or so latest posts appear. Is there a way to make it not appear again?
Thanks :) | Go to the code of "Main blog part", loop.php i guess... or any code your theme uses..
Find get_posts and use exclude parameter to exclude the post from there. Pass id of featured post as exclude...
Here is reference...
< | stackexchange-wordpress | {
"answer_score": 0,
"question_score": 0,
"tags": "posts, php, functions"
} |
Active Menu Highlighter with Subpages?
my question is...
* * *
I have 2 pages & 2 subpages in each page. like:
page1
\-->subpage1
\-->subpage2
page2
\-->subpage1
\-->subpage2
& my Menu is **Page1 page2**
Now if i select subpage1(from page1) means the page1 need to active and highlight the menu. if i select subpage1(from page2) means it need to highlight page2 and page2 menu in active.
how to do this? please help me to get rid of this problem.i need to implement in my wordpress website. | To highlight page 1 and page 2 use `current-menu-parent` class | stackexchange-wordpress | {
"answer_score": 4,
"question_score": 0,
"tags": "menus, headers, child pages"
} |
Initialize WordPress environment to use in a real cron script
I have to run a PHP script through real cron (WP cron being too unreliable). Within that script, I need $wpdb to insert data into WordPress table. But of course $wpdb will not be available as WordPress would not be initialized. Right? So, my question is how to 'include' WordPress/initialize WordPress environment to do such tasks? How about require_once("wp-load.php")? | You can use real cron to trigger WP cron - by fetching `wp-cron.php` file from root (snippet from quick google search).
That will take care of environment and everything. | stackexchange-wordpress | {
"answer_score": 3,
"question_score": 3,
"tags": "php, cron, wp cron, wp load.php, command line"
} |
wordpress custom login successful redirect hook
I am using a custom login form imported on my theme's home page through jqModal. In that, when i successfully login it redirects to the same page. I want to redirect based on the logged in user role.
I will prefer a response with some editing in my functions.php or adding a mini plugin. Because I dont want wordpress original files to be edited for future updating hassles. | I used Theme My Login Plugin and modified its templates as per my requirements. I think its the best plugin as per my requirements were concerned. You may check yours.
Also if you want to see the working inside the code, this plugin coding approach is nice and adaptive. | stackexchange-wordpress | {
"answer_score": 0,
"question_score": 2,
"tags": "plugins, functions, redirect, login, user roles"
} |
User management system similar to wordpress one?
I am in very big need of a user management system just like the one that wordpress uses but without being blog related. I need to be able to manage users and apply certain privileges depending on user level. I tried to take apart the WP engine and take out the users part but I think it's so tied to the whole engine, I wasn't able to... Does anyone know of any scripts that offer the same register, login etc functions? Also, could it be open source? I already bought my first user management system but it sucks really bad... :(
Thanks in advance to anyone willing to help me.
Andy | you can still use WordPress and disable the front end functionality, or like @OneTrickPony suggested you can try **BackPress** which is a PHP library of core functionality for web applications that grew out of WordPress. | stackexchange-wordpress | {
"answer_score": 1,
"question_score": 1,
"tags": "php, users, mysql, login, user registration"
} |
Using the Settings API, how should I add multiple values to an option?
I'm trying to add/ update additional values to an option created with the Settings API. I'm trying to do this with my validation callback function, but I'm not getting very far. Here is my code:
function tccl_settings_option_validate( $input ) {
add_option( 'tccl_settings_option', $input );
}
This is causing a pretty big error. How should I be doing this?
What I would like to do is use the validation callback to add values to the option array without overwriting it. | Get the option, modify only the values you need to modify in it, then return the results.
function tccl_settings_option_validate( $input ) {
$options = get_option('tccl_settings_option');
// modify $options using data from $input as needed
return $options;
} | stackexchange-wordpress | {
"answer_score": 2,
"question_score": 1,
"tags": "plugin development, settings api"
} |
Update Wordpress with SFTP instead of FTP
Is there a way to update Wordpress without the use of FTP, but with SFTP (which uses SSH)? I've only got my server set up for SSH access (and therefore SCP/SFTP). | Configuration instructions in Codex on Enabling SSH Upgrade Access recommend either:
1. Using SSH SFTP Updater Support plugin from official repository.
2. Using built–in SSH2 support, which requires the PECL SSH2 extension installed on the server.
It used to refer to this tutorial: Using SSH to Install/Upgrade in before, which might be of use. | stackexchange-wordpress | {
"answer_score": 12,
"question_score": 9,
"tags": "upgrade, updates"
} |
How to make a second query offset -2 from current post
I would like a second `WP_Query` on a custom post type's single page to return 5 posts, starting with two before the current post, so that I get this:
1. The-one-before-the-previous post
2. Previous post
3. Current post
4. Next post
5. The-one-after-the-next post
How can I do this? `offset` is only good if I know the number of the current post.
In pseudo-code it's easy:
$gallery = new WP_Query(array(
'post_type' => 'artwork',
'posts_per_page' => 5,
'fake-offset' => $current->ID-2 //This is imaginary
));
Thanks in advance! | Instead of using the `offset` parameter, take a look at the `post_where` filter examples under the Time Parameters section of WP_Query codex page. You could just add a filter that returns posts that are less than the current post's date. | stackexchange-wordpress | {
"answer_score": 0,
"question_score": 1,
"tags": "wp query, loop"
} |
Better way to exclude category output for post/pages?
I always assumed there was a way to exclude certain categories from being output in the loop using `get_the_category`, `the_category`, or one of the `term` related functions. After looking around it seems like the only way is to grab the array and just remove them by ID or name.
For instance this is what I am using:
<?php // exclude category ID 12 as an example.
foreach((get_the_category()) as $cat) {
if (!($cat->cat_ID =='12'))
echo '<a href="' . get_bloginfo('url') . '/category/'
. $cat->category_nicename . '/">'. ' | ' . $cat->cat_name . '</a>';
}
?>
This looks kinda messy due to having a somewhat "hard-coded url" using `/category/` ( I know I can also change this but it still seems counter intuitive).
Is there no better way to exclude categories? | If the URL being "hard-coded" is the problem you can use **`get_category_link`**
foreach((get_the_category()) as $cat) {
if ($cat->cat_ID !='12')
echo '<a href="'.get_category_link($cat->cat_ID).'"> | ' . $cat->cat_name . '</a>';
} | stackexchange-wordpress | {
"answer_score": 1,
"question_score": 0,
"tags": "exclude, categories"
} |
Custom routing for plugins
I am making a plugin that needs a page that can be accessed from the outside, pretty much like an API, and have the url like so,
is there a clean way to do this?
Thanks in advance. | The WordPress Way of doing it is using `query_vars` so first you add you vars to the array:
//add to query vars
function add_query_vars($vars) {
$new_vars = array('custom_method','cm_parameter');
$vars = $new_vars + $vars;
return $vars;
}
add_filter('query_vars', 'add_query_vars');
then you can check in your plugin for the vars:
global $wp;
if (array_key_exists('custom_method', $wp->query_vars) && isset($wp->query_vars['custom_method'])){
//do your stuff
} | stackexchange-wordpress | {
"answer_score": 3,
"question_score": 2,
"tags": "plugins, api, routing"
} |
WordPress as a backend only. How to output database content on public side without WordPress?
I'm a bit of a PHP MySQL newb but i feel i need to bypass WordPress for the frontend of a site i'm building (it is mainly just RSS and JSON feeds). I was wondering if there are any tutorials or advice I should follow on this or just cut straight to it? | You want to include `wp-load.php` at the beginning of your script/page like this :
require_once("/path/to/wordpress/wp-load.php");
You then have access to any WP functions. To manipulate the DB directly, have a look at `wpdb`. | stackexchange-wordpress | {
"answer_score": 4,
"question_score": 3,
"tags": "php, front end"
} |
Wordpress Ecommerce Chase Paymentech Integration
Just wondering, If any body have integrated Chase Paymentech Payment Gateway with WordPress for Shopping Cart purpose? | The best source for information on this is the getshopped.org/forums/ forums. It appears that there are a couple of posts regarding this gateway in the forums, but the forums appear down at the moment.
Also, getshopped.org maintains a directory of developers that can help you develop a new payment gateway. These gateways are relatively simple to build (I'm working on one right now) depending on the complexity of the merchant API.
There's no reason that the gateway cannot be build; it's just a matter of finding someone to do it. And, I do not believe that the gateway you are looking for currently exists. | stackexchange-wordpress | {
"answer_score": 1,
"question_score": 1,
"tags": "plugins"
} |
How can I add comments to a page?
How can I allow people to post comments on a page?
I've put this into my page template: `<?php comments_template(); ?>` but it just says at the bottom of my page "Comments closed".
UPDATE: If I can allow comments for one specific template for a page that would be great. | Have you checked under **_Admin -> Settings -> Discussion_** and for individual pages, under **pages** and **quick-edit** or the **discussion** area in **edit page** below the page editor?
When the last one does not show, click **screen options** near the top right, and tick **discussion** there, then scroll back down. | stackexchange-wordpress | {
"answer_score": 10,
"question_score": 4,
"tags": "comments"
} |
Search Results not displaying for multiple word search
I've customized a theme and am having some problems with search results using multiple-word queries. Site is live at www.abetterworldbydesign.com
Searching for a single word works as expected.
Searching for multiple words that should have returned results shows blank results.
Oddly enough, manually changing the "+" character in the URL to "&" displays the results correctly but only shows the first word in the header "Search results for:_".
My code in search.php for initializing WP_Query follows exactly the code listed in the codex. Full code for search.php on pastebin.
Code for searchform.php below.
<form id="searchform" name="searchform" method="get" action="<?php echo home_url(); ?>">
<div>
<input type="text" id="s" name="s" />
<input type="submit" id="searchsubmit" value="<?php esc_attr_e( 'Search', 'richwp' ); ?>" />
</div>
</form> | Answer from Richard M on the question originally asked on StackOverflow:
Replacing line 21 on search.php with `$search_query[$query_split[0]] = urldecode($query_split[1])` resolved it. | stackexchange-wordpress | {
"answer_score": 0,
"question_score": 0,
"tags": "theme development, search"
} |
Pagination Not Working When Modifying Loop Based on Post Category
I have added query_posts() to my index.php file to modify the loop on the posts page:
query_posts( 'cat=-4,-7' );
get_template_part( 'loop', 'index' );
This works correctly, but when I click on "Older Posts" (link to /page/2), the latest posts show up instead of the previous ones. How can I get my pagination to show the correct posts? | different approach:
global $wp_query;
$args = array_merge( $wp_query->query, array( 'category__not_in' => array(4,7) ) );
query_posts( $args );
get_template_part( 'loop', 'index' );
if this approach should not work, please check if one or more of the plugins is interfering - deactivate all plugins; if the exclusion of categories works then, re-activate one plugin at a time to find the interfering plugin. | stackexchange-wordpress | {
"answer_score": 2,
"question_score": 0,
"tags": "pagination, loop"
} |
Overriding functions in wordpress plugins
I notice that in some plugins you can override functions by ...
1. Creating an uploads folder
2. Creating a folder with the plugin name
3. Using the following code
if (!function_exists('function_name')) {
function function_name() {
}
}
Is this standard for all Wordpress plugins or only if they're written in a specific way? | If the plugin displays content via any function, the code:
if(!function_exists('function_name')) function_name();
... is used for safety.
If your plugin is disabled, and the `if (!function_exists('function_name'))` is missing, your theme will throw a fatal error. | stackexchange-wordpress | {
"answer_score": 1,
"question_score": 1,
"tags": "plugins, pluggable"
} |
Updating servers at once in web cluster
We have a pretty basic load balancing setup with 3 web servers behind a load balancer connected to the same db server and pointing their wp-content/uploads folder to an nfs share.
We have the first server rsynching the wordpress files across the other 2 in a cron job to keep the servers in sync (all wp-admin stuff is done on the first server)
I'm wondering what the best way is to upgrade the entire cluster at once with minimal downtime. If I update wordpress on the first server, will the db versioning cause the other 2 servers to stop working? Or can I just update the first server then rsync the files across without any downtime? | I don't think the database schema ever changes so drastically that the versions of wordpress on box 2 + 3 would be prevented from reading from the DB after you've updated on box 1, however it depends what version you are upgrading from.
Why not set a similar environment locally and test upgrading site 1, while still trying to visit site 2. | stackexchange-wordpress | {
"answer_score": 1,
"question_score": 2,
"tags": "upgrade, server"
} |
Hook the Keydown Event in the TinyMCE Post Editor
I would like to hook the keydown event in the TinyMCE Editor on the edit post admin page. I managed to hook the HTML content editor using the following code:
jQuery('#content').keydown(function(){
alert("keydown")
});
Here is my failed attempt at hooking the TinyMCE editor. The problem is that the editor hasn't been init yet so the variable ed is undefined.
var ed = tinyMCE.getInstanceById('tinymce');
ed.onChange.add(function(ed, l) {
alert("keydown");
});
Any help would be much appreciated! | the TinyMCE Editor has its own keydown event handler and its hooked to a function on initiation so to do that you can create a tinymce plugin or use the wordpress initiation of it with `tiny_mce_before_init` hook like this:
add_filter( 'tiny_mce_before_init', 'wpse24113_tiny_mce_before_init' );
function wpse24113_tiny_mce_before_init( $initArray )
{
$initArray['setup'] = <<<JS
[function(ed) {
ed.onKeyDown.add(function(ed, e) {
//your function goes here
console.debug('Key down event: ' + e.keyCode);
});
}][0]
JS;
return $initArray;
} | stackexchange-wordpress | {
"answer_score": 8,
"question_score": 4,
"tags": "plugin development, wp admin, jquery, javascript, tinymce"
} |
Publication Workflow
I am looking into having the two following roles:
1. Editor
2. Publisher
and the following different states a post can be in:
1. Draft
2. Ready for publication
3. Published
The workflow I am seeking is:
1. An **editor** writes a blogpost. It is a **draft**.
2. Once it is final, the editor marks ist as **ready for publication**. From that moment on, the editor **looses the ability to edit the blogpost**.
3. The **publisher** reviews, edits and **publishes the blogpost**.
Is this possible with Wordpress?
If not, is there a state of the art plugin for such a workflow?
It seems like an obvious workflow. | Allow me to translate the roles and states into WP parlance:
Roles:
1. Editor -> Author
2. Publisher -> Editor
States:
1. Draft -> Draft
2. Ready for publication -> Pending Review
3. Published -> Published
The only thing you need a plugin for is this bit:
"From that moment on, the _author_ looses the ability to edit the blogpost." | stackexchange-wordpress | {
"answer_score": 2,
"question_score": 1,
"tags": "workflow"
} |
Wordpress tables and aliases?
I have imported some tables from my online wordpress database to my local to work on.
However now I am getting some weird sql errors that I don't get online.
I can see that the code of the plugin I am working on has some references (aliases?) that don't appear to reference anything that I see when I do a search:
$result = $wpdb->get_row( 'SELECT re.*
FROM ' . EVENT_ESPRESSO_RECURRENCE_TABLE . ' re
INNER JOIN ' . EVENTS_DETAIL_TABLE . ' ed
ON re.recurrence_id = ed.recurrence_id
WHERE re.recurrence_id = ' . $recurrence_id .
' ORDER BY ed.start_date ASC
LIMIT 1', ARRAY_A );
What is table 're'? In re.recurrence_id? | 're' is the alias you give to EVENT_ESPRESSO_RECURRENCE_TABLE.
The error you're seeing is probably because the EVENT_ESPRESSO_RECURRENCE_TABLE constant isn't defined.
Do a `var_dump( $wpdb->last_query )` just below that code to see the final SQL statement. | stackexchange-wordpress | {
"answer_score": 2,
"question_score": 0,
"tags": "mysql"
} |
Wordpress Tiny MCE won't accept line breaks
Encountered an infuriating issue where I f i want to add multiple linebreaks
for layout between paragraphs, Wordpress doesn't recognize them in th wysiwig editor. If I enter them in the code window, and publish they DO save, but the next time the Wysiwig is edited and published those breaks disappear.
is there a workaround or a plugin hat lets Tinymce handle this better? | I use TinyMce Advanced. In the TinyMce Advanced settings it gives you to the choice to stop removing the line-breaks. You might give it a try. This is the first plug-in I install after adding a WP Website.
Link: < | stackexchange-wordpress | {
"answer_score": 1,
"question_score": 0,
"tags": "tinymce"
} |
I cannot include a file in my plugin settings page
I'm trying to create a settings page. If I print things within index, I can see it. If I try to include it, I can't see anything, neither errors.
add_options_page('My Plugin', 'My Plugin', 'manage_options', 'my-plugin', array('MyPluginSettings', 'index'));
my settings:
class MyPluginSettings
{
public function index()
{
/* I can echo or print here and it works fine ...
* But i can't require a file here ... nothing happens
*/
require('existing/path/to/a/file.php');
}
}
?>
What's wrong? Thanks. | Most likely the file cannot be found, I'm assuming the file you're trying to include is located in your theme folder, in that case you should use:
require_once( TEMPLATEPATH . '/file.php');
`TEMPLATEPATH` will return something like this: `/home/user/httdocs/wp-content/themes/twentyeleven`.
Worst case scenario you'll find a **Fatal Error** , but that'll help to find the problem. | stackexchange-wordpress | {
"answer_score": 1,
"question_score": 0,
"tags": "plugins, plugin development, wp admin, menus, actions"
} |
Alternate stylesheet only works with absolute address for link?
I am trying to add a stylesheet when users are accessing the blog section of my site from and iPad. The first snippet of code works, however, I don't want to use the absolute path. I want to use wordpress's function.
function ipad_css() {
if( preg_match('/ipad/i',$_SERVER['HTTP_USER_AGENT'])) {?>
<link rel="stylesheet" type="text/css" href=" media="screen" />
<?php }
}
add_action('init','ipad_css');
This doesn't seem to work:
function ipad_css() {
if( preg_match('/ipad/i',$_SERVER['HTTP_USER_AGENT'])) {?>
<link rel="stylesheet" type="text/css" href="<?php bloginfo('template_directory'); ?>/ipad.css" media="screen" />
<?php }
}
add_action('init','ipad_css');
I'm confused as to why it won't work. I have trying `stylesheet_url` as well with no luck. | Try replacing `<?php bloginfo('template_directory'); ?>` with `<?php echo get_template_directory_uri(); ?>`
Also, I wouldn't hook it to the `init`action, why don't use `wp_print_styles` instead? **It is** a style after all. | stackexchange-wordpress | {
"answer_score": 3,
"question_score": 0,
"tags": "css"
} |
Rewrite database urls
Is there a query I can run on my wordpress database so that I can change all instances of
www.mydomain.com
to
localhost/mylocalsite.com? | Try this plugin: < \- It helped me dozens of times.
Or try this query:
UPDATE tablename SET tablefield = replace(tablefield, "findstring", "replacestring");
Or try this method, dump the database, open the SQL file, do a find and replace in a text editor then reimport it.
Take care to backup your database prior to making any operations and changes! | stackexchange-wordpress | {
"answer_score": 4,
"question_score": 1,
"tags": "mysql"
} |
How to exclude my home page from url of my internal pages?
I just definsed at Setting> Reading a page I have created called "home" as my homepage. The change was ok, but since them all my internal pages url shows an extra /home/in their urls.
How can I avoid it?
Examples:
Before: www.mydomain/internalpage/
After the change: www.mydomain* _/home/_ *internalpage/ | What @iampearce said is basically right, but to be a bit more specific: look in Settings > Pewrmalinks. Choose one of the defaults - maybe %year%/%postname% - and click Save. Does that help?
If that doesn't fix it, look in Settings > Reading and check that the "front page" and the "posts page" are not set to the same page via the dropdowns there. If you want your front page (home page) to be the blog page, just choose "Your Latest Posts".
Best of luck! | stackexchange-wordpress | {
"answer_score": 0,
"question_score": 0,
"tags": "url rewriting, urls, options, homepage"
} |
How should I best incorporate WordPress in my static website?
My site as of right now is a static website. I am planning on having a 'recent blog posts' section on it, with permalink to the main blog post/blog. example:
I was wondering, because of having a recent blog posts section on the homepage, should I just have the entire website powered by WordPress and just add the homepage (and other pages, such as contact) as a word press 'page', and call recent blog posts on it?
If I do it that way, am I still able to have the blog in `/blog`?
I was also thinking of just adding the whole WordPress files to the /blog directory and call recent blog posts from the static file...
I am new to Wordpress, so I am a bit confessed here.
What is the best option? | You can do either, it's up to you depending on how invested in your static site you are and how much work you want to do transferring things over.
The Codex page on Integrating WordPress with your website outlines how you could have WordPress installed in the /blog directory, and show recent posts on your static site through the use of a bit of php.
Your other option is to have WordPress take over serving all of your site's content. It's pretty easy to set up a static home page, plus contact, etc., as well as a blog at whatever url you choose. See the Codex page on WordPress Settings > Reading. You just need to create two pages, then designate one your home page and the other to be the page that shows your posts. | stackexchange-wordpress | {
"answer_score": 1,
"question_score": 1,
"tags": "pages, static website"
} |
Can I output a custom taxonomy as a submenu in the site navigation menu?
I'm building a WP 3.2 site with a couple of custom post types and taxonomies. I'm calling one of these custom post types _programs_ , and its associated taxonomy is called _topics_.
I'd like to add an item called "Topics" in the site's horizontal navigation, with a dropdown submenu that lists all categories in the _topics_ taxonomy. Each submenu item would then link to its respective category archive page.
Is this possible? I assumed this would be pretty easy in WordPress, but I've been searching around for a while to no avail.
**EDIT:** This blog post and plugin come close, but it seems to only apply to blog categories (that is, I don't see how to adapt it for a custom taxonomy). | This is enabled by default if your using `wp_nav_menu` ( the drag & drop menu's in admin) and have also set `show_in_nav_menus` to true for your `register_taxonomy`.
To enable them to show go to Admin-->Appearance-->Menus
Click "Screen Options" in the top right and you should see it listed there.
ps. The post you linked is obsolete. | stackexchange-wordpress | {
"answer_score": 1,
"question_score": 0,
"tags": "custom taxonomy, menus, archives, navigation"
} |
How to order a taxonomy's terms numerically, from lowest to highest using get_terms
I'm using `get_terms` to output a taxonomy's terms, which are all numbers:
For example:
4, 6, 8, 10, 12
How can I order these numerically, so they appear exactly as above?
What I'm getting is actually:
10, 12, 4, 6, 8
I can see why it's done this (thinks 10 is first because it starts with a 1) but how can I fix it?
I've tried all the ordering options on the codex for `get_terms` but can't seem to get them in order. Here's an example of what I have so far. I've even tried ordering by id and entering them in order but it still muddled it up.
$taxonomy_array = get_terms('taxonomy-name', 'hide_empty=0'); | I have a plugin, Custom Taxonomy Sort, that allows you to sort taxonomy terms in any order that you might want. After installing the plugin, there will be an order field for each term. It will save these values as integers and will properly sort your taxonomy terms. By default, it will use the order you specify to sort the terms. It also enables a new value for sort the `orderby` parameter, "custom_sort". You would be able to do something like:
<?php $terms = get_terms('taxonomy', 'orderby=custom_sort'); ?> | stackexchange-wordpress | {
"answer_score": 1,
"question_score": 0,
"tags": "taxonomy, array, terms"
} |
global menus made from master site's custom menus wpmu network
I'm looking into a way to have global menus across my network of blogs. Basically I am using wordpress as a CMS - the purpose of the network is actually to ringfence content. The sub blogs will be able to customise some areas of the template - but I would like them to share the main site's menu system.
This is easy enough for a static consistant menu - but my clients would like to be able to make changes to the menu on the main, top-level site using wordpress' built in custom menu system.
So - in short, can my sub sites in a blog network show the custom menu from my top level site?
Thanks | That's an old question, if someone like me landed on this page for WORDPRESS MULTISITE MENU sharing across all network sites without any plugin,
Not only menu you can use the same method to share anything other then widgets across all the network sites.
here is the solution : Edit your Header.php
//store the current blog_id - Use this function at the start of the function that you want to share
global $blog_id;
$current_blog_id = $blog_id;
//switch to the main blog which will have an id of 1
switch_to_blog(1);
//output the WordPress navigation menu - incase of menu-sharing use this
wp_nav_menu(
//add your arguments here
);
//switch back to the current blog being viewed - before ending of the function
switch_to_blog($current_blog_id); | stackexchange-wordpress | {
"answer_score": 4,
"question_score": 3,
"tags": "customization, menus, multisite"
} |
How to enlarge the media file upload size in wordpress admin
I'm using wordpress 3.0 with buddypress.
I need to enlarge the file size that is being uploaded from the media section in the admin menu.
We have tried many ways including the methods from this link but nothing made it larger than a 1 mega.
Is there a different way to do it?
Thanks | If you are using multisite make sure you set "Max upload file size" to some higher limit.
> Network Admin -> Settings -> Network settings -> Upload settings -> Max upload file size | stackexchange-wordpress | {
"answer_score": 5,
"question_score": 2,
"tags": "php, uploads"
} |
Getting only the most recent bookmark?
So, I was thinking I'd use WordPress' Bookmarks/Links content type to populate a slider...
...Except there are a grand total of four functions interacting with this part of WordPress.
I don't think you can even access these with a WP_Query object, and it seems all date-related data attached to these is in relation to the last update of the link itself (I.e., when the linked-to page is updated).
**Is there any way to even retrieve only the most recently-added bookmark?**
(For more of a semi-related discussion question for the comments -- if this aspect of WP is so woefully underdeveloped 3 versions of the CMS in, why not just farm out this functionality to a plugin? Simply backwards compatibility?) | As far as I know it's not possible to query the links directly, but there is definetly a `link_updated` field in the wp_links table, so you can use `wpdb` to interact with it and return the latest (modified) links.
There's also a solution here.
**EDIT** : Updating a link doesn't change `link_updated`, but here is a plugin that can solve that : Link Updated Plugin
> Auttomatically update the link_updated field when adding or editing a link, so you can use Links as a linklist.
**EDIT 2** : If using the Links/Bookmarks functionality is too much of a hassle, as it seems it's really not as flexible as posts, you could also create a custom post type or a post format for Bookmarks and work with that. | stackexchange-wordpress | {
"answer_score": 1,
"question_score": 2,
"tags": "links, bookmark, get bookmarks"
} |
the_post_thumbnail() Custom sizes not display correctly
I'm trying to display wide image icons from the_post_thumbnail() function. I'm using 'true' value for cropping, but they are not cropped well... I get some strange results with different sizes (I'm trying to use 200width x 150height). If image cannot be display with good proportions (I don't know why whem I'm cropping it? ) then I want it to have exact 150px height always! How can I achieve it? I've been trying with set_post_thumbnail_size() but its even worst... | If the critical dimension is height, you have a couple options:
Hard-cropping to the exact width/height:
<?php
add_image_size( 'wide-image-icon', 200, 150, true );
?>
The hard-crop will create a thumbnail size using the _exact_ dimensions. Be sure that all images have a minimum width/height as what is defined.
Or soft-cropping (i.e. "box-resizing") constrained to height:
<?php
add_image_size( 'wide-image-icon', 9999, 150, false );
?>
The soft-crop with an unconstrained dimension (i.e. `9999` width) will box-resize to the exact _height_ , while allowing the _width_ to be, essentially, anything. Be sure that all images have a minimum height as what is defined.
Also: make sure that, if you have added these `add_image_size()` functions after already uploading/attaching some images, that you **regenerate your thumbnails**. | stackexchange-wordpress | {
"answer_score": 2,
"question_score": 1,
"tags": "post thumbnails"
} |
Conditional Tag Custom Querys?
I think thats what its called...
Basically a conditional statement if there are any posts in a specific custom post type/custom taxonomy, show posts, it not show an img or include whatever…?
But cycle through a few custom post types?
Checking in each if there is a post in the featured custom tax and if not skip on to the next one, ending up if a temp image or something...
So a conditional tag with query i suppose…
if
<?php $loop = new WP_Query( array( 'post_type' => 'profile','profile-type' => 'featured','posts_per_page' => '-1' ) ); ?>
show post details
else if
<?php $loop = new WP_Query( array( 'post_type' => 'films','film-type' => 'featured','posts_per_page' => '-1' ) ); ?>
show post details
etc etc
else
show include or temp image
Can it be done, or asking a bit too much of the technology?
Many thanks for any help :) | You can use the `have_posts` function. For more information, visit The Loop
<?php
$loop1 = new WP_Query( array(
'post_type' => 'profile',
'profile-type' => 'featured',
'posts_per_page' => '-1' ) );
$loop2 = new WP_Query( array(
'post_type' => 'films',
'film-type' => 'featured',
'posts_per_page' => '-1' ) );
if($loop1->have_posts()) {
while($loop1->have_posts()) {
$loop1->the_post();
// content here
}
} elseif($loop2->have_posts()) {
while($loop1->have_posts()) {
$loop1->the_post();
// content here
}
} else {
// content if all else fails
}
?> | stackexchange-wordpress | {
"answer_score": 0,
"question_score": 0,
"tags": "query, conditional tags"
} |
Need to manually regsiter user, send the password and retreive their user ID
I'm writing a custom signup script for users to register with on my MU-setup.
One problem I'm having is that `wpmu_signup_user()` sends the password activation email but it doesn't return the user ID which I need for the rest of the script. - It's my understanding that this doesn't create the user account, just an entry in the "signup" table.
The other way I've tried is using `wp_create_user()` which returns the user ID I need (as it creates the user properly) but no email for the user. | If you want to force add a MU user and activate them, and email them, this will do it. It's a slightly altered version of a piece of the code in user-new.php.
wpmu_signup_user( $new_user_login, $new_user_email, array( 'add_to_blog' => $blogid, 'new_role' => $role ) );
$key = $wpdb->get_var( $wpdb->prepare( "SELECT activation_key FROM {$wpdb->signups} WHERE user_login = %s AND user_email = %s", $new_user_login, $new_user_email ) );
$ret = wpmu_activate_signup( $key );
The wpmu_activate_signup function will send the welcome email. And the $ret from wpmu_activate_signup is an array of several things, including the user_id in $ret['user_id'].
Obviously you'll need to fill in the user name, email, blogid, and role in the above code. | stackexchange-wordpress | {
"answer_score": 2,
"question_score": 0,
"tags": "multisite, email, password, signup"
} |
Editorial Process
Now I've never really used Wordpress with more than one author and it's usually been myself so I've followed no editorial process, but with my new site, I'm looking to add a handful of users to the Author role.
I understand there's many roles with different permissions within Wordpress already, but I can't seem to find whether or not there's an option or any documentation about setting WP up so that when Authors submit an article it should go to the Editor group for approval before anything gets published (editors are notified of new pending items via e-mail). Is this possible?
Or does it work like this by default?
As I don't know, I thought I'd ask here.
Thanks for any help in advance | Yes that's the default behavior. When an "author" writes a post, he cannot publish it, only an "editor" (or higher) can do the publishing action.
As for email notification, there are a couple of plugins for that, here are two :
* WP Status Notifier
* WP Pending Post Notifier | stackexchange-wordpress | {
"answer_score": 0,
"question_score": 0,
"tags": "author, editor, posting"
} |
Non-Linear Questionnaires in Wordpress
I want to make the following happen in Wordpress
1. People answer questions in paginated or single page form.
2. Each next set of options is dependent on the option the user selects preiviously
3. At the end, the user is directed to a page which is a common ending for all questionnaire trees.
4. All this questionnaire options can be viewed/exported
**Question:** How can this be done? or if there is a plugin available for a similar purpose? If not wordpress, is there another CMS that offers this? | This plugin is capable of doing exactly what you are after < | stackexchange-wordpress | {
"answer_score": 1,
"question_score": 3,
"tags": "plugin recommendation, pagination, forms, export"
} |
How to display magic field's custom write panel in wordpress theme?
So here is the thing.
I'm creating a site. A user can register in my site and post articles. The thing is I don't want separate admin area to post articles. I want to integrate everything in my theme. So the user don't need to go to wp-admin to create posts.
I'm using magic fields plugin. I created a custom write panel. Now my only problem is i don't know what shortcode or hook i should use to display that custom write panel in my theme. I mean i want the whole write panel in my theme. Here is a sample snapshot of custom write panel.
!enter image description here
I want to display the whole custom panel in my frontend. So logged in users can submit articles from that page. I hope you guys get what i mean. Thanks | I'm afraid it won't work quite like that.
There are plugins that enable posting from the front end, such as TDO Mini Forms.
Or see this answer for creating a form and code yourself. | stackexchange-wordpress | {
"answer_score": 1,
"question_score": 0,
"tags": "custom post types, theme development, wp admin, plugin magic fields"
} |
Detailed form plugin, with ability to export to excel etc. OR edit PDF live?
I have a client who wants to have online application forms for their non profit service.
I have used Contact Form 7 in the past, since its pretty flexible and you can have lots of fields, radio buttons etc which I LOVE.
The only concern is that just sends a plain text email, they want a way that they can save the data into a spreadsheet or database of some sort. Weither it attaches a xml to an email when the form is filled, or it saves it in the admin where you can then export it.
Is there anything out there like this?
OR is there even a way to have a PDF online where people can type in it, fill it in then email it off? Since all the documents are in PDF form already this would be even easier. | The Contact Form 7 to Database Extension plugin will save the form data to the database. I haven't used it myself, so don't know whether it offers easy ways of then extracting it, or if you have to deal with extracting it yourself. | stackexchange-wordpress | {
"answer_score": 1,
"question_score": 0,
"tags": "plugins, forms"
} |
If the only permalink setting is %postname% what happens in the case of old duplicates?
I am tempted to change my blog to be site.com/postname.
I know that for new posts Wordpress is smart enough to add a unique number to them, but what about old posts that would get updated?
I can run a database check for duplicates and manually fix them but I was wondering if this was already covered by some Wordpress magic? | Any time you have a duplicate slug for a post or taxonomy, WordPress just adds '-2' to the end of the slug. | stackexchange-wordpress | {
"answer_score": 3,
"question_score": 1,
"tags": "permalinks, url rewriting, duplicates"
} |
Nicest way to 301 Redirect traffic when changing permalink settings
If I change my permalink structure, is there is a nice way to handle when people/bots go to the old structure?
I presume I can add use .htaccess and write a rule to redirect based on a 301 but is it possible in my case?
I currently have site.com/%year%/%month%/%day%/%postname% and I will just want site.com/%category%/%postname% | Dean's Permalink Migration has always worked for me. Install it before you change your permalinks. | stackexchange-wordpress | {
"answer_score": 2,
"question_score": 3,
"tags": "permalinks, redirect"
} |
Change image link: wp_get_attachment_link
Can anyone help me filter wp_get_attachment_link so that a particular occurence of it links to the 'medium' or other size image rather than the full size. I have the following in a page template:
$args = array( 'post_type' => 'attachment', 'numberposts' => -1, 'post_status' => null, 'post_parent' => $post->ID );
$attachments = get_posts($args);
if ($attachments) {
foreach ( $attachments as $attachment ) {
echo wp_get_attachment_link( $attachment->ID , array(150,150) );
}
}
I can add a filter to add class or rel but I can't find anyway to alter the default (as originally uploaded) full size image linked to in the template .... The above works fine with colorbox (not plugin) to create a lightbox, but if a user uploads a very large image (ie: 4000x4000+ pixels), the link will load too slowly and I don't want the public to be able to download a print quality image from the lightbox.. | I think I've answered my own question sort of....
As I was using a child theme of Hybrid I activated the cleaner gallery extension in the functions.php file: `add_theme_support( 'cleaner-gallery' );`
Then, based on the topic here I created my own filter:
add_filter( 'cleaner_gallery_image', 'my_gallery_image', 10, 4 );
function my_gallery_image( $image, $id, $attr, $instance ) {
$post = get_post( $id );
$image_src = wp_get_attachment_image_src( $post->ID, 'medium' );
$image_thumb = wp_get_attachment_image_src( $post->ID, 'Custom Thumb' );
$title = esc_attr( $post->post_title );
$image = "<a href='{$image_src[0]}'><img src='{$image_thumb[0]}' border='0'></a>";
return $image;
}
There are still things that are not right such as the title, but it answers the original question, though I'm sure it could be improved on as I'm rather going by the seat of my pants.... | stackexchange-wordpress | {
"answer_score": 1,
"question_score": 3,
"tags": "attachments, images"
} |
Editing Pages that Have Already Been Published
Sorry for the simple question.
I've published a page. Let's say that I now need to make changes to the page. Can I simply edit it, after it's been published? Or should I use a maintnenace mode? If someone tries to view the page at the same time that I'm editing it, will they be greeted by an error message?
Thank you.
-Laxmidi | You can edit the page at any time after it is published. I would not recommend using maintenance mode, as then your entire site will be unavailable while you are editing the page.
When you are editing, your site is unaffected until you click "Update" and save the changes to the published post.
No users will receive error messages when you edit, however they may see the old content until they refresh. | stackexchange-wordpress | {
"answer_score": 2,
"question_score": 2,
"tags": "pages, maintenance"
} |
Edit the_content function
I want to edit the default function `the_content()`. I know i can `add_filter('the_content', 'with_my_function')` but im having trouble outputting the old content with mine.
Heres an example of what im doing.
add_filter('the_content', 'my_function');
function my_function()
{
$write = 'hello world';
$content = apply_filters('the_content', get_the_content());
echo $write.$content;
}
How can i get this to work? | Not exactly sure what you are trying to accomplish, but it looks like you are trying to prepend something to the beginning of the_content.
Try this:
add_filter('the_content', 'se24265_my_function');
function se24265_my_function( $content )
{
$write = 'hello world';
$new_content = $write . $content;
return $new_content;
}
Most filters will provide a parameter or two for your function to manipulate and then return. | stackexchange-wordpress | {
"answer_score": 9,
"question_score": 2,
"tags": "functions, content"
} |
Unwanted blank lines before <html> tag
I've a strange problem with an Autofocus theme.
In my templates file, header.php, I've a code like this (and is correct)
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "
<html xmlns="
When I look at the source code of the generated HTML, I found something like this
[blank]
[blank]
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "
<html xmlns="
The extra blank lines are breaking my RSS feeds...
Other info:
* No filters on the content except wpautop
* functions.php doesn't do anything on the content
* Plugins All In One Seo, WP Stats, Smiley Remover, SEO Friendly images
Any clues? | `the_content` doesn't affect the `DOCTYPE` and `<html>` tags, only the post/page content.
One of your plugins, or something else in the theme is either throwing an error, or is printing something earlier than it should.
Have you tried:
* Disabling each plugin one by one and see when it is fixed.
* Editing wp-config.php and adding `define( 'WP_DEBUG', true );` to look for errors | stackexchange-wordpress | {
"answer_score": 3,
"question_score": 2,
"tags": "theme development, themes"
} |
Force core to use .dev JavaScript files
I was wondering if there's some constant telling WordPress **not** to use the minified versions of scripts but instead load .dev ones. Already tried `define('SCRIPT_DEBUG', true);` but it only turned off script unification. | I use a combination of constants on my local install.
define('CONCATENATE_SCRIPTS', false);
define('COMPRESS_SCRIPTS', false); // <--- this is likely the one you're after
define('COMPRESS_CSS', false);
define('SCRIPT_DEBUG', true);
I'd imagine the second constant listed above is the one you're after. | stackexchange-wordpress | {
"answer_score": 6,
"question_score": 3,
"tags": "javascript, customization"
} |
Setting a title on a Custom Post Type that doesn't support titles
I have a CPT called "profile" that only supports the editor and thumbnail. Each user is limited to posting just 1 profile.
I'm looking for a way to prefill the title and slug fields with the display name of the post author. As it is now, if I click on Publish, the post_status in the db is "Auto Draft" and the URL becomes "localhost/mytestsite/profile/auto-draft-1". It seems WP **needs** a title or else it won't be considered "Published".
I've checked several questions already posted here and this one seems like the one I need. Custom Post Type with Custom Title
But since I want the author's name and not values in a taxonomy or custom field, I don't know how to modify the code to reflect that.
I see that get_the_author() needs to be in The Loop. | You could add a hidden input into the page to pre-set the title field, because it won't be on the page(because the type doesn't support titles).
Slug is produced from the title, so you should only need add a title value.
Something like this should work(though untested)..
add_action( 'submitpost_box', 'hidden_type_title' );
function hidden_type_title() {
global $current_user, $post, $post_type;
// If the current type supports the title, nothing to done, return
if( post_type_supports( $post_type, 'title' ) )
return;
?>
<input type="hidden" name="post_title"value="<?php echo esc_attr( htmlspecialchars( get_the_author_meta( 'display_name', $current_user->data->ID ) ) ); ?>" id="title" />
<?php
}
Though i'd perhaps suggest adding further to the code and checking if the author display name is not empty, etc... it should be enough to work with..(or get you started at least).. :) | stackexchange-wordpress | {
"answer_score": 1,
"question_score": 1,
"tags": "custom post types, slug, title, post status"
} |
High traffic management in WP
I have to develop a site in Wordpress similar to an already existing site in JSP which handles approx.`50K users a day and 200 users` at a time. And in load testing i get that wordpress can handle only `40 users` at a time (with `Super Cache` plugin `ON`). Also I have hosted my site on a `Shared hosted server`.
So please suggest me some way or guide me to `optimize` my wordpress site so that it can also handle the same traffic.
Thanks in advance. | Reduce the amount of plugins. Check your theme for memory intense stuff or lots of queries.
Add this line to your footer or hook it to the `shutdown` hook to see some basic information:
<!-- Time needed to print this page: <?php timer_stop( 0, 3 ); ?> Number of queries needed to process this request: <?php get_num_queries(); ?> -->
Then take a look at your site through source code and at the bottom you'll find the html comment containing this basic data. Then start disabling single plugins to see the difference and their impact on performance.
Furthermore I'd say the max user restriction is not by wp, but by your shared hosting account. | stackexchange-wordpress | {
"answer_score": 2,
"question_score": 0,
"tags": "performance, optimization, server load"
} |
Wordpress add_action the_post hook
Now i face a problem, that i want to add a hook into the the_post. Then i use `print_r($post);` here display the my `print_r` content and again display the default content. because i am here in the_loop.so again the content was display.
add_action( 'the_content', 'custom_post' );
function custom_post() {
global $post, $wp_query;
$post_id = $post->ID;
print_r($post);
}
Here i need how to overwrite the default content of the the_post and display my own content.
This is possible in a way, that i use the_title and the_content hook but here the function was call two times then its problem. so plz help me. | Take a look at my answer here, if you are trying to replace the post content:
Edit the_content function | stackexchange-wordpress | {
"answer_score": 1,
"question_score": 0,
"tags": "hooks"
} |
How to install plugins in individual sites on a wordpress network?
I'm trying to install plugins in my wordpress subsites instead of network activate that plugin. But i'm not seeing any "add new" link in my subsite plugin area. How to install plugins in my individual sites. Am i missing something?. Thanks | 1. Install plugin in networ admin as usual for multisite.
2. Do not activate plugin for whole network.
3. Go to admin of individual site and enable plugin there for that site alone. | stackexchange-wordpress | {
"answer_score": 10,
"question_score": 4,
"tags": "plugins, multisite"
} |
Multisite stuck at 1MB for max file size
I have a Wordpress Multisite install on our FreeBSD development server. It seems to be stuck at 1MB.
I have the following settings in `php.ini`
upload_max_filesize = 100M
post_max_size = 100M
max_execution_time = 300
All the regular WordPress installs on the site have a max upload size of 100MB, as expected. Regardless of the values I put the multisite install is stuck at 1MB.
The setup:
* FreeBSD 8.1
* PHP 5.3.3
* Wordpress Multisite 3.2.1
After moving the site to another server on Rackspace, it has the same issues.
Any help on getting this limit raised would be appreciated. If I left any pertinent information out let me know and I'll provide what I can. | There is a network admin settings page with a Max upload file size field, make sure this is also set correctly. | stackexchange-wordpress | {
"answer_score": 22,
"question_score": 9,
"tags": "multisite, uploads"
} |
What's the best way to get posts from one multisite blog into another?
I have a multisite setup, with the main site being the company web site and a couple other blogs that will have different themes.
I want to pull in posts from one or the other blog onto the home page of the main blog.
What is the best way to accomplish this?
Thanks. | There's a function to get **one post** from **one blog** , but that's it:
<?php
$post = get_blog_post( $blog_id, $post_id );
echo $post->ID;
?>
If the blog has only one author you could also use `get_most_recent_post_of_user`. But I think the best way is to fetch the feed using `fetch_feed()`:
$rss = fetch_feed('
// Figure out how many total items there are, but limit it to 5.
$maxitems = $rss->get_item_quantity(5);
// Build an array of all the items, starting with element 0 (first element).
$rss_items = $rss->get_items(0, $maxitems);
foreach ( $rss_items as $item ) { // Loop
echo $item->get_title();
echo $item->get_content();
}
It uses the Simplepie API, I recently wrote an article about that Display RSS Feed in WordPress. | stackexchange-wordpress | {
"answer_score": 1,
"question_score": 0,
"tags": "multisite"
} |
Specifying multiple categories in URL (permalink)?
For example: ` where `dell` and `studio` are categories
A few months back I heard from someone that it is not possible. I need to know why? Which part of code prevents it? Is there any workaround for this? | Some folks asked the same question you did here. This one specifically worth reading, if you haven't already. It has ottopress explanation for harmful permalinks.
If you really want to force this, you could write your own permalink (< then either use htaccess rewrite rule or WP_Rewrite to take them to the link wordpress generated.
This merely satisfies your visual requirement, but it adds server load. | stackexchange-wordpress | {
"answer_score": 1,
"question_score": 1,
"tags": "categories, custom taxonomy, permalinks"
} |
Shortcode returns values in the wrong order
I have a shortcode function that returns:
return '<ul class="list-pages">'. wp_list_pages( $args ) .'</ul>';
Of course it returns:
{pages}
<ul class="list-pages"></ul>
Instead of:
<ul class="list-pages">
{pages}
</ul>
There is almost the same question, but for echo:
Why does this echo values in the wrong order?
And it works perfectly for echo, but I don't know how to use PHP line breaking with "return" (it breaks the whole code).
Thank you! | it is b/c wp_list_pages ECHOES by default. so it echoes before your return happens.
wherever you are defining your $args, set
'echo' => FALSE,
see < | stackexchange-wordpress | {
"answer_score": 5,
"question_score": 0,
"tags": "php, shortcode"
} |
In What WordPress Version Was the Import/Export Tool Introduced?
I was just looking under my "Tools" menu in my WordPress site and noticed the "Export/Import" functions.
I was not aware that this was even available and I've been needing it for some time. What version of WordPress did it originate with? | Exporting and Importing has been there since at least WordPress 2.1. Probably earlier. It moved into plugins with the release of 3.0, I believe. | stackexchange-wordpress | {
"answer_score": 3,
"question_score": 0,
"tags": "import, export"
} |
WordPress Export/Import for custom options.php values?
I've just discovered the WordPress export/import routine under the tools menu. However, upon testing it for the first time, several values stored in my wp_options table did not transfer over.
Is there a way to include those values when exporting/importing a site? | Simply read the text, the import/export plugins offer:
> Upload your WordPress eXtended RSS (WXR) file and we’ll import the posts, pages, comments, custom fields, categories, and tags into this site. | stackexchange-wordpress | {
"answer_score": 1,
"question_score": -2,
"tags": "import, export"
} |
get_categories returns an array with one category
I'm running a query on a custom plugin to display all categories and put them into a dropdown (the select parts are outside the loop) which looks like this:
<?php
$ember_categories = get_categories();
foreach($ember_categories as $ember_category) {
echo '<option value="' . $ember_category->cat_ID . '">' . $ember_category->name . '</option>';
}
?>
For some reason though, it's only returning my default category (Uncategorized) - even though there are six more added to the system (including one I added afterwards, just as a curiosity). I'm wondering whether I'm doing something glaringly wrong? | Try `get_categories( array('hide_empty' => 0 ) );` | stackexchange-wordpress | {
"answer_score": 7,
"question_score": 3,
"tags": "categories"
} |
How to get page's ID if I know the title only?
Is there an exact opposite funciton to this one:
get_the_title(ID)
I know there's:
get_the_id()
But it doesn't seem to accept any arguments.
So, basically, I'm looking for something like:
$title = 'Something';
get_the_id($title);
I already know this solution:
global $wpdb;
$post_name = get_query_var('name');
$post_id = $wpdb->get_var("SELECT ID FROM $wpdb->posts WHERE post_name = $post_name");
But maybe there's something bulit-in that I'm missing? | I'm not sure how to get it via the title, but you can get it via the slug (which is often more useful in my experience) using this:
<
Just change "$page" to "$post" if you want to return slugs for posts instead of pages.
G'luck! | stackexchange-wordpress | {
"answer_score": 3,
"question_score": 3,
"tags": "title, id, get the title, get the id"
} |
Is the Block Bad Queries Plugin Still Relevant?
The Block Bad Queries Plugin hasn't been updated recently. Is WordPress still subject to these types of malicious attacks or has it been hardened sufficiently to make the plugin obsolete? Is there an alternative? | Yes it is still relevant, WordPress is very subject to query based attacks. It is more common and easier to attack bad plugins/themes, so even if your WordPress version is kept up to date, it's still a good idea.
There is a better plugin called Mute Screamer, it uses a central PHPIDS database.
< | stackexchange-wordpress | {
"answer_score": 1,
"question_score": 0,
"tags": "plugins, security"
} |
To be able to login as different user
I have 2 kinds of users...
Both uses custom form for registeration....
One is parent user and another is child users. Parent user can register and then login and create child users. I have also given interface in theme where parents can manage child users data created by them.
Basically site is based on article for childs helping them in education and question answer....
What i want to do is when parent is login , i have list of his child users, want to give link like Login as child, on click of which parent gets logout and get logged in as child using child credential...
Any tips/suggestion how to achive logout and login as different user using script... | To login as a user you just need the target user ID and these two functions:
wp_set_current_user( $user_id );
wp_set_auth_cookie( $user_id );
If you do this mid-page, make sure you refresh it to reflect the changes. | stackexchange-wordpress | {
"answer_score": 9,
"question_score": 1,
"tags": "login"
} |
How to set a default format for a custom post type?
I created a custom post type for my blog, to allow easier separation of content. This new post type supports different post formats, but most of them will be galleries.
register_post_type('atelier',
array(
'label' => 'L\'Atelier',
'public' => true,
'supports' => array('title', 'editor', 'post-formats')
)
);
I saw that it is possible in Settings -> Writing to set the default post format for posts, is it possible to do the same for my newly created post type? | One option would be to modify the global Default Post Format setting, via `Dashboard -> Settings -> Writing`.
Note that this setting is _global_ , so it would set the default for _all_ post types that support Post Formats.
If you have no need of post formats for blog Posts, you could simply enable post-format support _only_ for your custom post type, by _removing_ post-format support for blog posts:
<?php
remove_post_type_support( 'post', 'post-formats' );
?>
(Untested, but I see no reason why it shouldn't work.) | stackexchange-wordpress | {
"answer_score": 3,
"question_score": 7,
"tags": "custom post types, post formats, customization"
} |
WordPress As A Shared Items Collection
I'm planning on using WordPress to create an arcive of my starred/shared/favourited items on a few services, such as:
* Twitter Favourites
* YouTube Favourites
* Google Reader Starred Items
* Stack Overflow Starred Questions
* etc.
As the data for each type is different, eg video/article/short text what would be the best way of doing this? Would a custom post type or format for each type be the best way?
Or does anyone have any suggestions for any themes or plugins which work in a similar way to save me doing all of this from scratch? | Now I would suggest to do it with Post Formats.
Before there were Post Formats, I made sth similar to what you're looking to do. Although I am not sure whether it is possible to "grab" You Tube Favorites, others should be possible. I actually integrated a lot of social media feeds using the Feed WordPress plugin and Yahoo Pipes where necessary. You can read more on the linked page. | stackexchange-wordpress | {
"answer_score": 2,
"question_score": 1,
"tags": "custom post types, plugin recommendation, post formats"
} |
get_page() unlike Loop returns the post content without html tags. How can I fix this?
get_page() unlike Loop returns the post content without html tags. I need tags. How can I fix this?
I don't want to change wysiwyg editor, here is the bad solution < | I presume you are getting the page content like so:
$page_id = 1;
$page = get_page($page_id);
$content = $page->post_content;
echo $content;
If thats the case then you can run the content through the `the_content` filter:
$content = apply_filters('the_content', $content);
The will process the content as if it was run through `the_content()` function. | stackexchange-wordpress | {
"answer_score": 1,
"question_score": -1,
"tags": "loop, tags, html, pages"
} |
How to remove "featured image" functionality from a custom post type?
I have made a custom post type for a child theme. I removed "thumbnail" from the supports array in functions.php and that prevents a featured image meta box from being displayed. However, when in the "add an image" modal dialogue thing, there is still a "Use as featured image" link. Why, oh why? More to the point, does anyone know how to remove?
I tried...
remove_post_type_support( 'itinerary', 'post-thumbnail' );
...where itinerary is the name of my custom post type. Any help would be greatly appreciated!
Steve | Some where in your theme you should have:
add_theme_support( 'post-thumbnails' );
Instead of removing support for a post type try only adding support for the post types you want:
add_theme_support( 'post-thumbnails', array( 'post', 'movie' ) ); | stackexchange-wordpress | {
"answer_score": 12,
"question_score": 7,
"tags": "custom post types, post thumbnails"
} |
How to custom category template based on category?
My blog have 2 categories: Photos and Texts.
I would like do customize the category template so that when it renders Photos post's, I want to show a thumbnail gallery and when it renders Texts post's, I want show only the excerpt.
There is an way to do this without hardcoding on category.php? Or, at least, how is the best way to do this?
Thank you! | create category templates; i.e. category-photos.php and category-texts.php; starting with a copy of the code from category.php. you will still need to hard-code the changes in each template. | stackexchange-wordpress | {
"answer_score": 1,
"question_score": 0,
"tags": "theme development, categories, customization"
} |
How safe / sanitized is wp_insert_posts()?
Looking at the Codex for wp_insert_post() it states that this function "...sanitizes variables, does some checks, fills in missing variables like date/time, etc. " (EDIT: I updated the Codex entry to include a more robust example that includes security as well as post meta and category assignment)
Just wondering whether I need to do any further sanitization to prevent XSS hacks and the like or whether enough is being done through the function.
To be honest, I've checked through the function in core and haven't found any wp_kses() or other sanitization on post_content for example, so I'm a little concerned. All I can see that it does is stripslashes_deep() on the data.
So should I be running wp_kses() or anything else when I build my arguments to wp_insert_post()?
What's the best practice here? The Codex is pretty cavalier about security in its example.
Thanks | You don't have to do anything.
On WP load:
`'init' hook -> kses_init() -> kses_init_filters()`
Later:
`wp_insert_post() -> sanitize_post() -> sanitize_post_field() -> 'content_save_pre' -> wp_filter_post_kses()`
Similarly for post titles, comment text etc.
Conclusion: wp_insert_post() is very sanitized. :) | stackexchange-wordpress | {
"answer_score": 12,
"question_score": 13,
"tags": "security, sanitization"
} |
Use the_taxonomies() to create a simple list
I'm trying to create `<div class="cat-hidden categories"></div>` where `categories` is a list of the categories the current post is posted in.
When just using `the_taxonomies()`, it outputs something like this:
<div class="cat-hidden Job Type: <a href=' <a href=' <a href=' and <a href=' Development/IT</a>."></div>`
Whereas I want it to output something similar to this:
`<div class="cat-hidden Early-Career Internship Web-Development/IT"></div>`
That means I'm going to also have to parse the categories that are outputted because I need `Web Development/IT` to be `Web-Development/IT` or `Web-Development-IT`. I'm unsure about the `/` being in there because I think CSS doesn't allow a `/`. That's where you experts come along.
I am very proficient in HTML and CSS, and know some PHP and Wordpress, but I don't know where to begin.
If any more info is needed, please let me know.
Thank you! | you can use **`wp_get_post_terms()`** to get a list of the post categories and just output the category slug which is already phrased for you, something like this:
//in your loop
echo '<div class="cat-hidden';
$cats = wp_get_post_terms($post->ID,'category');
foreach($cats as $cat){
echo ' '.$cat->slug;
}
echo '"></div>'; | stackexchange-wordpress | {
"answer_score": 3,
"question_score": 2,
"tags": "custom post types, custom taxonomy, taxonomy"
} |
When is it appropriate to create a new table in the WordPress database?
For a client we'll need 29,000 terms (all the highschool's in the US) and each term needs 6 meta items (address, phone...). My initial thought was to store the term meta information as suggested in this post but after looking through it again I will be using lots of terms and I wonder if it will overload the options table.
Is there a good time to create a new table? Would this qualify? Other thoughts on how to relate the HS that a person attends to the 'post' that will be their academic profile?
It was suggested that I make the 'terms' a Custom Post Type. I'm not opposed to that either but I fail to see how I'll relate the CPT to multiple 'authors' since a school will have more than one student that attends it. Because of the multiple ownership of the content terms just seemed to fit better. | As the article mentions, using wp_options is not a good idea when you have thousands of terms, mainly because there's:
* a lot of serialization involved OR
* long option names (the limit is 64 characters)
In this particular case, yes, it's appropriate to create some custom tables.
To save time, you can use this plugin (update more recently than Simple Term Meta):
<
Having said that, it looks to me like a custom post type would be better suited for this.
Take a look at my Posts 2 Posts plugin for relating highschools to whatever you were planning on relating them to. | stackexchange-wordpress | {
"answer_score": 5,
"question_score": 5,
"tags": "database, customization, table"
} |
Changing the default WordPress search action
I recently completed a WordPress site design, and I'm just struggling with one bug: when a user clicks the "Search" button without any content in the text field, they are redirected to a list of posts. Is there a way to modify this action? Ideally, if the text field is empty, the user will be redirected to the homepage. | The default WordPress action is to redirect to the homepage when the search is blank - just what you want! Do you have any plugins or .htaccess settings that may be changing this? | stackexchange-wordpress | {
"answer_score": 1,
"question_score": 0,
"tags": "search"
} |
How to attach sidebar to shortcode's output?
I have one shortcode that should be always next to the sidebar:
// [shortcode] otuput | default sidebar
My theme allows me to set different sidebars for each page. So I have sidebars on a few pages, but not everywhere.
What's the best/proper way of achieving this goal? I was thinking about adding `dynamic_sidebar($sidebar_name)` to the shortcode itself, but it doesn't seem to be smart idea (especially with multiple instances of my shortcode at the same page). | I'm still not sure exactly what you're trying to do, but here's one possibility if it's to display something like this:
PAGE CONTENT | SHORTCODE/POSTS LOOP | SIDEBAR
Do you have control of the shortcode content? If so, you could update it so its output is wrapped in a `<div id="shortcodecontent"> --shortcode post-loop output-- </div>`.
Then add a text widget to your sidebar and insert the [shortcode] within it. If shortcodes aren't rendering when inserted in widgets, add the following line to the functions.php file within your theme:
add_filter('widget_text', 'do_shortcode');
Now, the shortcode output will appear first, before any of the other widgets in your sidebar. Using CSS, style the wrapping #shortcodecontent div so that your shortcode widget floats to the left of the other widgets in your sidebar.
Hope this helps in some way! Best of luck. | stackexchange-wordpress | {
"answer_score": 0,
"question_score": 0,
"tags": "shortcode, sidebar"
} |
Should I use relative or absolute urls when pointing to internal pages
This is a simple question, that's probably been asked before. For internal links between pages, is it better to use a relative link or full permalink?
Thank you. | It depends on what you're talking about. If you're talking about using just
`<a href="/page-title">Page Title</a>`, then no. It's better to use the full link.
However, instead of using ` it's better to use
`<?php echo bloginfo('url'); ?>/page-title`.
The reason you don't want to use relative links is the way wordpress permalinks work. If you're on a sub-page (`domain.com/about/john`) and you use a relative link to another subpage (`href="/jane"`), it will point to the root URL (`domain.com/jane` instead of `domain/about/jane`.
**UPDATE**
The full `<a>` will be
`<a href="<?php echo bloginfo('url'); ?>/page-title">Page Title</a>` | stackexchange-wordpress | {
"answer_score": 3,
"question_score": 0,
"tags": "permalinks, pages"
} |
Custom Permalinks don't work on local LAMP installation
I'm on Ubuntu and using LAMP for local dev. I've several WordPress installations for different project and tried to set custom permalinks on all of them, but only default permalink setting ( ` ) works, other settings are giving 404 error. Any idea how can I fix this?
George | I had the same problem. It sounds like you don't have rewrites turned on in your installation.
Find your httpd.conf file, find the following line:
#LoadModule rewrite_module modules/mod_rewrite.so
And remove the # at the beginning so it looks like this:
LoadModule rewrite_module modules/mod_rewrite.so
Save and then restart the service. Custom Permalinks should now work. There might be an easier way but I'm not familiar with Linux | stackexchange-wordpress | {
"answer_score": 3,
"question_score": 1,
"tags": "permalinks, local installation"
} |
Actions to use when flushing cache (when posts are added / deleted / modified)
I'm looking for a list of action tags that are relevant when you:
* create a post, with any method, so basically using wp_insert_post
* modify a post, like changing status, title, content, terms, meta, anything related to it;
* remove a post
Are `save_post` and `deleted_post` enough for this kind of thing? | Yes, 'save_post' and 'delete_post' cover everything, except modifying meta and terms associated to a post. Those hooks can be found in wp-includes: `meta.php` and `taxonomy.php`, respectively. | stackexchange-wordpress | {
"answer_score": 1,
"question_score": 0,
"tags": "posts, cache, actions"
} |
How do I make Wordpress "Page" link in the top nav bar go to an external URL?
I would like the Wordpress page link as shown here go to an external URL instead of going to page. What is the best way to set this up? I'm running Wordpress 3.1.3. Thank you. | Goto
> Appearance -> Menus -> Create a new menu -> Add your link as custom link | stackexchange-wordpress | {
"answer_score": 2,
"question_score": 0,
"tags": "links, urls, configuration, headers"
} |
wp_insert_term - parent & child problem
I have a car database that I want to import into Wordpress as taxonomies. The problem is I can't create 2 taxonomies at once (first is parent, last ones are childs of first).
$p = wp_insert_term("Acura", "classified-category", array("description" => "Acura"));
$c = wp_insert_term("Acura CL", "classified-category", array("parent" => $p["term_id"], "description" => "Acura CL"));
print_r($p);
print_r($c);
returns:
Array ( [term_id] => 13 [term_taxonomy_id] => 4720 )
Array ( [term_id] => 2589 [term_taxonomy_id] => 4721 )
But in Dashboard appears just parent category. The problem is similar to this one: <
Any idea ? | The issue is with the taxonomy cache. You have to clear it after you insert the terms in order to see them. I had the same issue, which someone answered for me here:
delete_option("classified-category_children");
Insert that after the term inserts and you should be good. | stackexchange-wordpress | {
"answer_score": 7,
"question_score": 4,
"tags": "custom taxonomy, customization, taxonomy"
} |
Complicated image name like flickr does and deny access just to original image
If I upload a given image like my-image.jpg, then following image resizes occurs:
> < <
also the original image is uploaded:
> <
I have two question about which actions try to:
# 1 Question
Rename image name to a complicated long name like 5702703214_85bfb55948.jpg:
# 2 Question
Avoid access to original image uploaded, let access to thumb, medium and large, but deny access just only to the original image uploaded?
Thanks in advance | create shortened URL function, then add filter on the_content() to replace all img src URL to shortened URL | stackexchange-wordpress | {
"answer_score": 1,
"question_score": 0,
"tags": "uploads"
} |
Add an image box besides featured image?
When you want to associate an image to a post which already has its own featured image, you have to use a custom field : you upload an image just as if you wanted to add an image inside your post, but then you just copy the image URL, click cancel, and put the image URL in the custom field value : burdensome.
Is it possible to do that automatically without any need to copy and paste any URL, like having another featured image, but with a specific name and having the properties of a custom field ?
I hope my question is understandable. | You can add 2nd featured image using Multiple Post Thumbnails plugin, make sure to follow the installation instruction. | stackexchange-wordpress | {
"answer_score": 4,
"question_score": 2,
"tags": "posts, images"
} |
The MySQL alternatives: Do Percona Server and MariaDB work well with WordPress, and do they make WordPress go better?
Lately I've been reading about MariaDB and Percona Server, two strong alternatives to MySQL that have gained popularity since Oracle bought Sun.
As far as I know, both of them could be used with WordPress, but I'd like to know if anyone uses them, and if they really help make our blogs and servers run better than they did with MySQL. | I have personally worked with Percona Server and MySQL, not with MariaDB as of yet.
Percona provides support for MariaDB, Drizzle, Amazon RDS, and other MySQL products.
I learned at Percona Live NYC that Percona gets the latest version of MySQL and injects 30,000 lines of C/C++ that is unique to its Performance Enhancements. MySQL (eh, Oracle) tries to keep up with its own enhancements of InnoDB.
Unless your website is very heavily trafficked, there is no decent performance difference you can feel or see. However, if you do have high traffic and you want to compare MySQL, Percona, and MariaDB, I have posted an article in the DBA StackExchange on how to go about doing this. | stackexchange-wordpress | {
"answer_score": 4,
"question_score": 12,
"tags": "database, mysql"
} |
Error jQuery(domChunk).live is not a function
I'm getting this error in FireFox:
Error: jQuery(domChunk).live is not a function Source File: Line: 26
This is the function:
//add thickbox to href & area elements that have a class of .thickbox
function tb_init(domChunk){
jQuery(domChunk).live('click', tb_click);
}
Thickbox seems to be a build in WordPress feature but the theme we are using uses prettyPhoto. | I used jQuery(domChunk).bind instead. This seems to work. | stackexchange-wordpress | {
"answer_score": 1,
"question_score": 0,
"tags": "plugins, jquery"
} |
How can I get only parent terms?
Is there any way to get only parent terms from custom taxonomy or category? | Yes, just pass in the parent parameter to `get_terms` when you call it, as Michael pointed out.
Since WP 4.5 this is the recommend usage:
$myterms = get_terms( array( 'taxonomy' => 'taxonomy_name', 'parent' => 0 ) );
Prior to WP 4.5 this was the default usage:
$myterms = get_terms( 'taxonomy_name_here', array( 'parent' => 0 ) );
Will return all terms that have a parent value of `0`, ie. top level terms. | stackexchange-wordpress | {
"answer_score": 49,
"question_score": 26,
"tags": "custom taxonomy, terms"
} |
Sort posts after filtering them through multiple taxonomies
I'm using scribu's Query Multiple Taxonomies to filter posts through multiple taxonomies (which works great!).
However, I'd like to allow people to perform further sorting on the results based on custom fields which have numeric values (eg. `rate_per__private_session` or `rate_per_group`) by clicking on a link.
I thought that something like the following would be all there was to it but clearly it is not.
<a href="<?php query_posts($query_string . '&meta_key=rate_per_private_session'); ?>">Sort by Rate per Private Session</a> |
<a href="<?php query_posts($query_string . '&meta_key=rate_per_group'); ?>">Sort by Rate per Group</a>
How do I do this? | I think I got it on my own. The code should be:
<a href="<?php echo add_query_arg( 'order_by', 'rate_private' ); ?>">Sort by private</a>
<a href="<?php echo add_query_arg( 'order_by', 'rate_company' ); ?>">Sort by company</a>
Note: I used another plugin, Custom Query Fields, which has "order_by" query var made available. | stackexchange-wordpress | {
"answer_score": 0,
"question_score": 0,
"tags": "custom field, filters, sort"
} |
How to block a someone from commenting?
I keep getting spammed by the same user, well different name and site listed but always the same email, IP, and comment.
the email is `[email protected]`, the IP is `31.184.238.9`, and the message is long and always the same.
I want to do 2 things:
* How can I block this person from commenting?
* I have over a hundred pending from them, is there a way to mark them all as spam? | In `Settings > Discussion > Comment Blacklist`. You can blacklist comments based on content, name, url, e-mail, or IP.
To mark the comments as spam, what I would do, is to do a search for his IP and then there is a checkbox that will select all, then just mark as spam. Trick is, it only applies to the comments listed on the page, but it is still better to do a few and a lot. | stackexchange-wordpress | {
"answer_score": 2,
"question_score": 2,
"tags": "spam"
} |
How to control accept encoding on HTTP API requests?
Related to this ticket about issues with inflating data.
So far it had been suggested by API's support to request gzip instead of deflate.
However I cannot find a way to override WP settings that set deflate with highest priority as accepted encoding for all requests.
Related functions - `WP_Http_Encoding::is_available()` and `WP_Http_Encoding::accept_encoding()`.
Is there any hook or other option to control this that I am missing? | Quite an edge case, but the accepted encoding types should be filterable nonetheless. I can see a few situations where fine, granular control over this header would be useful (as in adding an API that uses non-standard encoding).
So, while there's no stock hook for this, I have created a Trac ticket for it and submitted a patch. If you voice support on the ticket, maybe we can raise enough noise to get it incorporated into a future release. | stackexchange-wordpress | {
"answer_score": 4,
"question_score": 11,
"tags": "http api"
} |
Help with static front page blog at /blog
I'm interested in installing wordpress and having a static front page and have link to the blog at /blog.
How do I install wordpress in the root directory, but have the blog live at /blog I see how I could do it for the blog urls, but do I just change the wordpress url in general settings for this?
Thanks. | There's a codex on this issue here:
<
I haven't been provided all the details of your site from your post. As in what your original site root is from when you installed it.
So i'm making an assumption that this is a new install. | stackexchange-wordpress | {
"answer_score": 2,
"question_score": 1,
"tags": "url rewriting"
} |
Featured Images on Front Page
I currently have a static front page and a /blog.
My goal is to have the front page be a grid of hand selected images (similar to a portfolio). I would like to be able to easily switch the images are featured on this page without having to change the raw html.
Is the best way to do this, using custom fields on a page? Or is there a better way to handle managing featured images on a static page?
Thanks! | Two categories should do the trick.
1. Featured posts - This category should be applied to posts that you want to show on your home page, with that images grid. You can limit the number of posts (so only the, for example, 6 newest ones would appear) and select the featured image for them on each post's properties. You can limit number of posts easily, and you can also exclude other categories from your home page.
2. Blog posts - a general category with a name such as 'blog' would include every other post you've got on your website. This category would have a visible link on your home page, and would be accesible through www.yousite.com/blog/
I think this would be my way to go. | stackexchange-wordpress | {
"answer_score": 0,
"question_score": 0,
"tags": "images, post thumbnails, page template"
} |
Is it possible to include an HTML flat-file website inside a WordPress theme?
Is it possible to include an entire flat-file HTML site (.html, folders/ and CSS) inside WordPress?
Essentially, I want to host an HTML site, but have access to WP functions and plugins. Not to interested in a iframe solution as that would break the look of the URLs on the browser address bar.
Can I include the html site in WP? Or perhaps include WP in the HTML (with some PHP .htaccess extension magic)? | First you need site to be processed as PHP, since WP simply won't work otherwise. I think you can do it for non-.php extensions by tinkering with server config.
THen see Integrating WordPress with Your Website in Codex. You can load WP core to required degree and use the functions.
However I'd consider just migrating site to WP completely. | stackexchange-wordpress | {
"answer_score": 2,
"question_score": 0,
"tags": "theme development, html, include"
} |
Getting archive pages in WP's AJAX internal link finder?
I often need to link to custom taxonomy term archive pages and would love to be able to do so through the AJAX internal link navigator added to the visual editor in 3.1. Is there any way to get this functionality, with either with a plugin or non-colossal changes to the core? | Right now there are no hooks to do that from a plugin and the function that makes the search query itself is not pluggable which means that the only way to achieve that is to hack core files.
Currently there is an open Trac Ticket asking for some kind of hook. | stackexchange-wordpress | {
"answer_score": 1,
"question_score": 2,
"tags": "custom taxonomy, permalinks, links, editor"
} |
Overstand theme set up issue
I've just begun setting up the overstand theme to work with my blog, but I've run into a problem. Check out my site: < the problem is pretty obvious. Those two black categories have been like that since I first installed the theme - I have done nothing to change them. I'd like those two areas to stretch out across the entire page. They are both set to use the "latest2" class which is coded to be 465px, but neither are responding to it. What's wrong?
You can find the files for the overstand theme here:
Thanks | **You should replace this code:**
ul.latestoneandhalf {
float:left;
padding-right:15px;
width:225px;
}
**With this:**
ul.latestoneandhalf {
float:left;
padding-right:15px;
width:100%;
} | stackexchange-wordpress | {
"answer_score": 0,
"question_score": 0,
"tags": "customization"
} |
Getting WPTouch and W3 Total Cache to Work Together
I cannot get WPTouch to work with W3 Total Cache. WPTouch admits that there is a known issue with the two, and they send you to a tutorial. The tutorial is out of date, however, and does not work for me. Does anyone have WPTouch working with W3 Total Cache? If so, can you give some directions/instructions? | See: <
You'll need to add that long list to Rejected User Agents under Page Cache, Minify and CDN.
If your concerned about the browser caching issues when switching between mobile vs. normal themes, you'll need to add some query string pattern in the reject URIs field on the page cache settings tab. | stackexchange-wordpress | {
"answer_score": 1,
"question_score": 1,
"tags": "plugins, plugin w3 total cache"
} |
A carousel slideshow plugin in JavaScript
Am looking for carousel slideshow plugin that is similar to the one implemented here.
Any JavaScript slideshow that closely resembles that one would do. It does not even have to be a WordPress plugin, any standalone JavaScript library would also be very useful. | there is a plugin (discontinued): < and a Nextgen addon: <
More samples and the original code (to the best of my knowledge) can be found here: < | stackexchange-wordpress | {
"answer_score": 1,
"question_score": 0,
"tags": "jquery, javascript, gallery, slideshow, jquery ui"
} |
How to add text editor in plugin menu?
Can I add a **text editor to my plugin menu**? So I can let users edit custom css file? Something like `/wp-admin/plugin-editor.php` but I want users to be able to edit only one file. The custome css file.
Could this be done using **Wordpress standard functions**? | This will help you
< | stackexchange-wordpress | {
"answer_score": 1,
"question_score": 0,
"tags": "plugin development, wp admin, admin menu"
} |
Admin menu success message
I have created a simple admin menu that allows users to enter in some basic information that is stored in the footer.
When they click save the url appends `&settings-updated=true`
Is there a way, using jQuery to show a success/fail message?
Can anyone show me how or give me an example?
Thanks in advance, George | See the top answer on this Stackoverflow question. Basically you need to use:
decodeURI((RegExp(name + '=' + '(.+?)(&|$)').exec(location.search)||[,null])[1]);
Get URL parameter with jQuery | stackexchange-wordpress | {
"answer_score": 1,
"question_score": 0,
"tags": "wp admin, jquery, menus"
} |
How should I set up a Tumblr blog at a WordPress Page?
I am developing a site for a client, let's call it `whatever.com`. He wants to have his Tumblr blog at `whatever.com/blog`. (Tumblr lets you name the URL at which your Tumblr page will be served, and if it's a site root, you adjust your domain's A-Record, which obviously I can't do here.)
Right now I have a blank page called `blog` so that it shows up in the nav using `wp_list_pages()`, but I'm guessing this won't work unless I do some fiddling elsewhere.
Anyone know how to do this? | Hmm, given that it's okay to send the visitor to an entirely different site, but you are trying to get it to show up as a page, I would suggest adding it to a menu.
You are probably already aware, but when you are modifying menus (Appearance > Menus) there is a box on the left side called "Custom Links," which just like they sound, allow you to add something directly to the menu that can go anywhere. Add an entry using this that goes to the Tumblr blog and use that menu (whether it be primary or secondary) wherever you need to display the pages AND the Tumblr link. This avoids `.htaccess` conflicts and is the "natural" way to do things, but does restrict it to only being in menus.
Might be missing something here on how Tumblr recognizes the URL and the DNS issues, but from the WordPress side of things, that's how I would go about it. | stackexchange-wordpress | {
"answer_score": 0,
"question_score": 0,
"tags": "pages, redirect, tumblr, wp list pages"
} |
How to preload the entire site with javascript?
I don't know if I'm in the right place because is not strictly for Wordpress, I think someone can get some benifit of this question without using Wordpress but in this case I'm using it.
So, I'm using a modified theme with some plugin enabled, carousel, and other fancy things. There is a problem with some graphics, when I call the site from a remote host, and it's not cached, it's not quick as it's in localhost so all the images are preload in the same place one above the other and when the JS is ready all go in place, but you see a mess while the site is reading...
This is not very nice as you thinking...
My intention is to achive a "site is loading" pulsating or a progress bar while the site is ready in background.
How to do this? | This is NOT a good idea. If you get that kind of behavior, then you didn't properly code your carousel thing / CSS. You should hide the element that contains it, and reveal it in the js hook.
But if you really want to go your way, here's how:
header.php:
...
<body <?php body_class('site-loading no-js'); ?>>
<script>
document.body.className = document.body.className.replace('no-js','has-js');
</script>
...
CSS:
body.site-loading.has-js{
background: #fff url('the/loading.gif') no-repeat center center;
}
body.site-loading.has-js *{
display:none;
}
javascript, assuming jQuery:
jQuery(document).ready(function($){
// do your carousel thing
// should be last line
$('body').removeClass('site-loading');
});
Needless to tell you that any javascript error after the header code I gave you, will keep your site in "loading" mode forever :) | stackexchange-wordpress | {
"answer_score": 0,
"question_score": 0,
"tags": "performance"
} |
I want to enable facebook connect how to do this?
I do not allow users to login to my blog, but I would like to enable facebook connect for those who do not want to enter their details in the comments fields all the time. How should I start doing it?
Enable on wordpress settings user logins, when implement facebook comment and thats it? | Try the new beta version of my Simple Facebook Connect plugin.
<
I prefer this comment implementation over others as mine does not create WordPress users directly from Facebook connected users when just used for commenting. | stackexchange-wordpress | {
"answer_score": 2,
"question_score": 0,
"tags": "facebook"
} |
Change Category Page Display
I have several category pages (e.g. example.com/?cat=3) that display only the post titles. I would like to make them display the post as well. What is the easiest way to do this? | Category pages or archives? If you're a little more specific you will probably get multiple ideas, but in general, if you've got a loop you can use one of the two following functions:
* `<?php the_excerpt(); ?>` will show the custom or default excerpt for the post
* `<?php the_content('Read More »'); ?>` will show the full post with a "Read More" link employed if you've used `<!-- more-->` in your post to show only part of the post on aggregate templates
If you are looking for simple functions for your templates to display content, you should probably read up on the WordPress codex. | stackexchange-wordpress | {
"answer_score": 0,
"question_score": 0,
"tags": "categories"
} |
Test if post has a category
I need to display some HTML only if the post being displayed has a category - not a specific category, just any category at all.
I tried `if (!is_empty(get_the_category($post->ID)))`, but for some reason this isn't working. Has anone else had the same issue? | Use `has_category` instead.
`if (has_category('',$post->ID)) ...`
If you want to use it in The Loop, you don't need to specify the ID.
`if (has_category()) ...` | stackexchange-wordpress | {
"answer_score": 7,
"question_score": 3,
"tags": "categories"
} |
Plugin to assign parent category on multiple taxonomy terms
I've inherited a mess of a WP site. I need to be able to take 100+ categories and rearrange parent/child relationships. I need something with a UI that will make this easy. Anyone know of a plugin that does this? | Perhaps Scribu's Term Management Tools would be of use to you here, it does various tasks including bulk term management. | stackexchange-wordpress | {
"answer_score": 1,
"question_score": 1,
"tags": "taxonomy"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.