INSTRUCTION
stringlengths 11
999
| RESPONSE
stringlengths 0
999
| SOURCE
stringlengths 16
38
| METADATA
dict |
---|---|---|---|
How do you properly prepare a %LIKE% SQL statement?
I'd like to use a LIKE %text% statement while still using the WordPress $wpdb class to sanitize and prepare input.
SELECT column_1 from `prefix_my_table` WHERE column_2 LIKE '%something%';
I've tried something like this to no avail:
$wpdb->prepare( "SELECT column_1 from `{$wpdb->base_prefix}my_table` WHERE column_2 LIKE %s;", like_escape($number_to_put_in_like));
How do you properly prepare a %LIKE% SQL statement using the WordPress database class?
|
The `$wpdb->esc_like` function exists in WordPress because the regular database escaping does not escape `%` and `_` characters. This means you can add them in your arguments to `wpdb::prepare()` without problem. This is also what I see in the core WordPress code:
$wpdb->prepare(" AND $wpdb->usermeta.meta_key = '{$wpdb->prefix}capabilities' AND $wpdb->usermeta.meta_value LIKE %s", '%' . $this->role . '%');
So your code would look like:
$wpdb->prepare(
"SELECT
column_1
FROM
`{$wpdb->base_prefix}my_table`
WHERE
column_2 LIKE %s;",
'%' . $wpdb->esc_like($number_to_put_in_like) . '%'
);
You can also add `%%` in your query to get a literal `%` (`wpdb::prepare()` uses `vsprintf()` in the background, which has this syntax), but remember that **your string will not be quoted** , you must add the quotes yourself (which is not what you usually have to do in `wpdb::prepare()`.
|
stackexchange-wordpress
|
{
"answer_score": 79,
"question_score": 53,
"tags": "mysql, wpdb, sql"
}
|
Prevent five different copies of jquery from being included on every page
Many wordpress theme, plugin, and widget developers seem to think that the only way to use jquery on the page is to include their own copy. On some pages of the site I'm developing, there are as many as _six_ different places where I see various different copies of jquery included. **This is ridiculous.** It increases loading time, and is totally redundant.
Is there any easy way, either through a plugin or a bit of my own coding, to force only _one_ copy of jquery to be included on each page? There's already a `jquery.js` in the `/wp-includes/js/jquery/` directory, which should suffice for any plugin that needs it. How can I automatically remove all of the other references to it on the page?
|
There is no blanket solution to this.
1. If developer has a clue - he will reuse bundled jQuery or re-register it to other copy (commonly done to load jQuery from Google's CDN).
2. Otherwise there are a lot of [insane] ways to add jQuery and there is no way to handle them all without global output buffering or tweaking hooks/plugins individually.
Overall it is often better plugins from good developers than waste time on tweaking poorly coded plugins. But if you already stuck with bunch of poor plugins - you are in for some manual cleanup. :(
|
stackexchange-wordpress
|
{
"answer_score": 4,
"question_score": 2,
"tags": "jquery, javascript, performance"
}
|
get_categories exclusion issues
In the script below i'm trying to pass category IDs to exclude, however, the category list still includes children of these categories and i can't figure what's wrong.
Can anyone see what I could be doing wrong in this script?
$cat_args = get_option('show_empty_cats') ? 'exclude='.ce4_cat().'&exclude_tree='.ce4_cat().'&hide_empty=0' : 'exclude='.ce4_cat().'&exclude_tree='.ce4_cat().'';$categories=get_categories($cat_args);
//$cat_args = 'exclude=1,31&exclude_tree=1,31&hide_empty=0';
$categories = get_categories($cat_args);
for each..., etc
|
Add before your code: `$test_me = ce4_cat(); var_dump($test_me);`
Edit: Easier to read version:
`$test_me = ce4_cat();
echo '<pre>';
print_r($test_me);
echo '</pre>';`
|
stackexchange-wordpress
|
{
"answer_score": 0,
"question_score": 0,
"tags": "plugin development"
}
|
One page - Multiple parents?
I'd like to have the same pages assigned to two different parent pages, to save me making separate pages for two sections that contain mostly the same info. I'm using the WenderHost Subpages widget to generate the side menus.
|
Not possible natively, parent is simply single field in database.
There are plugins that allow to create more complex relationships, such as Posts 2 Posts but it's unlikely to work with just any widget.
Alternatively you can create custom menu with arbitrary structure and use native widget to display it in sidebar.
|
stackexchange-wordpress
|
{
"answer_score": 3,
"question_score": 2,
"tags": "pages"
}
|
Using the "Latest posts" feature on a different site
I want to display the "latest x posts", like you see per default on the index-page, but on a completely different site. E.g. `/blog/`
Installing WP into the directory `/blog/` is not an option, as the other pages will be managed with WP.
Currently I'm using the `NuRelm Get Posts` plugin to get the content of the latest 10 posts, but the styling is really hard to recreate with it.
So, is there any simple solution to use the "Show latest posts" on other sites?
**Edit** : I'm using the `twentyten` theme as basis
|
You could insert the plugin's shortcode into another page, by following the directions here.
<
Alternatively if you don't necessarily need the plugin and simply want to create a page that displays posts, follow the example given here on the codex.
<
Scribu, +1 .. as that's essentially what you were suggesting to.
|
stackexchange-wordpress
|
{
"answer_score": 0,
"question_score": 1,
"tags": "plugins, posts, cms"
}
|
How can I find the cause of theme crashing Apache in Xampplite?
I'm testing a version of my theme in WordPress 3.0 and it crashes Apache each time I try to preview it.
Where can I look to trace the cause of the crash? WP_DEBUG is of no use in this case, since it never gets to that point.
Can I trace errors in XAMPPLITE somewhere?
|
Survey said! Wolf Fence in Alaska.
The basic idea is that you divide your problem space in half by inserting a `print "Hi, Mom!\n"; exit;` (insert your favorite phrase) somewhere near the "middle" of your code. If you get the message, then the bug is beyond where you put the print, so move it farther along in the execution. If you don't get there, move the print earlier.
Lather, rinse, repeat.
If you Choose Wisely about where to put the print you can narrow a 1,000,000 line program down to 1 line in just 20 tries.
This is faster/easier to do from the command line, but it's possible to do it via FTP.
|
stackexchange-wordpress
|
{
"answer_score": 7,
"question_score": 1,
"tags": "errors, xampp, apache"
}
|
Is there a theme function for is_password_protected()?
I'm looking at the function and template references and I'm not seeing a way to test for whether a post is protected. Is there a theme function for (something like) `is_password_protected()`?
I'm already using `add_filter( 'the_password_form', 'custom_password_form' );` to override the default form that shows up, but I want to customize some other aspects of the look when a post is password protected.
|
Yes there is. It's post_password_required:
> Whether post requires password and correct password has been provided.
|
stackexchange-wordpress
|
{
"answer_score": 5,
"question_score": 1,
"tags": "theme development, functions, password"
}
|
htaccess or redirect to cloak portion of a link?
I have an ad rotate plugin installed to display a few ads on my site but the plugin is coded so that it uses the full directory in the ad count link. I would like to know if there's something easy to put in my htacces to cloak the link. So for example:
<
needs to look like:
< (actually any variation of this is fine, I just don't want that full wp-content/plugins/ directory shown in the link).
I've tried a few plugins but not getting the desired results. To recap, I want the link to SHOW as the bottom link, but when clicked, be taken to the top link, and I need that trackerid=# to stay the generated id, so I only want to cloak part of the link. Is there something I can put in my htaccess to do this?
Thanks!
|
What you need to do is set up a custom rewrite. This can change something like ` to `
Here is some **untested** code that might help:
<?php
/*
Plugin Name: Your Plugin
Plugin URI:
Description:
Version: 0.1
Author:
Author URI:
*/
// Add rewrite rule and flush on plugin activation
register_activation_hook( __FILE__, 'ad_rotate_activate' );
function ad_rotate_activate() {
ad_rotate_rewrite();
flush_rewrite_rules();
}
// Flush on plugin deactivation
register_deactivation_hook( __FILE__, 'ad_rotate_deactivate' );
function ad_rotate_deactivate() {
flush_rewrite_rules();
}
// Create new rewrite rule
add_action( 'init', 'ad_rotate_rewrite' );
function ad_rotate_rewrite() {
add_rewrite_rule( 'rotate/([^/]+)','/wp-content/plugins/ad-rotating-plugin/rotate.php?trackerid=$matches[1]','top' );
}
|
stackexchange-wordpress
|
{
"answer_score": 2,
"question_score": 1,
"tags": "permalinks, redirect, htaccess"
}
|
"Apache HTTP Service has stopped working" with WP Query in WordPress 2.9.2
When my script runs the 4th line below in WP 2.9.2, its causing my web app to throw an "Apache HTTP Service has stopped working" error
$cat=get_cat_ID('top-menu');
$catHidden=get_cat_ID('hidden');
$myqueryCurrent = new WP_Query();
$myqueryCurrent->query(array('cat'=>"$cat,-$catHidden",'post__not_in'=>get_option('sticky_posts')));
Do you see something in that 4th line that's incompatible with WP 2.9.2? The code runs fine on the same server under WP 3.0.4
Here's the details of the error:
Problem signature: Problem Event Name: APPCRASH Application Name: httpd.exe Application Version: 2.2.14.0 Application Timestamp: 4aeb9704 Fault Module Name: php5ts.dll Fault Module Version: 5.3.1.0
|
Executing the code you posted results in a crash inside the PHP module. I assume you're running PHP as module inside apache on windows, if the module crashes, apache crashes as well.
Ensure that you're using the right PHP modules here. Are you sure you need the Thread-Safe variant of PHP for apache? Those are reported to not run stable under windows IIRC.
So this might not be related to the wordpress version but to the server configuration.
Hope this answer helps a bit tackling things down.
|
stackexchange-wordpress
|
{
"answer_score": 0,
"question_score": 1,
"tags": "errors, wp query"
}
|
Please give me the rewrite rules for my ugly urls
In functions.php I am adding a rewrite rule for this url:
<
<
And so on...
This is the code I use, can u please give me the rewrite rules to transform my urls into pretty ones?
add_action( 'init', 'wpa5413_init' );
function wpa5413_init() {
// Remember to flush the rules once manually after you added this code!
add_rewrite_rule(
'Please add my rewrite rule',
'Please add my rewrite rule',
'top' );
}
add_filter('query_vars', 'wpa3537_query_vars');
function wpa3537_query_vars($query_vars) {
$query_vars[] = 'currentpage';
return $query_vars;
}
Ty!
|
if you are trying to get
* <
* <
then your function should be
add_action('generate_rewrite_rules', 'currentpage_rewrite_rule_222');
function currentpage_rewrite_rule_222($wp_rewrite){
$newrules = array();
$new_rules['currentpage/(\d*)$'] = 'index.php?currentpage=$matches[1]';
$wp_rewrite->rules = $new_rules + $wp_rewrite->rules;
}
and just keep your query_vars function the way it is.
add_filter('query_vars', 'wpa3537_query_vars');
function wpa3537_query_vars($query_vars) {
$query_vars[] = 'currentpage';
return $query_vars;
}
|
stackexchange-wordpress
|
{
"answer_score": 1,
"question_score": -2,
"tags": "url rewriting, functions, urls, mod rewrite"
}
|
What is the fastest way to generate a unique id number when registering a user
I have a client who wants to register users and give them a unique ID number when they complete registration. (Kind of a member number sort of thing)
Can I just setup the WP member table to start id numbers in the high 10 digit range?
User experience would be:
1. user would visit the site
2. user would register
3. WP would issue an 10 digit id number
|
The `ID` column of the `users` table is `AUTO_INCREMENT`, so you can set the base counter to a high number:
ALTER TABLE wp_users AUTO_INCREMENT = 1000000000;
All new users will have an `ID` that is higher than this value. Calling this operation is safe, if you accidentally set it to a low number either nothing happens (in a `InnoDB` table), or it is set to the highest existing number + 1 (in a `MyISAM` table).
|
stackexchange-wordpress
|
{
"answer_score": 3,
"question_score": 1,
"tags": "database, user registration"
}
|
Multisite behind Varnish
I'm trying to use varnish with a wp 3.0.5 site with Network (Multisite), when I access the varnish URL, I get this message:
Multisite only works without the port number in the URL.
Do I need a custom VCL to make this work? I'm using the same backend config for other wordpress sites that work fine..
If I need to ask this on serverfault, let me know and I'll ask there.
|
I found a fix here: <
You basically need to modify wp-includes/ms-settings.php like this (remove '-' lines; add the '+' line):
@@ -26,18 +26,8 @@
if ( !isset( $current_site ) || !isset( $current_blog ) ) {
+ $_SERVER['HTTP_HOST'] = preg_replace( '|:\d+$|', '', $_SERVER['HTTP_HOST'] );
$domain = addslashes( $_SERVER['HTTP_HOST'] );
- if ( false !== strpos( $domain, ':' ) ) {
- ....
- wp_die( /*WP_I18N_NO_PORT_NUMBER*/'Multisite only works without the port number in the URL.'/*/WP_I18N_NO_PORT_NUMBER*/ );
- }
- }
|
stackexchange-wordpress
|
{
"answer_score": 2,
"question_score": 5,
"tags": "multisite, server, configuration"
}
|
Correct Approach for Validating Custom Field Input
I have a custom post type with several custom fields. I am looking to do some validation on these fields because they will be used downstream by other services. So, it is important that it can't be saved until it is correctly entered. The validation is reasonably complex and requires custom logic.
Unfortunately, it also won't work to use a plugin in this particular case.
Is there an ideal hook to use in this case? At a high level -- whats the best way to go about this.
|
Example code in `add_meta_box()` documentation uses `save_post` hook (at the very end of `wp_insert_post()` function) to add custom fields data from metabox.
You must be using something like that already in your metaboxes, is it not appropriate place to validate your data?..
|
stackexchange-wordpress
|
{
"answer_score": 4,
"question_score": 3,
"tags": "custom field, security, php, input, validation"
}
|
the_tags without hyperlinks?
How can I call the_tags as a list without hyperlinks?
|
<ul>
<?php
$tags = get_tags();
foreach($tags as $tag) {
echo "<li>$tag->name</li>";
}
?>
</ul>
|
stackexchange-wordpress
|
{
"answer_score": 6,
"question_score": 2,
"tags": "theme development"
}
|
Why doesn't my contact form work?
My contact form is here
<
When users submit a message, I receive an e-mail but the spinning waiting sign keeps on spinning and the user does not receive confirmation. What is wrong with the code?
|
From Contact 7 Help:
> The spinning arrow icon shows up once I submit a form, but then nothing happens.
>
> This is most probably due to a conflict between plugins/theme. Try deactivating all other plugins and switching to the default theme.
Also, I have gotten this behavior when you have built your blog at something like mysite/blog and then moved it to simply mysite. You will need to edit the site base url in this case.
|
stackexchange-wordpress
|
{
"answer_score": 2,
"question_score": -2,
"tags": "contact"
}
|
A way to get featuread image or first image and crop on the fly before display
1. In Loop = There exist a way or hook to get the featured image, if not, the the first image from post and cropit before display it on frontend?
2. Re-asking my question: On upload. How do I set a featured crop size for a giving custom post type like: news.
Thanks in advance.
|
In your theme's functions.php add a call add_image_size($name, $width, $height, $crop) where $name is the name or identifier for the new size, and $crop is whether the image should cropped to fit the dimensions or just shrunk to fit within the dimensions given. This will register the new size that will be automatically created when you upload new images:
add_image_size('news-thumbnail', 500, 200, true);
Then in the template file for your news post type, call the specific thumbnail size name:
the_post_thumbnail('news-thumbnail');
|
stackexchange-wordpress
|
{
"answer_score": 2,
"question_score": 0,
"tags": "cropping"
}
|
Protect changes made to the theme when updating
I customized the wordpress theme I'm using by changing php, css and even a js file. Is there a way to protect these changes, when updating the theme to a new version?
|
You can do exactly that by creating Child Theme. It depends on specifics of theme you want to customize and amount of changes how complex will it be to implement, but it is definitely most solid way to implement customization and preserve update capabilities.
|
stackexchange-wordpress
|
{
"answer_score": 4,
"question_score": 1,
"tags": "themes, customization"
}
|
How to defeat "Blog pages show at most __ posts" setting in the loop?
I'm using this script on my archive.php in order to list a link list of all posts contained in the current category. However, its limiting the result count relative to the number assigned to "Settings > Reading > Blog Pages Show At Most ___ posts".
In other words, there may be 10 posts that are in this category, but its only displaying up to the number assigned in that setting.
How can I change my script to ignore this setting?
<?php if(is_category()) while (have_posts()) : the_post(); ?>
<li id="post-<?php the_ID(); ?>">
<a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>">
<?php the_title(); ?>
</a>
<?php echo get_link_excerpt(); ?>
</li>
<?php endwhile; } ?>
|
Instead of using the default loop, perhaps try building your own query.
Basically, it'll look something like this:
$your_posts = get_posts('cat=123&posts_per_page=123');
foreach ($your_post as $post) {
do_something-with($post);
}
You can display all posts by either use the param `'posts_per_page'=>-1` or `nopaging=true`.
(Not sure why someone voted this down? IMHO said person should comment on how the question should be improved if she or he is going to do that.)
|
stackexchange-wordpress
|
{
"answer_score": 2,
"question_score": -1,
"tags": "theme development, loop"
}
|
Using wp_tag_cloud('format=array') to print tag names without links?
I'm trying to pull just the tag names as an array collection in order to write them out as a simple listing, without links, but the array that's returned does not send the name as an indexible item.
array(2) {
[0]=> string(129) "<a href='#' class='tag-link-31' title='1 topic' style='font-size: 8pt;'>tag 1</a>"
[1]=> string(127) "<a href='#' class='tag-link-30' title='1 topic' style='font-size: 8pt;'>tag 2</a>"
}
Is there another method I can use to get the entire site's tag collection with just the tag names? This is my current code, but because of the array indexes, I get the links as well.
$tagNames = wp_tag_cloud('format=array');
echo implode($tagNames,", ");
|
try :
function my_tag_list_123($sep){
$tags = get_tags();
foreach ($tags as $tag){
$ret[]= $tag->name;
}
return implode($sep, $ret);
}
and call it when you need like this
echo my_tag_list_123(',');
hope this helps.
|
stackexchange-wordpress
|
{
"answer_score": 4,
"question_score": 1,
"tags": "theme development, tags"
}
|
Wordpress Theme that returns all posts as a JSON object?
Are there any Wordpress themes that will just return a JSON object that can be processed by Javascript to display a list of postings?
|
Sounds like what JSON API plugin does.
|
stackexchange-wordpress
|
{
"answer_score": 2,
"question_score": 0,
"tags": "theme development"
}
|
How to put page numbers with the next/previous on a post/category list?
Is there a way to add numbering to the latest posts/category listing pages? By default you can put older/newer, but is there a way to add numbering like page 1,2,3,4 of the list so people can skip ahead?
|
Take a look at wp-pagenavi its a plugin which adds advanced paging navigation to your WordPress site just like you asked.
|
stackexchange-wordpress
|
{
"answer_score": 2,
"question_score": 0,
"tags": "categories, posts, feed, pages"
}
|
How do I display content to users who are not logged in instead of 404 on Private custom posts?
I want to display a message like "You must be logged in to view this", with Private custom posts. Theoretically, I want to use something like this:
`if (is_user_logged_in()) {
// Page code goes here
}
else {
echo "You must be logged in to view this page.";
}`
This code is in the single-custom.php page template.
The `true` case works just fine. However, if the user is not logged in, instead of seeing "You must be logged in..." I get a 404 instead? What am I doing wrong?
|
Are you doing this inside The Loop? I'd try something like this myself:
if ($post->post_status == "private" && !is_user_logged_in()) {
echo "You must be logged in to view this page.";
} else if( $post->post_status == "private" && is_user_logged_in() ) {
// Page code goes here
}
|
stackexchange-wordpress
|
{
"answer_score": 1,
"question_score": 1,
"tags": "custom post types, 404 error, private"
}
|
Does wordpress.com appears in the URL if I buy custom domain service from WP.com
Let's say I buy a custom domain myblog.com and I host at wordpress... if I access the dashboard page on my blog, will it have wordpress.com in the URL?
I want to be able to manage my blog behind school firewall.. thanks
|
* try blogging by email
* have your analytics and stats on google analytics or outside source
* have comments emailed to you
that will leave very few things to be done thru administration
to bypass security system try VPN or use of proxy
|
stackexchange-wordpress
|
{
"answer_score": 3,
"question_score": 0,
"tags": "wordpress.com hosting, domain mapping"
}
|
get_usermeta() deprecated in favor of get_user_meta(). But why doesn't it make use of it?
While coding WP I just wondered about this simple fact:
`get_usermeta()` is deprecated since version 3.0. The warning suggests me to use `get_user_meta()`. Even the parameters are pretty similar, I wonder why the deprecated function is not making use of the new function as well.
Isn't that a sign that the new function does not really does what the deprecated did?
I'm wondering because I need to replace deprecated calls and wonder a bit.
What makes me even wondering more is the simple fact that `get_user_meta()` is quite an alias of the 2.9 function `get_metadata()` with only a constant value'ed parameter 'user' given.
Help ;)
_**Edit:_** A counter-example is `clean_url()` \- it's deprecated, the error message shows what this is about and the deprecated function aliases the new one: `esc_url()`, so it's clear what to do.
|
Indeed, `get_usermeta()` behaves differently from `get_user_meta()` and all the other `get_*_meta()` functions. That's why it was deprecated.
Unfortunately, the subtle differences couldn't be explained properly in a deprecation notice.
|
stackexchange-wordpress
|
{
"answer_score": 1,
"question_score": 2,
"tags": "php, user meta"
}
|
How to create a custom loop ordered by Categories on a Page Template?
Ex.
Category 1
Post 1
Post 2
Post 3
Post ....
Category 2
Post 1
Post 2
Post 3
Post ....
Category ....
Post 1
Post 2
Post 3
Post ....
|
Not sure if this is exactly what you're asking, but it sounds like you're looking for nested loops. This will list the most recent 5 posts in every category on your site:
foreach ( get_terms('category') as $category ) {
echo '<h2>'.$category->name.'</h2>';
echo '<ul>';
foreach ( get_posts( 'cat='.$category->term_id ) as $post ) {
setup_postdata( $post );
echo '<li><a href="'.get_permalink($post->ID).'">'.get_the_title().'</a></li>';
}
echo '</ul>';
}
Add the name of the custom post type and any other variables you may want to modify the loop with to the call to `get_posts`. You can look through the Codex page for a list of argument that can be passed.
|
stackexchange-wordpress
|
{
"answer_score": 0,
"question_score": 0,
"tags": "categories, get posts, loop"
}
|
How to run a test WordpressMu to Wordpress3 update?
Currently I am running a wordpress MU site with ~100 blogs. It's Wordpress MU version 2.8.x
Because it was so heavily used, I was asked not to update to Wordpress 3 right away. The users are worried that their plugins and themes may not work once I've upgraded. Indeed, we activated some plugins that I suspect will stop working because there have not been any updates to them in a while.
Other users are anxious to start using Wordpress 3 and the new features.
So, what I have to do now is somehow test what the update will look like, and let users log in to test how their site will look in Wordpress 3.
My question is, what is the best way for me to test the upgrade?
My the root of my Wordpress MU is at mydomain.com, and the sites are in the directory below, such as mydomain.com/henrys-blog
Thanks for your help
|
In this situation, I'd recommend the following:
1. Dump your production database into your test database
2. Install WP 3 and point it at your test DB
3. Run the database upgrade
4. Turn users loose on the test instance
We used a similar process on a much larger installation, and it worked fairly well. Having the second instance made it possible to use our testing resources to verify functionality without depending on the users, too.
|
stackexchange-wordpress
|
{
"answer_score": 1,
"question_score": 0,
"tags": "customization, upgrade, multisite, testing, staging"
}
|
How do I make my navigation bar link to an external page?
My website is wordswithfriends.net
At the moment all of the top navigation menus link to an internal page. I want "Contact Us" to link to an external page ask.wordswithfriends.net
How do I do this in the administration panel? At the moment all I see are options for editing the page
|
It depends on your theme and WP version (you're using 2.9.1 - you should consider upgrading).
You can:
* upgrade to V3+ to use the menu editor that's built in (recommended) more info: <
* hard code your theme template with the link added to the end in the HTML
* modify the theme call to wp_list_pages() function excluding your contact page link (see: <
|
stackexchange-wordpress
|
{
"answer_score": 5,
"question_score": 1,
"tags": "links"
}
|
Wordpress MU 2.9.2 to 3.0.5 changes to category.php
In the latest version of WP I see the category.php page is now using edit-tags.php. The version Im running seems to have an issue with the search feature on this page whereas the new version doesnt. When searching for categories, the results show the category search AND its heirarchy i.e. - categoryname together in the same list. Short of doing a major overhaul and upgrade as one does need to check compatibility, what was changed in the new version that I could update in the old version of my source?
example: I have 5 categorys, 3 parents, 2 children. They all have the word cat in their name. If I search for the word 'cat' I not only get the 5 results, but ALSO another three results with - category name for each of the children again. This is not the case in 3.0.5
|
I feel you on the WPMU -> 3x transition but unfortunately it's going to be hard to troubleshoot the issues without seeing any code (@sanchothefat says something similar in a comment above). I've come up against similiar issues, so let me at least offer some general help in debugging these kinds of things.
Whatever the function in question, go into the SVN and compare code revisions for the function in question. Here's the WPMU 2.9.2 trunk and here's 3.0.5.
Try using a diff tool ("diff file1 file2" on the command line) and see what changed between revisions. Are all the parameters the same? Do those array keys exist in both versions?
To slueth out what your code isn't doing anymore it's helpful to first figure out it _did_ do that is no longer.
|
stackexchange-wordpress
|
{
"answer_score": 1,
"question_score": 0,
"tags": "categories, upgrade, multisite"
}
|
Any Good Wordpress Client Like Live Writer To Create Static Pages
I want to publish static pages on Wordpress quickly. Live Writer is a very good client for formatting and publishing blog posts. But I couldn't find a way to use it for publishing static pages.
Is there any way to publish static pages on Wordpress quickly with an easy to use client?
|
According to the following page Live Writer can manage pages as of Beta2.
<
Maybe it's simply a case of waiting to use the newer version that includes page management?
I don't use WLW myself, but a quick google did garner the above link, so hope it helps.
|
stackexchange-wordpress
|
{
"answer_score": 1,
"question_score": 0,
"tags": "customization, windows live writer"
}
|
How do you modify the 'post_parent' of a custom post type?
I want to be able to edit the post_parent of a custom post type. Basically in my use case I want to mimic how WordPress uses attachments: have a custom post type that is sort of a subtype to post or any other post type. WordPress uses the post_parent field on the wp_posts table to link attachments to their parent posts so I want to be able to do the same. I've tried to use wp_update_posts but it seems to time out the connection when I try to call it during a post save. Is there a way of editing the post_parent directly?
|
Hi **@Manny Fleurmond** :
You can add the following HTML to a **post metabox** you'll have an edit field that lets you edit the raw `post_parent` ID. Maybe with this knowledge you can build what you need?
<input type="text" id="parent_id" name="parent_id"
value="<?php echo $post->post_parent; ?>" />
|
stackexchange-wordpress
|
{
"answer_score": 3,
"question_score": 1,
"tags": "custom post types, attachments"
}
|
jQuery UI in Admin (Best Practice?)
Maybe someone has prior experience with this, but when I include the jQuery UI **1.8.9** file within my `admin_head` I break the functionality of the dashboard (i.e. popup for adding featured image, drag and drop menu items, etc.). If I include **1.7.2** , it doesn't break anymore but then my great little calendar won't work anymore.
So my questions is, currently (3.0.x),what is the best way to implement the jquery UI within admin pages without breaking everything?
( _Other info: trying to add datepicker to a field within my custom post type_ )
Thank you!
Noel
|
WP 3.1 will come with jQuery UI 1.8 so the easiest solution would be to wait.
Also, it sounds like you're outputting the script tag directly. You should try deregistering the bundled jQuery UI version and replacing it with your own.
This is done using wp_deregister_script() and wp_enqueue_script().
|
stackexchange-wordpress
|
{
"answer_score": 6,
"question_score": 3,
"tags": "custom post types, admin, jquery"
}
|
Remove_action inside a function
HI there,
I want to remove the actions added to wp_head by a plugin but only in certain circumstances.
Here is code that doesn't work:
if (is_single() && get_post_type() == 'tenant') {
$row = $wpdb->get_row("SELECT * FROM Events WHERE WP_ID='$post->ID'",ARRAY_A);
remove_action('wp-head',array($aiosp, 'wp_head'));
$seo_head = "<title>" . $row['Event'] . " | " . $row['Town'] .
" | Events in ". $row['Country'] . "</title>";
}
|
Sorted it, turns out all-in-one-seo-pack can be disabled on a post by post basis, so I used: add_post_meta($post->ID,'_aioseop_disable',true); inside the if parameter and before setting my own title, works a charm.
PS $post is gotten with global $post;
|
stackexchange-wordpress
|
{
"answer_score": 0,
"question_score": 0,
"tags": "wp head"
}
|
What happens to the mu-plugins folder when you upgrade to Wordpress 3?
I am about to press the "upgrade" button in my Wordpress MU 2.8 install.
What is going to happen to the mu-plugins folder? And is there an equivalent way for me to automatically activate a plugin across all my sites?
|
WordPress 3 uses the mu-plugins folder in exactly the same way as MU used to use it. Everything in there is automatically active sitewide.
Note that WP 3 has some newer methods for dealing with plugins though that you may want to consider switching to. For example, the Network Activation allows you to install a plugin via the normal means and then activate it sitewide and still use the WP upgrade system to keep it up to date. The mu-plugins method doesn't allow that sort of thing.
|
stackexchange-wordpress
|
{
"answer_score": 1,
"question_score": 0,
"tags": "customization, upgrade, multisite"
}
|
Why won't wp_mail() let me set the From: header when plain old PHP mail() will?
When I use `wp_mail( $to, $subject, $message, $headers )` (with values in place, of course), the email gets sent with a from name and email that isn't set anywhere I can find (not even in PHP or Apache settings). However, using `mail( $to, $subject, $message, $headers )` instead works just fine. What could be happening with `wp_mail()` to cause this?
|
Hi **@helenyhou:**
You can set the header, just not with a parameter. WordPress uses _**"hooks"**_ and the hooks you need are `'wp_mail_from'` and `'wp_mail_from_name'` hooks.
Here are the hooks you might add to your theme's `functions.php` file to modify the `"From:"` header when using `wp_mail()` to the email address `Helen Hou-Sandi <[email protected]>`:
add_filter('wp_mail_from','yoursite_wp_mail_from');
function yoursite_wp_mail_from($content_type) {
return '[email protected]';
}
add_filter('wp_mail_from_name','yoursite_wp_mail_from_name');
function yoursite_wp_mail_from_name($name) {
return 'Helen Hou-Sandi';
}
|
stackexchange-wordpress
|
{
"answer_score": 45,
"question_score": 36,
"tags": "headers, wp mail, email"
}
|
Looking for methods to Check if File Exist
I'm working on a custom theme framework for educational purposes.
I basically have a header.php in a child theme that i want to make smarter. I'd like to only include a stylesheet if the file exist. Getting 404 errors is not cool or efficient.
Are there native php or wordpress functions to check if a wordpress file exist.
Basically... **I want to output**
`<link rel="stylesheet" href="<?php echo get_stylesheet_directory_uri(); ?>/css/<?php echo get_stylesheet() ?>.css" type="text/css" media="screen" />`
**Only If** the stylesheet with the same name as the folder containing the child theme exist.
Any ideas would be awesome :-)
|
There's a lot of ways you could go with this. I might enqueue the style in your theme's functions.php dependent on a `file_exists()` check.
$your_css_file_path = "/path/to/file";
if ( file_exists($your_css_file_path) ) {
wp_register_style('your_theme_stylesheet', $your_css_file_path);
wp_enqueue_style( 'your_theme_stylesheet');
}
Here's the relavent core source.
|
stackexchange-wordpress
|
{
"answer_score": 3,
"question_score": 1,
"tags": "css"
}
|
More quicktag driving me nuts
I'm a bit confused.
I have my own custom post type - products.
I'm listing all the products on page-products.php.
Every product has also it's own page - single-products.php.
And the big and strange thing is... I'm using more quicktag:
<!-- more -->
And it doesn't work on both single-products and page-products! I don't care about single page, but I'd love to use on the page-products listing. And I'm not able to.
Documentation says:
> The MORE quicktag will not operate and is ignored in Templates, such as single.php, where just one post is displayed.
<
So is it perfectly normal to not work for me in both cases? As far as I understand it should work in the first case... Is there a way to force more quicktag to display there?
And yes, in both cases more "produces" perfect more span... But even content after the span is being shown...
Thank you!
|
The "read more" link is essentially a navigational device meant to point visitors to a full version of a piece of some excerpted content. A single.php of any post type is the full version, therefore it is 100% in the nature of `<!-- more -->` to not appear on single custom post type pages.
If you're just looking to display a snippit of your content, check out the_excerpt().
|
stackexchange-wordpress
|
{
"answer_score": 0,
"question_score": 0,
"tags": "custom post types, read more"
}
|
Solve product properties with custom taxonomies?
I need to add about 50 properties to a product, such as heigh, width, location etc. I created custom taxonomies for every property and ran into serious problems.
First of all, the UI is a mess! Every taxonomy uses to much space. Some of the propertys should be presented to the user with radio buttons, checkboxes and dropwdowns.
What is the best practice? Use custom fields instead and lose the taxonomy functionality?
|
For each propery, ask yourself these questions:
1. Is it likely that, on average, more than 1-2 posts will have the same value for this property?
2. If so, do I need to filter posts based on this property, or is it just for display?
If you answered both with 'yes', then make it a taxonomy, otherwise a custom field.
Whichever you choose, you can make a custom metabox for that individual property, or several metaboxes that group related properties together. Whatever makes more sense.
|
stackexchange-wordpress
|
{
"answer_score": 5,
"question_score": 1,
"tags": "custom taxonomy, custom field"
}
|
Multiple Wordpress Blogs on one host, using 1 WordPress installation, using multiple templates
Hay, I was wondering if this is possible. I have a company called dotty. The domain for this company is dotty.com. However, my company has many subcompanies (company_1, company_2). Is it possible using WordPress to manage all these subcompanies within one WordPress installation? Each company needs to have it's own template, and the URL's will end up something like this
dotty.com
dotty.com/company_1
dotty.com/company_2
and i can manage them all from
dotty.com/wp-admin
|
Use a WordPress Network. This is one installation with unlimited numbers of blogs, all controlled, to a point, by the central dashboard. See Create A Network - WordPress Codex
|
stackexchange-wordpress
|
{
"answer_score": 6,
"question_score": 1,
"tags": "multisite"
}
|
WP 3.0.5 - Custom posts matching 2 taxonomies
I'm running a WP 3.0.5 website and here is my problem: I define a custom post type with 2 custom taxonomies and I've got to develop a search engine based upon these taxonomies. Until there, no problem :
$args = array(
'my_post_type' => 'post_type_name',
'my_taxo_1' => 'taxo-1-slug',
'my_taxo_2' => 'taxo-2-slug'
);
query_posts( $args );
Working like a charm! But... What I want is to retrieve only custom posts matching both taxonomies whereas here, only 1 is sufficient.
I saw WP 3.1 is introducing a new way dealing with taxonomies ( which will absolutely solve my problem but WP 3.1 is still in beta and I can't take risk for my customer.
Thanks for your help !
|
You can do this in 3.0 with the Query Multiple Taxonomies plugin.
|
stackexchange-wordpress
|
{
"answer_score": 2,
"question_score": 1,
"tags": "custom post types, custom taxonomy"
}
|
Forum-esque Post Count User Ranks (Without Buddypress)
My client is looking for a ranking system similar to a forum. As your post count goes up, your "title" changes. I think Buddypress offers something along these lines but we're at the end stage and he doesn't want to take the extra time to let me convert it to a buddypress system. Are there other plugins that can do this? Or maybe someone can suggest some code to use with User Role Editor?
Thanks
|
I know i have something like that and I'll post it as soon as i get home.
## Update
Bit late I know , but since i jumped a head and said i have something like that, and i just couldn't find it i wrote something from scratch.
**Bainternet User Ranks**
!enter image description here
After you install and activate, configre it a bit and you can use it like this:
<?php $baur_plugin = new baur_Plugin();
$user_rank = $baur_plugin->ba_get_user_points($user_id,true);
echo "title: ". $user_rank['title'] . "Points: " . $user_rank['points'];?>
Enjoy!
|
stackexchange-wordpress
|
{
"answer_score": 3,
"question_score": 2,
"tags": "plugin recommendation"
}
|
Permalinks not working using wordPress Networking with custom post types
Hay All, I've setup a WordPress network and have a couple of websites. Within these 'sub-websites' have a created a new custom post type called 'courses'. When i create a new 'course' a sample permalink would be
www.mysite.com/site1/course/my-course-name
However, this doesn't link to the article in the question. Is this a normal error with wordpress?
How, can i fix this? I think there's an issue with the .htaccess file WP generated for me.
|
I wrote a post about it a week ago < But a simple save changes in the permalink admin panel should fix it for you.
|
stackexchange-wordpress
|
{
"answer_score": 3,
"question_score": 1,
"tags": "multisite, permalinks"
}
|
Why does wp_get_object_terms add a period after terms are output?
I'm using the following line to output an unordered list of taxonomies and their associated terms for a custom post type. The only problem with it is that a period gets added after the term.
wp_get_object_terms( $id, the_taxonomies( 'before=<ul><li>&sep=</li><li>&after=</li></ul>' ) );
Here's what it outputs:
<ul><li>Taxname: <a href='
Is there an argument I can add to `wp_get_object_terms` to remove the period?
|
wp_get_object_terms() isn't the problem. the_taxonomies() is doing the outputting; it doesn't return anything.
So, your code is equivalent to:
the_taxonomies( 'before=<ul><li>&sep=</li><li>&after=</li></ul>' );
wp_get_object_terms( $id, null );
Now, if you go to wp-includes/taxonomy.php you will find the dot in the_taxonomies() source.
To remove the dot, you need to add a filter:
function remove_the_dot($template) {
return '%s: %l';
}
add_filter('taxonomy_template', 'remove_the_dot');
In case you're wondering, yes, this _is_ an akward way of doing things.
In WP 3.1, you can modify the template simply by passing it as a parameter:
the_taxonomies( array(
'before' => '<ul><li>',
'sep' => '</li><li>',
'after' => '</li></ul>',
'template' => '%s: %l'
) );
|
stackexchange-wordpress
|
{
"answer_score": 4,
"question_score": 0,
"tags": "terms, taxonomy"
}
|
Wordpress MailChimp Framework suddenly stopped working without modification
I had a WordPress webshop setup, and I am using the [MailChimp Framework plugin][1] for sending newsletter, among other things. Now, the setup has been running since January 1st, then all of the sudden the Mailchimp framework suddenly stopped sending. The "Everything's Chimpy" ping status does not appear as well, sometimes it's NULL, sometimes it's garbage character. I am pretty sure I haven't touched any code of the plugin, and a colleague having a totally different project has experienced it as well.
Also, I remember their reply used to be "text/json", but now I see a reply with Content-type "application/json".
Is any one of you experiencing this as well?
Update: Mailchimp API responded:
<
<
There seems to be a problem with connections being suddenly being dropped at mid-call. They have updated the MCAPI wrapper. I haven't tested this yet.
|
Well, it seems that the author of Wordpress MailChimp Framework is on indefinite vacation. So I suggest to you having the same problem as this one is to go through the PHP MCAPI wrapper ( since this one is directly supported by the MailChimp team. The team has updated the wrapper to handle dropped connections.
And yeah, forget about the Wordpress MailChimp Framework if you want your sanity.
|
stackexchange-wordpress
|
{
"answer_score": 0,
"question_score": 0,
"tags": "plugin mailchimp"
}
|
How do I get only the image URL from the_post_thumbnail()?
I want to know how to get just the image URL from `the_post_thumbnail()`. The default output of `the_post_thumbnail()` is:
<img width="800" height="533" src=" class="attachment-post-thumbnail wp-post-image" alt="book06" title="book06" />
Here I want grab the `src` only. How do I filter `the_post_thumbnail()` to get only `
|
You might also try:
If you only have one size thumbnail:
$thumbnail = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ) );
Or...if you have multiple sizes:
$thumbnail = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), "size" );
Note that wp_get_attachment_image_src() returns an array: url, width, height, is_intermediate.
So if you just want only the image url:
echo $thumbnail[0];
Resources:
* <
* <
|
stackexchange-wordpress
|
{
"answer_score": 42,
"question_score": 34,
"tags": "post thumbnails"
}
|
How to add custom template tag in wordpress theme?
I am working on a WordPress site, it's an online newspaper site.
The theme I am developing, I want to add custom template functions like `get_footer()` or `get_header()`, so that I can save those HTML and PHP codes like the way `footer.php` stores.
Thanks in advance.
|
You can define your function in the file function.php and use it later in your theme.
|
stackexchange-wordpress
|
{
"answer_score": 1,
"question_score": 2,
"tags": "theme development, functions, customization"
}
|
create new user role for reader
is there a way to add a new user role? I need two kind of readers:
1. can read all private posts
2. can read just private posts from a specific category.
Subscriber as described here could be fair enough to satisfy the first kind of reader. Then what I need is to define something less than subscriber, once I can test if a user has this new role for me it's ok.
|
this plugin should help you with what you need and more <
|
stackexchange-wordpress
|
{
"answer_score": 1,
"question_score": 0,
"tags": "user roles"
}
|
How to determine if theres a next page
I am new to wordpress development, just trying to convert my HTML into a WordPress theme, I started with Chris Coyer's blank theme.
<div class="navigation">
<div class="next-posts">
<?php next_posts_link('« Older Entries') ?>
</div>
<div class="prev-posts">
<?php previous_posts_link('Newer Entries »') ?>
</div>
</div>
How can I output the div only if there is a `next_posts_link()`. I need this as I will be using `<ul>` for my pagination. If I don't do that, I will get an empty bullet
|
You can use `get_previous_posts_link` and `get_next_posts_link` to determine if they exists like this:
$prev_link = get_previous_posts_link(__('« Older Entries'));
$next_link = get_next_posts_link(__('Newer Entries »'));
// as suggested in comments
if ($prev_link || $next_link) {
echo '<ul class="navigation">';
if ($prev_link){
echo '<li>'.$prev_link .'</li>';
}
if ($next_link){
echo '<li>'.$next_link .'</li>';
}
echo '</ul>';
}
Hope This Helps
|
stackexchange-wordpress
|
{
"answer_score": 20,
"question_score": 18,
"tags": "pagination"
}
|
Code to determine WP version check
I'm unable to devine what's causing my theme to crash in WP 2.9.2, although I know its something in my query statement below, so I need to do a version check for (version) < 3 to branch it.
What is the method to get the currently installed WP version? - I'm just using "wp_version" as a stand in :)
if(wp_version < 3)
$myqueryTopMenu = '';
else
$myqueryTopMenu = new WP_Query();$myqueryTopMenu->query(array('cat' => "$cat,-$catHidden",'post_not_in' => get_option('sticky_posts')));
|
`get_bloginfo( 'version' )`
Other version globals can be found in wp-includes/version.php
Also, it's safer to use PHP's version_compare().
|
stackexchange-wordpress
|
{
"answer_score": 6,
"question_score": 0,
"tags": "theme development"
}
|
Server-side subscribe by email?
Is there a server-side email solution that will allow users to subscribe to updates via email and, specifically, also be able to do this by category?
I'm aware of Aweber and Feedburner being able to provide this kind of functionality, but my client has requested this as a server-side solution, with a database on-site.
Any suggestions?
|
I found Mailpress to be a far superior option to the others I tried (Post Notification and Subscribe 2). It has many options, it's own set of additional plugins, its own themes, and the option to sync subscribers with your userbase.
10/10!
|
stackexchange-wordpress
|
{
"answer_score": 2,
"question_score": 2,
"tags": "plugins, categories, email, feed, subscription"
}
|
Any dummy content I can use for development?
I tried using <
but when I try using it, I get something like
> An error occurred: Field 'to_ping' doesn't have a default valueAn error occurred: Field 'to_ping' doesn't have a default valueAn error occurred: Field 'to_ping' doesn't have a default valueAn error occurred: Field 'to_ping' doesn't have a default valueAn error occurred: Field 'to_ping' doesn't have a default value
Is it the plugin or is it my WordPress (which is new? 3.0.5 just downloaded)
Perhaps there are other Dummy content available
|
Might wish to try the theme unit tests for creating test/dummy content.
Just note, some of the images in the unit test may have incorrect URLs, they were for me(but should be relatively easy to correct - i can give you the URLs if you need them, i've fixed them in my installation - i just can't remember specifically which ones right now).
|
stackexchange-wordpress
|
{
"answer_score": 1,
"question_score": 1,
"tags": "theme development"
}
|
How to enable custom fields for pages (if not a bad practice)?
My main page has a intro image beside the main content.
I would like to add that image using custom fields.
I've noticed that pages don't have. I would like to enable them.
Is it a bad practice?
|
Pages do have Custom Fields enabled by default on WordPress. If you're not seeing them on the "New/Edit Page" page, then check the "Screen Options" pull down tab on the upper right corner of your Dashboard. See if "custom fields" is checked.
|
stackexchange-wordpress
|
{
"answer_score": 20,
"question_score": 13,
"tags": "custom field, pages"
}
|
Make sub menu items a main link in the admin menu using fuctions.php
I am trying to customize the admin area using the functions.php file to make things easier for my clients. One request I have got before and hope to be able to accomplish, is to move some of the sub menus into the main navigation.
For instance I would like to make Widgets and Menus appear in the main navigation as opposed to being a submenu for Appearances. I would then end up removing the Appearances tab all together.
I have been able to remove the tab but unable to make the new buttons for Widgets and Menus. Even if I can get help of not technically moving them but instead creating a new button and setting the link myself (ex. for Menus -> /nav-menus.php).
Is any of that possible?
Thanks
|
OK, it's a bit messy, but it works. Take a look
function remove_submenus() {
global $submenu;
unset($submenu['themes.php'][10]); // Removes Menu
}
add_action('admin_menu', 'remove_submenus');
function new_nav_menu () {
global $menu;
$menu[99] = array('', 'read', 'separator', '', 'menu-top menu-nav');
add_menu_page(__('Nav Menus', 'mav-menus'), __('Nav Menus', 'nav-menus'), 'edit_themes', 'nav-menus.php', '', 99);
}
add_action('admin_menu', 'new_nav_menu');
Essentially it is removing the nav menu settings from the Appearance sub-panel, then re-adding it as a top level page (similar to a plugin). You can set an icon URL in there as well. The only part I can't get working the way I want is the positioning.
|
stackexchange-wordpress
|
{
"answer_score": 4,
"question_score": 3,
"tags": "wp admin, admin, functions, admin menu, dashboard"
}
|
How to add RSS Icon/link as a widget?
When I search plug-ins for RSS, so many of them are dealing with pulling in RSS feeds. I just want an RSS icon to let people subscribe to my feed? I'm also using FeedBurner. I looked for Feedburner plugins as well, but still confused what is simple and best.
Shouldn't all blogs have an RSS icon? Or is that simply a matter of the theme? Seems like the default 2010 theme would even have that.
|
It is matter of theme, unlike technical links for browser discovery (that make RSS show up in browser address bar) there is no convention on how to present RSS links in page. So that completely up to designer/web master.
The simplest way is putting together HTML for link (or taking FeedBurner's snippet) and putting it into text widget.
|
stackexchange-wordpress
|
{
"answer_score": 1,
"question_score": 0,
"tags": "rss, icon"
}
|
Any way to change the actual filename of an image from media manager?
The default WP media manager does not appear to offer the ability to change an image's filename.
Are there any plugins available that allow this functionality?
|
Try the Media File Renamer.
|
stackexchange-wordpress
|
{
"answer_score": 2,
"question_score": 1,
"tags": "plugins, media library"
}
|
How to know if I am on 1st page
How can I find out if I am on the 1st page of my home page.
I have my page setup like below where I want to display the 1st 2 posts taking up full width. then the rest 1/2. But I want this behaviour on the 1st page only, how can I do that? What condition do I use?
|
I'm assuming that you're talking about the "home page" when you say "1st page only". Or are you talking about the first "paginated" page of your posts? If its the prior, you'd probably want to use the "is_front_page()" conditional if you're using a single page.php template.
Or maybe it'd be easier to make a "page-home.php" template and do some sort of new query of your posts...just for that page. Would that work?
|
stackexchange-wordpress
|
{
"answer_score": 1,
"question_score": 0,
"tags": "theme development, pagination"
}
|
Notification mail about high memory usage?
I received a shocking mail from my WordPress site, don't know what to do,
Can anyone help me out in this
> Subject: [Online MBA] High memory usage notification Sent: Feb 13, 2011 11:33 PM
>
> WordPress memory usage exceeded 64 MB
> WordPress peak memory usage: 114.87 MB
> Number of database queries: 173
|
This mail seems to come from the TPC! Memory Usage plugin. The description includes _Send e-mail notification if memory usage reaches threshold setting_ , and it seems that is what happened here. Either change your plugins so they use less memory, increase the notification limit, or remove this plugin.
|
stackexchange-wordpress
|
{
"answer_score": 1,
"question_score": 1,
"tags": "memory"
}
|
How to implement pagination eg. newer - 3 - 4 - 5 - 6 - 7 - older
How can I implement pagination like shown in the title perhaps something similar to most sites
 and view the site, but I don't want the site to be available to the public while it's in the editing stages.
Can anyone suggest a good way to prevent access to the public (for example a "coming soon" page, but access to the main site via a password; or perhaps put the wordpress installation in a subdirectory while the site is in the editing stages, and then use url rewriting to redirect the root directory to the subdirectory when the site goes live).
I should mention that I'm relatively new to wordpress, so if this kind of functionality is built in I apologise for asking the question.
|
I also have had problems with the maintenance plugins. What you can do instead (if you are familiar with HTML) is create a simple "Closed for Maintenance" page. Save the page as **xindex.html**. Upload the xindex.page to the same directory as your WordPress installation.
You Wordpress installation comes with two files index.html and index.php. While you are working or doing maintenance to your site, first rename the existing **index.html** file as realindex.html then rename the xindex.html that you uploaded as index.html. This will replace the Wordpress homepage with your maintenance page.
When you are finished working and are ready to display your site, reverse your steps. Rename the current index.html back to xindex.html and change realindex.html back to index.html. Sounds more complex than it is in practice, but it entirely avoids buggy plugins.
Here's a link to my maintenance page. You can copy the source. Closed for Maintenance
|
stackexchange-wordpress
|
{
"answer_score": 2,
"question_score": 2,
"tags": "redirect, cms, url rewriting"
}
|
How to find if a post with custom_field == X exists?
I need to find if a post with a custom field X equal to Y exists in a wordpress installation.
Should I do it with a simple sql query or is there something build in that can help me achieve it?
|
You can use the WP_Query(); to check that like this:
$my_query = new WP_Query();
$my_query->query(array( 'meta_key' => 'X', 'meta_value' => 'Y'));
if ( $my_query->have_posts() ){
//it exists
} else {
//it's not here
}
Hope this helps.
|
stackexchange-wordpress
|
{
"answer_score": 5,
"question_score": 2,
"tags": "customization, database, mysql, wp query, query"
}
|
Switching themes without losing widgets?
The other day, I switched from 2010 default them to Semiologic, then back. When back to the 2010, all my appearance/widgets had gone back to the default.
Does this often happen? What is the best practice? Should I always do a database backup before trying new themes, then restore if I don't like it? Or is there something simple I might have missed?
|
Storing widgets is complex topic. Basically it is such a multi-level-array-mess on the inside that very few people try to make sense of it (and even fewer succeed). :)
As far as I understand it myself while we can manipulate cute sidebar names on the surface, deep inside it is getting deconstructed to numerical IDs. So when you switch between themes amount and order of available IDs shift and widgets go haywire.
In theory any widget that can't find its designated place is supposed to land in "Inactive Widgets" area. In practice - who knows. I experienced widgets disappearing, appearing, duplicating and whatever.
So if you have any kind of complex widget setup I highly recommend not to experiment with themes on it. I have stockpiled idea to do reliable widget import/export, but it will take me plenty more time to gather enough courage to touch that. Did I say it is a mess inside? :)
|
stackexchange-wordpress
|
{
"answer_score": 10,
"question_score": 6,
"tags": "themes, widgets"
}
|
List Category Posts plugin upgrade fails with fatal error
I just tried an automatic upgrade of List Category Posts plugin to version 0.17.2 on WordPress 3.0.5. I think I had 0.17.1 before. It installed but failed to activate:
Plugin could not be activated because it triggered a fatal error.
Parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /hsphere/local/home/carrollp/clanecommunity.ie/wp-content/plugins/list-category-posts/include/CatListDisplayer.php on line 10
If I understand correctly author has requested issues be posted here.
I've never debugged WordPress before. Appreciate any help. My site home page is relying on this plugin. Thanks!
|
Yes, I've asked for issues to be reported here, so that you can get answers from the larger community of WordPress users and developers at WordPress Answers.
Regarding the issue, other user also reported it, and it is due to the webhost using PHP 4. Line 10 of CatListDisplayer.php declares a private attribute. PHP 4 doesn't have public, private or protected accessors.
Is there a way to ask your webhosting provider to update your server to PHP 5?
The other possible solution is to download the previous version of the plugin: 0.16, which doesn't use Object Oriented PHP.
|
stackexchange-wordpress
|
{
"answer_score": 2,
"question_score": 2,
"tags": "errors, upgrade, plugin list category post"
}
|
is_plugin_active function doesn't exist
I'm using WordPress 3.0.5 and have tested with 3.1rc4. In the main PHP file of my plugin, when I try to call is_plugin_active I get `Call to undefined function is_plugin_active()`. I can call add_action and add_filter. What should I check/change to fix this?
This is happening inside of the admin on the Plugins page. At the top of my main plugin file I have, `if (function_exists('is_plugin_active')) {` which always returns false.
I also can't see the functions from my main plugin file in other plugins (if that helps any).
|
That's because the file in which is_plugin_active() is defined - `wp-admin/includes/plugin.php` \- is only loaded in the admin, after your plugin is loaded.
Thus, you can only call it after 'admin_init' has fired:
function check_some_other_plugin() {
if ( is_plugin_active('some-plugin.php') ) {
...
}
}
add_action( 'admin_init', 'check_some_other_plugin' );
|
stackexchange-wordpress
|
{
"answer_score": 41,
"question_score": 26,
"tags": "plugins, customization, plugin development"
}
|
How to change the WordPress favicon?
I'm looking for a way to change the WordPress favicon. Any hints how to do this?
|
You should add it on your theme's header.php file with this code (W3C standard code):
<link rel="icon" type="image/png" href="
|
stackexchange-wordpress
|
{
"answer_score": 7,
"question_score": 2,
"tags": "favicon"
}
|
Is There a WordPress Hook to Filter the Edit Posts View?
I want to be able to customize the WordPress edit posts screen to filter based on a custom field (or whatever).
Unfortunately I'm not sure what filter or hook to use here, and instead of opening the code myself, figured I'd throw the question out here.
Just to be clear, I'm talking about this screen. Essentially I want to be able to add a new "tab" next to Drafts, Pending, etc.
!enter image description here
**Update** After testing this, here's the solution:
add_filter( 'parse_query', 'filter_post_edit_screen' );
function filter_post_edit_screen($query) {
global $pagenow;
if (is_admin() && $pagenow=='edit.php'){
$query->query_vars['category__not_in'] = array(120,9999);
}
return $query;
}
That's it. Just paste that into a plugin. Obviously you'd tweak the category IDs or add some more substantial code.
|
You need a to use a few hooks for that
take a look at mike's answer to a similar question.
Hope this Helps
|
stackexchange-wordpress
|
{
"answer_score": 4,
"question_score": 6,
"tags": "plugins, plugin development, wp admin, admin"
}
|
404 Error on form submission within custom post type
I'm trying to create a forum system using WP's custom post types - two post types as Topic/Reply and a Forum taxonomy.
I have created a singular template for the topic post type, in which I added a reply form. The problem is that when I submit the form I get a 404 page.
This is the form template:
<div class="topic-reply-form">
<form method="post" name="topic-reply-form" class="topic-reply-form clear-block" action="<?php echo home_url('/'); ?>">
<p><?php _ae("Add reply"); ?></p>
<fieldset>
<textarea id="reply-content" name="content" cols="50" rows="6"></textarea>
<input type="hidden" name="topic" value="<?php the_ID(); ?>" />
<?php wp_nonce_field('new-topic-reply'); ?>
<input type="submit" value="Publish" id="reply-submit" name="reply-submit" />
</fieldset>
</form>
</div>
Any ideas why this is happening?
|
it was the "topic" name field. It seems you can't use reserved terms in $_POST, and "topic" is a post type name, so its probably one of them...
|
stackexchange-wordpress
|
{
"answer_score": 2,
"question_score": 0,
"tags": "custom post types, customization, 404 error, forms"
}
|
add_meta_box() to Category Edit Screen?
I've got a plugin that attaches itself to both the post and page editors to read and write to the post_content object. I'd like to also attach my plugin to the category manager edit screen.
In the code below, lines 1 and 2 attach it to the post and page editor, but line 3, a shot in the dark, is not yet doing the trick. Any ideas on the proper way to do it?
if ( function_exists('add_meta_box') ) {
add_meta_box('My-plugin', __('My plugin'), 'My_plugin_callback', 'post', 'side', 'high');
add_meta_box('My-plugin', __('My plugin'), 'My_plugin_callback', 'page', 'side', 'high');
//??? add_meta_box('My-plugin', __('My plugin'), 'My_plugin_callback', 'category', 'side', 'high');
}
|
I'm pretty sure that even if you add that meta box at the bottom of the category edit you will still have the problem of meta table for categories, and i bet that your meta_box 'save' function saves as postmeta data table.
However this can be done using the options table here is an how to add extra fields to categories
Hope this helps
|
stackexchange-wordpress
|
{
"answer_score": 3,
"question_score": 1,
"tags": "plugin development"
}
|
WordPress.com vs WordPress.org
This question might seem a little silly but I was wondering what is the differences between WP.com and WP.org?
I know the main differences like you can't edit a them file without paying for it, you might get some ads and you get a youname.wordpress.com domain but what are the little features that make the difference.
|
* WordPress.com is **web service**.
* WordPress.org is **software product**.
Think bus vs car. You can ride both, but bus is owned by someone else and what you can do with it is limited.
|
stackexchange-wordpress
|
{
"answer_score": 2,
"question_score": 1,
"tags": "wordpress.com hosting, wordpress.org"
}
|
Permalink opens attachment instead of page
I recently moved a blog from one host to another and now have a problem with a permalink - rather than opening up a page, it now opens an attachment.
The blog is using WP 3.0.4, running on PHP 5 and IIS 7.0. The permalinks are set to use "/%postname%/" and the web.config is as suggested in the Codex. The blog was moved using the WP export and import tools.
Previously < opened up a page called map, but it is now opening < Does anyone know how to change this behaviour?
Thanks, Jon.
|
Attachments are stored with their filename (minus extension) as the post name. So if you uploaded an attachment that's called map.xyz, it would have the same name as your page.
So first, check your Media Library if you have a 'map' attachment. Secondly, check if your 'map' page still exists and still has the same slug.
When wordpress tries to resolve your request, it can't figure if your are referring to a post(/attachment) or a page.
I would imagine that wordpress also does some slug mingling in the process of importing an export to avoid duplication of post names. It may have imported the attachment first and the page after and mingled your page name into something else.
Try using /posts/%postname%/ for your permalinks, this will distinguish them from pages.
Also read: <
|
stackexchange-wordpress
|
{
"answer_score": 4,
"question_score": 0,
"tags": "permalinks, pages, iis"
}
|
Wordpress on a local machine redirecting to online url
i've downloaded a wordpress web to my local machine and tried setting it up. the problem: when trying to login, wordpress will always redirect to the online url. the only way i found was changing the siteurl manually in phpmyadmin to my local machine's ip address. is there a better solution? the problem about doing that is that permalinks won't work anymore locally.
thanks
|
Open up your `wp-config.php` file
Try adding the following to it:
define( 'WP_SITEURL', ' );
define( 'WP_HOME', ' );
|
stackexchange-wordpress
|
{
"answer_score": 16,
"question_score": 7,
"tags": "local installation"
}
|
homepage loading too slow
I transferred a website to VPS and when I open that website, the home page takes too long to load, for me its taking 30-35 secs just to display the home page, but when I navigate the internal pages it loads in normal speed, I also tried this when all of my plugins were deactivated, but no change, it was taking time to load.
|
There was a thread on wp-hackers in December which could be related: Avoid query_post on frontpage on wp initialization. You may give Sergey Biryukov’s code a try:
> I was able to cancel the initial query with this code in the active theme's functions.php file:
function cancel_first_query() {
remove_filter('posts_request', 'cancel_first_query');
return '';
}
add_filter('posts_request', 'cancel_first_query');
|
stackexchange-wordpress
|
{
"answer_score": 1,
"question_score": 0,
"tags": "homepage"
}
|
Is there any way to pass messages from a script to a redirect target in a hidden fashion?
I'm trying to pass error messages or regular messages from a page that processes a form post request to the page it then redirects to (after processing).
Since i want to get rid of the POST request header (you know...browsers trying to repost on page reload), i need to redirect (no include or using same page, possible). Or can i somehow get rid of the POST request header?
I'm wondering if there's any non-visible way of passing my messages to the next page, since i can't use $_SESSION and don't want to use GET request parameters.
Thanks.
|
Hehe, got it meself, just a little too late, unfortunately, now i have to change half the stuff again...
set_transient(), get_transient() and delete_transient() will be my friends
Edit: More on this...i now realized that my wp_options table is full of _transient_xyz records, coming from WP itself. So that indicates that WP is using the db to store these transients, which isn't ideal. Haven't done the research, yet, but i hope WP cleans this up in regular intervals.
|
stackexchange-wordpress
|
{
"answer_score": 1,
"question_score": 0,
"tags": "plugin development, redirect, errors"
}
|
Use WordPress' URL rewrite engine
I'm developing a web application with user submissions, i'm not too hot on mod-rewrite and was hoping there is a way to utilise WordPress' amazing rewrite engine and incorporate this somehow into my PHP/AJAX web application?
|
I suggest you don't try to take out the `WP_Rewrite` class and re-use it in your application, but look at other frameworks instead. Many MVC frameworks have nice rewrite engines, that not only offer more flexibility in handling incoming URLs, but also generating internal links according to these formats.
The WordPress rewrite system is tightly coupled to the rest of the code, and for all the effort it would take to rip it out, you can just as easily have learned how to use a "real" framework.
|
stackexchange-wordpress
|
{
"answer_score": 4,
"question_score": 1,
"tags": "php, url rewriting"
}
|
What are some good Apache settings to use with wordpress?
My server has 756m of RAM. Every few days I get
[error] server reached MaxClients setting, consider raising the MaxClients setting
|
Just to break cycle of "doesn't belong here".
WordPress basically has no specific requirements for web server itself (which doesn't even have to be Apache), aside from permalinks.
The message you are getting seems to be performance-related and may or may not be connected to you using WordPress. For starters check if your traffic had recently increased and ask your hosting if they recommend specific Apache configuration for your hardware and traffic.
|
stackexchange-wordpress
|
{
"answer_score": 4,
"question_score": 2,
"tags": "apache"
}
|
Codex Version Focus on Production or Nightly?
The function get_users_of_blog() is to be deprecated in WP 3.1.0 but the current production release is 3.0.5.
Does it make since to have the documentation reflect a nightly change when the production version of get_users_of_blog() is still the primary function used to fetch a list of users? Or is it fine so long as the version it is deprecated is listed on the article?
I reverted the page back to reflect that it was not deprecated but it was reverted quickly back to it's original state. I'm probably just missing something and was hoping someone would shed some light on this.
**EDIT**
@kaiser pointed out that the codex is a wild-west of sorts, some articles are up-to-future to 3.1, up-to-date with 3.0.5, and others are very outdated.
Refocusing my question, what should be the best practice for documentation on a popular framework like Wordpress that does have public nightly builds?
|
The codex is some kind of a mess. General behavior is to let users (re)write it and then go over it and change what they (whoever this is) think. Ex. The Codex lacks a lot of functions in the function reference. On some places you already got the 3.1 explanations, on other completely outdated stuff. Sometimes you'll find two versions (current and future) or existing empty pages for template tags coming in the future.
|
stackexchange-wordpress
|
{
"answer_score": 3,
"question_score": 0,
"tags": "plugin development, documentation, codex"
}
|
Header image is overlapping sidebar?
I just changed my header from a background to an image, as that seemed to be the easiest way to link the entire header to my main page (after a whole lot of trial and error with other methods). The one problem is that the image is now overlapping my sidebar instead of the other way around. It's also overlapping some of my menu bar, but it's a part that I can live with or possibly fix myself.
Here's my site with the header going over the sidebar. How do I get it back under the sidebar like it was before? And now that I think of it, is the whoe header being linked going to cause problems with the various links and buttons in the area where the sidebar overlaps it?
|
I'm not much of a CSS guru myself, but I think the z-index property might be helpful here. Check this link on Smashing Magazine: The Z-Index CSS property: A comprehensive look.
|
stackexchange-wordpress
|
{
"answer_score": 1,
"question_score": 0,
"tags": "sidebar, headers"
}
|
"Rendering of admin template [path to template] failed"
I've got a php script that is called when the user is editing the category. However, although the page renders fine for the most part, at the point where the image upload button should appear, I'm seeing this message:
> Rendering of admin template /home/site/public_html/wp-content/themes/mytheme/folder/subfolfer/admin/file.php failed
What are the likely causes for this error in this one site? Other sites are processing this fine?
THe site has PHP version 5.2.16 THe site has WP version 3.0.5
|
Looks like an error related to the HeadSpace2 plugin, see.
<
<
Perhaps the plugin has template support which you've enabled but not created the appropriate file for in the theme? I have no idea, i don't use the plugin, just thinking out loud..
Hope that helps.
|
stackexchange-wordpress
|
{
"answer_score": 1,
"question_score": 0,
"tags": "plugin development, php, errors"
}
|
Change headers in admin posts list
Is there anyway to show different information shown about custom post types in their list in the admin, wp-admin/edit.php?post_type=myposttype ?
Obviously I could rip it apart by adding php or js to the admin_head action, but is there a core wp way.
|
If you mean change the columns that show op on the list of posts/custom post types the there is a "WordPress way" to do that, take a look at < and jan answer to a similar question
Hope this Helps
|
stackexchange-wordpress
|
{
"answer_score": 3,
"question_score": 1,
"tags": "custom post types, wp admin"
}
|
How to save Admin FTP password
Every time I attempt to upload a plugin or theme, I am asked for the FTP password. Is there a way to save this within Wordpress, or do I have to enter it every time? Thanks.
|
You can save this information on your wp-config.php file:
define('FTP_HOST', 'ftp_host');
define('FTP_USER', 'ftp_username');
define('FTP_PASS', 'ftp_password');
More info (WordPress Developer Resources)
|
stackexchange-wordpress
|
{
"answer_score": 12,
"question_score": 8,
"tags": "password, ftp"
}
|
Changing a username
I have had a small number of users on my blog whiching to change thier username.
I was reading that is in stored in the DB but where is it and how do I change it.
|
You can look at the `user_login` column at the `wp_users` table. You can edit these values using any database tool (my favorite is PHPMyadmin <
|
stackexchange-wordpress
|
{
"answer_score": 1,
"question_score": 1,
"tags": "users"
}
|
What parameter should I pass to wp_enqueue_style to depend on the themes stylesheet?
I have written a basic gallery plugin that uses wp_enqueue_style to include a stylesheet on the page. I'd like for the WordPress theme to be able to override the style of the plugin which means I'd like to my plugin to play nice and output the css file **before** the theme css file.
wp_enqueue_style has a `deps` parameter for exactly this requirement. My question is what value should I use for the `deps` parameter if I want to say "I depend on the themes css file"?
The current plugin code is incorrect because it uses `false` for the `deps` parameter:
// Enqueue a CSS style file - see
wp_enqueue_style('bitvol_galleria_css', BITVOL_GALLERIA_URL . '/bitvolution-image-galleria.css', false, $this->bitvol_galleria_version, 'all' );
|
First issue - you have dependency backwards. Depending on something means loading **after** dependency, while you want earlier.
Second issue - theme's stylesheet doesn't actually use enqueue, it is usually codded directly in `header.php` file of theme. And since it seems to come before `wp_head()` call - you have no hook to ensure your stylesheet is above it.
So this is commonly handled like your workaround \- queued stylesheet with option to disable it by code or option in admin.
|
stackexchange-wordpress
|
{
"answer_score": 2,
"question_score": 1,
"tags": "plugin development, plugin recommendation, css"
}
|
Removing custom background and header feature in child theme
I am creating a child theme using twentyten as my base. I am looking for a way to remove the features of adding custom header and background without touching `functions.php` file in the parent theme.
no luck with this :(
function my_child_theme_setup() {
remove_theme_support('custom-background');
remove_theme_support('custom-header');
}
add_action( 'after_setup_theme', 'my_child_theme_setup' );
|
Both the header and background image features setup some globals in order to work, unsetting those globals seems to have some effect, and at the least removes them from the administration side.
add_action('after_setup_theme', 'remove_theme_features', 11 );
function remove_theme_features() {
$GLOBALS['custom_background'] = 'kill_theme_features';
$GLOBALS['custom_image_header'] = 'kill_theme_features';
}
class kill_theme_features {
function init() { return false; }
}
There's expectations for a class name to be provided as a callback for both of these features, and both expect the given class to have an init method. The solution was to create a dummy class that does nothing and update the globals, which effectively kills off the theme background and header pages in the admin area.
Hope that helps..
|
stackexchange-wordpress
|
{
"answer_score": 4,
"question_score": 4,
"tags": "functions, pluggable, child theme"
}
|
Send batch of posts as HTML Email?
Looking for a little help getting to grips with a quote, part of which is producing quarterly reports consisting on all the posts from that quarter.
My question is two fold - Is there a plugin that can do this sort of thing? Or of not, any clue as to where to start coding it?
Cheers
|
You are looking for a mailing plugin that can send mails in digests. One example is Subscribe2, which can be set from once hourly to weekly, but you can probably modify the code so it extends to quarterly mailings.
|
stackexchange-wordpress
|
{
"answer_score": 1,
"question_score": 0,
"tags": "plugins, plugin recommendation, email, html email"
}
|
Completely replacing the login form
I need to completely replace WP's login form with the login form of an external service.
The actions and filters I've found (eg login_form, login_head) seem to rely on WP's login process starting. I suppose I could do a redirect from here, but is there a cleaner way of sending a user to another URL if they attempt to browse to a WordPress login page.
|
Short and simple: No. You'll find a lot of stuff for wp-login.php on trac, but it seems that it won't change.
|
stackexchange-wordpress
|
{
"answer_score": 1,
"question_score": 1,
"tags": "login, single sign on"
}
|
Calling a plugin in theme development
I am trying to call plugins on a theme page. Specifically I am after the 'User Avatar' theme but their will be other later.
How do I call a plugin on a theme?
Presumable something linke `<?php` ...plugin name... `;?>` but that isn't it. Any ideas.
Marvellous
|
You must check the documentation of the plugin.
1. Is it supporting shortcodes? Do sometingh like `<? do_shortcode('[plugin_shortcode]'); ?>`
2. Has function to call in the theme? Do something like `<? my_plugin_function(); ?>`
|
stackexchange-wordpress
|
{
"answer_score": 3,
"question_score": 1,
"tags": "plugins, php, codex"
}
|
Submitting posts from the front end - sanitizing data
I have a form that allows any registered user to submit a post (it's a custom post type - forum related), and I'm using `wp_insert_post()` to insert it into the db.
From what I've seen in this function a sanitize_post() function is run automatically, but I think this only handles db escaping and such.
So how do I sanitize the input data the same way as the wp-admin editor does? I mean apply the kses filter and all the other stuff...
|
When a post is created/edited from the admin, edit_post() is called.
This function simply collects all the $_POST arguments and passes them to wp_update_post().
wp_update_post() then does some more logical checks and passes the data along to wp_insert_post().
wp_insert_post() calls sanitize_post(), which does all the heavy duty sanitization.
So, yes, wp_insert_post() _is_ the correct way to do it.
|
stackexchange-wordpress
|
{
"answer_score": 4,
"question_score": 4,
"tags": "custom post types, save post"
}
|
Display additional user fields
A theme is in development that echo's fields from the users account on their themed account page. This is the standard format.
<?php echo $current_user->user_lastname;?>
Thats all well and good. But there are 13 additional fields added via the plugin register plus. How do we echo them? This for example does not work.
<?php echo $current_user->user_post_code;?>
Any help appreciated, marvellous.
|
Hi **@Robin I Knight:**
Have you tried this?
<?php echo get_user_meta($current_user->ID,'user_post_code',true);?>
|
stackexchange-wordpress
|
{
"answer_score": 1,
"question_score": 0,
"tags": "php, custom field, users, registered"
}
|
Aggregate Summaries of Posts of Different Blogs in Multisite Instance
I have a Multisite Wordpress installation with 7 different blogs. I want to show an aggregate of the summaries of posts from those 7 blogs in the main blog. Do you know a good way to do this?
|
A couple of plugins, depending what you wanted.
< Despite the name, it pulls in all posts to the main blog or a blog called 'tags'.
< Give a list of the latest posts network-wide, all in a handy widget.
|
stackexchange-wordpress
|
{
"answer_score": 1,
"question_score": 1,
"tags": "plugins, multisite, excerpt"
}
|
Lose "Blog Archive" from page title
Right now the title of a post page on my blog reads like this... Blog Name >> Blog Archive >> Post Title
I don't see the need for "Blog Archive" to be in there and would like to remove it. I've looked in single.php and style.css and I'm not seeing any reference to "Blog Archive" in there that I can remove.
Any suggestions?
Much appreciated.
Eddie
|
I just realized that you're talking about the browser "title" at the top; that wasn't clear from your original post
Go into your `header.php` and at the top look for this line
`<title><?php bloginfo('name'); ?> <?php if ( is_single() ) { ?> » Blog Archive <?php } ?> <?php wp_title(); ?> - <?php bloginfo('description'); ?> </title>`
and remove
`<?php if ( is_single() ) { ?> » Blog Archive <?php } ?>`
|
stackexchange-wordpress
|
{
"answer_score": 2,
"question_score": 1,
"tags": "posts, title"
}
|
I need basic help with custom post types
Basically here's my project:
I have to create a back-end wordpress gui user input section. The user will enter details about their projects like name, location, what it is, some other details. A page will display the top 9 recent or so in a 3x3 grid. There will be a search bar to search projects for related tags.
I have currently:
* used functions.php to setup my post type and it works
* used simple forms plugin to create forms on the add new page
Background: I am a pretty entry level person in wordpress, and slightly overwhelmed right now. But, it's slowly coming together. Any input on structure or anything would be appreciated.
Update: I have created the forms, but I need to know what to put in the single-projects.php to display the content from the forms.
Thank you so much
|
Hi **@jeff:**
This list of plugins should give you what you need:
* **Custom Post Type Plugins**
### UPDATE
Try this plugin as it lets you set up fields for the user to enter into:
* **Simple Fields**
|
stackexchange-wordpress
|
{
"answer_score": 1,
"question_score": 1,
"tags": "custom post types"
}
|
How do I accesss gravatar?
In the administration under Your Profile, which is where I suspect it would be, I can't find anything relating to gravatar
|
The only place that gravatars are administered in WordPress core (without plugins, that is) is on the discussion settings page:
!Avatars
If you want to access YOUR gravatar, go to < and set up your profile. WordPress is set to automatically interface with gravatar using your user's email address to identify you with gravatar.com.
|
stackexchange-wordpress
|
{
"answer_score": 3,
"question_score": 0,
"tags": "avatar"
}
|
Exclude parent categories from the_category() within the loop
I have typical parent and child categories setup as follows:
* Food
* potatoes
* corn
* beats
* Sports
* soccer
* football
* hockey
etc.
In my index.php template I'd like to list the categories of the specific post. The problem is, when I use the_category() it lists the parent categories twice. I'm using the following code:
<php echo '<dt>', the_category(', ', 'multiple'), '</dt>', "\n"; ?>
And it prints out:
`Food:corn, Food, Food:potatoes`
I believe it is listing the child category "corn" as "Food: corn" followed by the parent category "Food" just as "Food." Is there a way to exclude the parent categories?
The way I'd like it to read is:
`Food:corn, Food:potatoes`
Thank you.
|
Have you tagged the post in Food, Food:Corn, and Food:potatoes? Try categorizing it in Food:corn and Food:potatoes only.
I do not believe that there is a means to exclude categories from the_category() function. You will have to use another function to create a custom query to do so.
Try some of these.
|
stackexchange-wordpress
|
{
"answer_score": 1,
"question_score": 0,
"tags": "theme development, categories, loop"
}
|
Tags as autocomplete values
How can I load regular post tags as values for autocomplete field? What I have now is pretermined values like this:
var data = {items: [
{value: "1", name: "Siemens"},
{value: "2", name: "Phillips"},
{value: "3", name: "Whirlpool"},
{value: "4", name: "LG"}
};
$("#input_1_3").autoSuggest(data.items, {selectedItemProp: "name", searchObjProps: "name"});
I'm using Drew Wilson's Autocomplete plugin found at: < Any help would be most apreciated.
|
if(isset($_GET['get_tags'])):
$output = array();
foreach(get_terms('post_tag') as $key => $term):
// filter by $_GET['q'] here if you need to,
// for eg. if(strpos($term->name, $_GET['q']) !== false)...
$output[$key]['value'] = $key;
$output[$key]['name'] = $term->name;
endforeach;
header("Content-type: application/json");
echo json_encode($output);
die();
endif;
in this case your js would be something like:
$("#input_1_3").autoSuggest(
"
{selectedItemProp: "name", searchObjProps: "name"});
|
stackexchange-wordpress
|
{
"answer_score": 0,
"question_score": 0,
"tags": "tags, autocomplete"
}
|
Get all post attachments except featured image
$args = array(
'post_type' => 'attachment',
'numberposts' => null,
'post_status' => null,
'post_parent' => $post->ID
);
$attachments = get_posts($args);
if ($attachments) {
foreach ($attachments as $attachment) {
echo apply_filters('the_title', $attachment->post_title);
the_attachment_link($attachment->ID, false);
}
}
In the code above, theres exist a way to get:
1. All attachments links except featured image.
2. All PDF attachments links only.
I was reading:
* <
* <
|
For the first one, you can add `'exclude' => get_post_thumbnail_id()` as a parameter (as shown here).
For the second one, you can add `'post_mime_type' => 'application/pdf'`, but I'm not sure that would always work, afaik, pdfs have more than one mime type.
|
stackexchange-wordpress
|
{
"answer_score": 15,
"question_score": 8,
"tags": "attachments"
}
|
What's wrong with this post__not_in argument?
In the script below, the post__not_in argument does not appear to be working unless I hardcode the post ids inside the array(). Anything stand out?
If an item is in the category, but also in the post__not_in, what get's precedent?
get_option('sticky_posts') is a single item array with var_dump = array(1) { [0]=> int(6) }
$myposts = get_posts(
array('cat' => "$cat,-$catHidden",
'post__not_in' => array($post->ID, get_option('sticky_posts')),
'numberposts' => 10;
)
);
foreach($myposts as $idx=>$post){//do something}
|
try:
$not_in = get_option('sticky_posts');
$not_in[] = $post->ID;
$myposts = get_posts(
array('cat' => "$cat,-$catHidden",
'post__not_in' => $not_in,
'numberposts' => 10;
)
);
foreach($myposts as $idx=>$post){//do something}
hope this helps
|
stackexchange-wordpress
|
{
"answer_score": 5,
"question_score": 0,
"tags": "plugin development, get posts"
}
|
How do I redirect my blog posts to a subdomain?
I currently have my blog at `alexangas.com` and would like to move it to `www.alexangas.com`.
Is this as simple as changing the **WordPress Address** and **Site Address** in Settings? How can I ensure that users hitting `alexangas.com/someblogpost` are automatically redirected to `www.alexangas.com/someblogpost`?
|
Yes. I just did an experiment on my own site to verify that changing those settings will redirect between www and non-www as you specify.
|
stackexchange-wordpress
|
{
"answer_score": 1,
"question_score": 2,
"tags": "migration, domain"
}
|
I want to print a message in post " After one month from publish date"
I need to showing message in post , but after one month from publish date.
I try to make it before ask you, but I can't
this is my code
$publish_date = $post->post_date_gmt;
$today = date('d-m-Y h:i:s');
$nextMonth = mktime(0 , $publish_date('m')+1 , 0 , 0 , 0,0);
echo 'Publish Date:'.$publish_date.'<br/>';
echo 'Today Date:'.$today.'<br/>';
echo 'Next Month:'.$nextMonth;
if($today => $nextMonth){
echo 'One Month or more for publish post';
} else {
echo '';
}
|
Custom conditional I wrote for my theme (mostly to kick some widgets and ads from newer posts), works nicely:
function is_old_post( $days = 14 ) {
if( !is_single() )
return false;
$id = get_the_ID();
$date = get_post_field( 'post_date', $id );
if( strtotime( $date ) < strtotime( "-{$days} days" ) )
return true;
return false;
}
|
stackexchange-wordpress
|
{
"answer_score": 1,
"question_score": 0,
"tags": "customization, posts, publish"
}
|
Wordpress menu: How to make www.link.com/#name never contain current_page_item class?
I am using the wordpress menus on a website, but the problem is that one of the links on that menu is www.homepage.com/#order
So, when I am on the homepage, both "home" and "order" links on the menu contain the class current_page_item, which with my css it makes them appear both as the active button.
How can I make it so the #order link never contains that the current_page_item class?
Here's a screenshot of how the menu looks when visiting the homepage and how I set it up on the admin panel:
<
On the firebug panel you can see that both www.homepage.com and www.homepage.com/#order menu links contain the current_page_item class.
This is the php code I am using to display the menus:
<?php
$args = array(
'menu' => 'Top Menu',
'sort_column' => 'menu_order',
'container_class' => ' '
);
wp_nav_menu($args);
?>
|
a bit hacky, but it works:
add_filter('nav_menu_css_class', 'remove_some_menu_classes', 420 ,3);
function remove_some_menu_classes($classes, $item, $args){
if(strpos($item->url, '#order') !== false)
// in the 2nd array put the classes you want removed
return array_diff($classes, array('current_page_item', 'current-menu-item'));
return $classes;
}
|
stackexchange-wordpress
|
{
"answer_score": 1,
"question_score": 0,
"tags": "customization, menus, css"
}
|
WPML taxonomies not translated
I'm using WPML for multi-language website. It works really well except for custom taxonomies.
In admin, I can only join foreign posts to foreign taxonomies (which is exactly what it should do) but on the public area, when retrieving taxonomies it seems that the current language is ignored: I get all taxonomies.
Any help would be greatly appreciated !
Thanks.
|
I found out that when retrieving the taxonomy you have to do this :
$args = array(
'hide_empty' => true,
'taxonomy' => 'projet_thematique'
);
$thematiques = get_terms('projet_thematique', $args);
The thing was done by adding the 'taxonomy' as an argument as well.
I hope it will be usefull for others ;)
|
stackexchange-wordpress
|
{
"answer_score": 0,
"question_score": 0,
"tags": "custom taxonomy, plugin wpml"
}
|
How do I filter title and alt attributes in the gallery shortcode?
I am displaying a post gallery inside a custom post type, using the following in my single-custom.php template:
`<?php echo do_shortcode('[gallery id="'.$post->ID.'" link="file" columns="5" orderby="menu_order"]'); ?>`
One of the things included in the output is `title="filename"` in the `<img>` tag, like so:
`<img width="150" height="150" src=" class="attachment-thumbnail" alt="DSC_0036" title="DSC_0036" />`
I do not want to output the title attribute. Mostly, I don't want crappy filenames in the hover-over text, but there are hundreds of images and I'm not prepared to go into the Media Gallery and edit the title for each one. I'd prefer to also change the `alt` attribute to the post name, perhaps.
Is there a way to filter the gallery to output the post name in the alt and title attributes, instead of the filename?
|
The `[gallery]` shortcode is parsed by `gallery_shortcode()`, which calls `wp_get_attachment_link()`, which in turns calls `wp_get_attachment_image()`. This latter function writes the `<img>` tag with the `title` attribute. You're lucky, because the attributes are filtered through `wp_get_attachment_image_attributes`, so you can hook into that and remove the `title`.
To do this, you attach the hook before you call the shortcode and remove it after you did this. You can either do this in your template if it's a one-off, or, if you are more advanced, you "hijack" the `[gallery]` shortcode with your own function that adds the hook, calls the original `gallery_shortcode()` function, and removes the hook.
|
stackexchange-wordpress
|
{
"answer_score": 6,
"question_score": 1,
"tags": "filters, gallery"
}
|
In which directory do I find the HTML file of my wordpress pages?
I would like to manually edit the code my my wordpress pages. The WP interface only allows me to individually edit the CSS or PHP. The Page Edit feature gives me access to a certain part of the code, excluding the Body Tag.
Kindly help me locate my files on the server.
Thanks for your help!
:)
|
WordPress stores content in the database, there are not any physical files with the content of the pages(or posts). The theme's template files control how to render and display your site, you can find those files in `wp-content/themes/YOUR-ACTIVE-THEME-NAME-HERE`..
You can find lots of information on themes and their development here.
<
Additional information and guidance can be found through the other documentation listed in the resources section of the above linked page, here it is for quick reference.
<
A quick search of the WordPress forums would have also provided you with the information needed(just something to note).
<
Hope that helps.
|
stackexchange-wordpress
|
{
"answer_score": 4,
"question_score": 8,
"tags": "html, server"
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.