INSTRUCTION
stringlengths 11
999
| RESPONSE
stringlengths 0
999
| SOURCE
stringlengths 16
38
| METADATA
dict |
---|---|---|---|
Add posts from other Wordpress blog to the current one
This might seem like a duplicate, but other questions I've found seem to be about exporting/importing Wordpress, as a 1 shot deal.
My situation here is quite different; I'm looking for a method/plugin that would write in the posts as they are posted on another site.
Here is a more detailed way to explain it. My client has a blog, with his new site. He also has 3 kind of subblogs on other sites on other domains. The behavior we want is that if he posts something on the subblogs, it gets also posted on the main, new blog.
We can't run on multisite, the subblogs are already been running for a year, and there's enough traffic on it to not being able to take them down to make an update.
Anybody would know a plugin, or a method within functions.php (We do have access to the code) that could make that happen? | Try FeedWordPress « WordPress Plugins | stackexchange-wordpress | {
"answer_score": 1,
"question_score": 0,
"tags": "plugins, posts, blog, migration"
} |
remove_filter( 'comment_author', 'floated_admin_avatar' ); doesn’t work
In a small plugin I’ve written to add an IP address column to the comments list I want to remove the avatars.
In line 156 I tried to use `remove_filter`:
remove_filter( 'comment_author', 'floated_admin_avatar', 50 );
Well … I know this function fails sometimes, but **why does it fail here?**
My workaround is:
$_GET['comment_status'] == 'spam'
and add_filter( 'pre_option_show_avatars', '__return_zero' );
I guess I stared too long at this code to see what went wrong. I need a hint into the right direction. | As usual with hooks this is issue of timing.
* your init function is hooked to admin load process, which works fine for most things;
* however in this specific case function is added to filter in constructor of `WP_Comments_List_Table` class, and object is created in `edit-comments.php` after admin loader had been processed.
In my plugin for similar stuff I am removing it at `manage_edit-comments_columns` hook.
Simplified example from my class:
static function on_load() {
add_action( 'admin_init', array( __CLASS__, 'admin_init' ) );
}
static function admin_init() {
add_filter( 'manage_edit-comments_columns', array( __CLASS__, 'manage_columns' ) );
}
static function manage_columns( $columns ) {
remove_filter( 'comment_author', 'floated_admin_avatar' );
// stuff
return $columns;
} | stackexchange-wordpress | {
"answer_score": 3,
"question_score": 2,
"tags": "comments, avatar, filters"
} |
How to copy and paste a picture found on the web to wordpress easily
Anyone knows how to do so? What about if you want to edit the pics a little bit before pasting.
I am using windows. | It should not be a lengthy process.
## Straight from the web:
1. **Right click** > `Copy image location`
2. WordPress: Add Media > `From URL`
## Editing a picture:
1. **Right click** > `Copy image`
2. Paste into your favorite photo editor (e.g. GIMP)
3. Edit and Save
4. WordPress: Add Media > `From Computer`
Note: with WordPress 3.3 you can also drag-and-drop files. | stackexchange-wordpress | {
"answer_score": 6,
"question_score": 3,
"tags": "images, uploads"
} |
Newlines in Wordpress.com blog?
I just set up a blog on Wordpress.com, and the problem is, if I write:
something something
blah blah
That empty line in between doesn't show up! What can I do about this? | WordPress.com and self-hosted strips extra white space. But you can try forcing a new line with a nonbreaking space in between bold tags:
<b> </b> | stackexchange-wordpress | {
"answer_score": 1,
"question_score": 0,
"tags": "wordpress.com hosting"
} |
Keeping LaTeX contents in line with non-latex text
I am using LaTex from the JetPack plugin, which is similar but not identical to TeX for maths, for my WordPress blog where I post course work. How do I get the generated formulae to centre on the line so the equals sign lines up with the normal text that I have typed? to see what I mean please check this blog entry.
here are a the two offending pieces of LaTeX for the last two equations of the equations:
$latex = \large{\dfrac{1}{62,000}} $
and
\left(\large{\dfrac{10,000}{62,000,000}}\right) 100\% $
thanks for your time :) | I haven't used that plugin, so I can't speak to whether there are any configurations that would help. However, I think your issue could be solved with a simple css rule:
img.latex {
vertical-align: middle;
}
would center all your LaTeX-generated images on the line they fall on. | stackexchange-wordpress | {
"answer_score": 3,
"question_score": 1,
"tags": "latex"
} |
how to disable user confirmation from administration?
I have a multi-site network, on one of the sites the access is restricted to registered users, and only an administrator can create users.
I was asked to get rid of the confirmation email sent to new users, and I know you can select an option to add the user without sendind the email.
The problem is, that option is only available to super administrators (me) and not regular administrators.
Is there a way to add the new users without sending a confirmation email? I can get rid of the email, but I also need to remove the activation link, I need the users to be automatically added.
I've looking for hooks but I can't find anything helpful, any ideas?.
P.S. Every user is added from the _Add new user_ menu in the backend. | Haven't really tested this, but WP actually uses this filter if you check the "noconfirmation" box, except that it does so only for super_admins, like you said:
add_filter( 'wpmu_signup_user_notification', '__return_false' ); | stackexchange-wordpress | {
"answer_score": 2,
"question_score": 5,
"tags": "user registration, users"
} |
Auto Nofollow attribute in custom field links. How?
I have a wordpress network. All the contents in my network are user generated. All posts links are now dofollow. I want to change it to nofollow. My site uses plugin for custom fields. I removed the default description area. So i cannot use the_content function. I use custom fields for all.
I tried many auto nofollow plugins. But its not working in my custom fields. Can anyone help me?
Is there any function code available?
I just want
<a href=" Link</a>
to
<a href=" rel="nofollow">My Link</a>
Thanks | Code Available here which is written by chrisguitarguy | stackexchange-wordpress | {
"answer_score": 0,
"question_score": 0,
"tags": "nofollow"
} |
Allowing users to Sign-up > Login > Post articles that need approval
I need your advice!
I have a small hobby website, it's a small music magazine, with all the content published by me. It's setup with an open source Wordpress Theme with my custom graphics and CSS. I want to turn it into something else now, and allow users to have the ability to be able to sign-up > login > and post articles and any pretty much any post content they'd like. But I'd like it to be sent to my email or something for me to have to 'approve it' before it's published?
Whats a good approach of taking a standard Wordpress small magazine site, and creating allowing these functionalities? Is this a page or two of gluing PHP snippets together from around the web, could this be handled with a good plugin or two - or is it something deeper?
Thanks as always! | What you're asking for is part of core WordPress functionality. Simply assign the appropriate user role to new users. For example, the **Contributor** user role can draft - but not _publish_ \- new posts. Such posts then require someone with publish privileges to approve/publish them.
To set the default role for new users, go to `Dashboard -> Settings -> General` and set the **New User Default Role** setting. | stackexchange-wordpress | {
"answer_score": 1,
"question_score": 0,
"tags": "plugins, posts, php, signup"
} |
How to remove wordpress admin bar in dashboard
I would like to rebrand wordpress. Can anyone tell me how to remove it from dashboard? Is there any hook available. Or I should edit core files. If i should edit core file can anyone tell me which file?
I edited `wp-includes/admin-bar.php` and removed this action
add_action( 'admin_footer', 'wp_admin_bar_render', 1000 );
It actually removed the admin bar. But it doesn't remove admin bar style sheet. I see empty space instead of admin bar. I mean i see padding in the top. Can anyone point me in the right direction?
Thanks | _**NEVER_** edit core files.
Use the following code to disable admin bar.
add_action( 'init', 'disable_admin_bar', 1 );
function disable_admin_bar() {
add_filter( 'show_admin_bar', '__return_false' );
}
NOTE: From WordPress 3.3 you can't remove admin bar in WordPress admin. | stackexchange-wordpress | {
"answer_score": 1,
"question_score": 0,
"tags": "admin bar, core, core modifications"
} |
Admin taking a very long time to load
Logging into my site's Wordpress admin backend take several minutes. The site indicates that it is loading and then just hangs for many minutes before finally loading. It smells like something is timing out, I suspect a plugin, but I can't for the life of me figure out what.
In order to troubleshoot this, what steps would you take if confronted with such a problem? Turn plugins on and off and see which is the culprit? The problem with this approach is that after the initial slow loading, everything loads normal. Check php max execution times in php.ini? Somehow monitor outgoing connections to see what's trying to reach something and timing out (how would you do this)?
Any suggestions welcome. | I would do most of my troubleshooting in the Debug Bar plugin along with the Debug Bar extender plugin.
This plugin gives you detailed access to everything that is going on behind the scenes. It can also detail memory usage and execution time for each function and database query along with where it was called from.
I would start by doing some checking with the tool then come back here if you get stuck on anything. | stackexchange-wordpress | {
"answer_score": 3,
"question_score": 0,
"tags": "pages, performance"
} |
Reverting from a newer version of WordPress to an older version
For some reasons I need to degrade WordPress version of a site (I understand that it is **not** a good practice to do and I can fall into many troubles by doing so) but I still need to do it for some reasons.
I want to degrade from 3.0 to 2.9. I tried to upload the `wp-admin` folder of WordPress 2.9 installation into my WordPress 3.0 site but it was unable to load all the files. I can not delete the upgraded version as it contains images of posts.
Is there any way to revert back to 2.9? Moreover, is there a plugin that can get this done? | Like you said, downgrading would be a bad practice and is not at all recommended. Please make a backup of your database before continuing, just to play safe.
It looks like you've only replaced `wp-admin` folder. WordPress updates are not limited to `wp-admin` folder. Try replacing `wp-admin`, `wp-includes` and all those files in the root directory.
Now clear your cookies and goto:
> yoursite.tld/wp-admin/upgrade.php
WordPress might ask you to _upgrade_ your database and continue with it. After this, you'd be running 2.9 (hopefully). | stackexchange-wordpress | {
"answer_score": 1,
"question_score": 1,
"tags": "updates, wordpress version"
} |
How do I get posts by multiple post ID's?
I've got a string with post ID's: `43,23,65`.
I was hoping I could use `get_posts()` and use the string with ID's as an argument.
But I can't find any functions for retrieving multiple posts by ID.
Do I really have to do a `WP_query`?
I've also seen someone mention using `tag_in` \- but I can't find any documentation on this. | You can use `get_posts()` as it takes the same arguments as `WP_Query`.
To pass it the IDs, use `'post__in' => array(43,23,65)` (only takes arrays).
Something like:
$args = array(
'post__in' => array(43,23,65)
);
$posts = get_posts($args);
foreach ($posts as $p) :
//post!
endforeach;
I'd also set the `post_type` and `posts_per_page` just for good measure. | stackexchange-wordpress | {
"answer_score": 54,
"question_score": 29,
"tags": "get posts"
} |
Display only author posts in dashboard all posts panel
I would like to display only authors own posts in dashboard all posts section. As of now it displays everything.
I found some code here which is written by @t31os Its working correctly.
function posts_for_current_author($query) {
global $user_level;
if($query->is_admin && $user_level < 5) {
global $user_ID;
$query->set('author', $user_ID);
unset($user_ID);
}
unset($user_level);
return $query;
}
add_filter('pre_get_posts', 'posts_for_current_author');
But user_level is deprecated. So can anyone modify the code for new version? Thanks | The following worked for me to show only the current user's posts in the admin
add_action( 'load-edit.php', 'posts_for_current_author' );
function posts_for_current_author() {
global $user_ID;
/*if current user is an 'administrator' do nothing*/
//if ( current_user_can( 'add_users' ) ) return;
/*if current user is an 'administrator' or 'editor' do nothing*/
if ( current_user_can( 'edit_others_pages' ) ) return;
if ( ! isset( $_GET['author'] ) ) {
wp_redirect( add_query_arg( 'author', $user_ID ) );
exit;
}
}
It can be edited pretty easily if the restriction should only happen for users in a particular role. | stackexchange-wordpress | {
"answer_score": 5,
"question_score": 0,
"tags": "author, deprecation"
} |
Attach File Funcion for Common people
How can i allow my visitors that they can attach files like word text pdf with their comments or can allow attach file to register users is their any plugin or any other way for achieving this task ? | I have not used it, but this might be what you're looking for:
* Easy Comment Uploads _ Wordpress Plugin_ | stackexchange-wordpress | {
"answer_score": 1,
"question_score": 0,
"tags": "customization, plugin recommendation, comments, attachments"
} |
How to remove categories filter from wordpress admin?
I removed the categories column from "All posts" page by applying this code.
add_filter("manage_edit-post_columns", "my_post_edit_columns");
function my_post_edit_columns($columns){
unset($columns['categories']);
return $columns;
}
This code removed categories column. But still i see the categories filter in the top. Is there a way to remove it other than using CSS to hide it?
Thanks | I tested this and it works for removing the categories dropdown on the All Posts page:
add_action( 'load-edit.php', 'no_category_dropdown' );
function no_category_dropdown() {
add_filter( 'wp_dropdown_cats', '__return_false' );
}
\-- below: old answer when I misunderstood the question --
The code you posted works just fine for me. But here's an alternative you might try:
add_filter("manage_posts_columns", "my_post_edit_columns" );
function my_post_edit_columns($columns){
unset($columns['categories']);
return $columns;
}
This _will_ also impact other post types that have a 'categories' column. | stackexchange-wordpress | {
"answer_score": 6,
"question_score": 6,
"tags": "categories, admin, customization"
} |
Choose User to email when adding a new post?
I am trying to find out a way to "email" users when a post is made?
It would be nice to have a drop down menu or check box to check to "email that user" when Publishing a new post?? So I can just check one of the USERS to notify??
Anything like this available? I have found this as a plugin - Email Post Changes -- but it doesn't individualize each post?? | You would want to add a custom meta box that lists all users on the site. Not sure off the top of my head how you would create one that lists users, but it shouldn't be too hard.
You would then run a hook on wp_insert_post that verifies which users have been checked, and sends each of them an email. Something like:
add_action('wp_insert_post', 'my_function');
function my_function() {
$user_ids = "whatever you saved it as in your custom meta box"; // grab the user ids of who you want to email in an array
foreach($user_ids as $user_id)
$user_data = get_userdata($user_id);
wp_mail($user_data->user_email, "your subject", "your message");
}
return;
} | stackexchange-wordpress | {
"answer_score": 0,
"question_score": 0,
"tags": "plugins, email"
} |
What is the function to check network admin?
I know there is a function to check normal admin area.
Its `is_admin()`
Is there any other function available to chevk network admin something like `is_network_admin()` ?
Thanks | Google search: <
is_network_admin();
:) | stackexchange-wordpress | {
"answer_score": 3,
"question_score": 0,
"tags": "network admin"
} |
How does filter the_posts work?
I don't want to display post with empty body / post_content on my home page. So I added below code to my function.php. It detects post with empty body but it still display them. I expected that if I return '' the post won't be displayed.
* How can I **remove** post from displaying?
* How does the **filter the_posts work**?
The code:
function remove_post_with_empty_body ( $posts ) {
if (($posts->post_content) == '') {
echo 'empty'; //also tried return false; and return null;
return '';
}
else {
echo 'not empty';
return $posts;
}
}
add_action('the_post', 'remove_post_with_empty_body'); | First thing, in your code you are using `the_post` hook but in your question you are asking about `the_posts` hook, which are two different things.
`the_posts` gets called just after the posts have been selected from the database and it passes an array of $posts to your function, so you should use that.
as for `the_post` hook, it gets fired (usually) inside the loop it self which is to late to change any thing (like redirect) and its not a filter hook, but an action hook which means that if you return nothing, its just exiting your function and not effecting the outcome. | stackexchange-wordpress | {
"answer_score": 8,
"question_score": 5,
"tags": "posts, filters"
} |
Redirect non-members to about/intro page
I´m making a small wordpress/buddypress community site where I want all content except an about page to be for members only.
I need to do a redirect to the about-page for all non-logged in users. When users log in (from the sidebar) they should end up on the blog/frontpage.
How can I achive this? I tried some different members-plugins for buddypress and wordpress but none of them did exactly what I wanted, or didn´t work with other important plugins (like WP-FB-autoconnect).
I´m guessing this is pretty easy to do with custom code in the header or functions file. But I´m not really a coder so I would like som help! | Open your theme's headr.php file and add at the top
<?php
if( !is_user_logged_in() ) {
wp_redirect(get_permalink(123));
exit;
}
?>
just change 123 to the id of your about page, or replace `get_permalink(123)` with the about page URL example:
<?php
if( !is_user_logged_in() ) {
wp_redirect('
exit;
}
?> | stackexchange-wordpress | {
"answer_score": 0,
"question_score": 0,
"tags": "login, buddypress, private, members"
} |
making my own "related pages" / "pages you might like" section
I'm trying to get the tags of a post on the single content page and displaying a list of other articles that share the tags with the post. For example, the user is reading an article with a tag like 'game'; I want to display the titles of other articles that share the tag 'game'. I'm basically trying to make my own "related pages" section.
How would I do this without using a plugin and which PHP file does the code go? I am using wordpress 3.2.1 and a child theme for the Twenty-Eleven theme. | Function Reference/get the tags « WordPress Codex
Class Reference/WP Query « WordPress Codex#Tag_Parameters
add some code like this to content-single.php of your child theme of Twenty Eleven:
$tags = array();
$posttags = get_the_tags();
if( $posttags ) :
foreach( $posttags as $tag ) { $tags[] = $tag->term_id; }
$related_query = new WP_Query( array('tag__in' => $tags));
if( $related_query->have_posts() ) :
while( $related_query->have_posts() ) :
$related_query->the_post();
/*whatever you want to output; for instance:*/
echo '<a href="'; the_permalink(); echo '">'; the_title(); echo '</a><br />';
endwhile;
endif;
endif; | stackexchange-wordpress | {
"answer_score": 1,
"question_score": 0,
"tags": "php, tags, theme twenty eleven"
} |
Can I include get_posts in this array?
I am using the custom meta box script from deluxeblogtips.com and I wondered if I could include get_posts within this array so that it displays all posts within a set post type ("Locations" for example)
array(
'name' => 'Location', // File type: checkbox
'id' => $prefix . location',
'type' => 'checkbox',
'desc' => 'Check this box to make any links open in a new browser window',
'std' => 0 // Value can be 0 or 1
),
Obviously I'd need to be able to select as many posts as I wanted. Any help would be greatly appreciated. | I'm assuming there is an option in the array that is meant to receive an array of options for the checkboxes...?
In which case, you can use `get_posts` to obtain an array of post objects (of which ever type), and then loop through this, to create an array of post titles:
For example..
$args=array('numberposts'=>-1,'post_type' => 'location');
$post_objs = get_posts($args);
$options=array();
foreach($post_objs as $post_obj):
$options[]=$post_obj->post_title;
endforeach;
You then have an array of location names, `$options` which you can feed into your metabox array.
_Disclaimer: I've not tested this code._ | stackexchange-wordpress | {
"answer_score": 1,
"question_score": 0,
"tags": "query, get posts, metabox"
} |
Multisite Create New Blog Plugin
Looking for a plugin that displays a form for visitors to create a new blog on a network, where they can answer a few basic questions on a form along with some admin options for me to tweak.
Any ideas? | You're probably needing a membership type plugin. I've used the following before and it works great for creating a blog community.
< | stackexchange-wordpress | {
"answer_score": 1,
"question_score": 0,
"tags": "multisite"
} |
What's the difference between term_id and term_taxonomy_id
The title says it all. At the moment in my custom taxonomies I'm getting the terms using the term id and taxonomy name.
Thought this question would've been asked before but can't find it anywhere! So just thought I'd ask and see if anyone has any answers. | If you take a look into the Wordpress documentation you will find Wordpress Taxonomies
* **term_id** is the ID of a term in the terms table
* **term_taxonomy_id** is a unique ID for the term + taxonomy pair. | stackexchange-wordpress | {
"answer_score": 34,
"question_score": 34,
"tags": "plugin development, custom taxonomy"
} |
Portfolio & Blog cohabitation : multiple single.php files?
I'm currently creating a website that's going to be powered by Wordpress and have both a portfolio and a blog.
How should I go about coding up the `single.php`?
I understand custom post types are the way to go when it comes to a portfolio+blog setup, but when it comes to displaying the post/portfolio item in its entirety, is there such a thing as multiple `single.php` files?
Thanks in advance! | Have a look at the template hierarchy page. Custom post types will use `single-{post_type}.php` template if it exists. | stackexchange-wordpress | {
"answer_score": 2,
"question_score": 0,
"tags": "blog, customization, single"
} |
problem with quotes on new post
i have a little form to post:
$post_content = '"Neque porro quisquam est qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit..."';
$post = array( 'post_author' => 1,
'post_title' => 'title',
'post_content' => $post_content,
'post_category' => $categories,
'post_type' => 'post'
);
but, once my post is published shows :
&;Neque porro quisquam est qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit…&;
please note the `&;`
I've tried to escape before like this:
\"Neque porro quisquam est qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit...\"
but still the same. Any ideas? | $post_content = '"Neque porro quisquam est qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit..."';
Try encoding special characters. See: < & < | stackexchange-wordpress | {
"answer_score": 1,
"question_score": -1,
"tags": "mysql, escaping"
} |
Count all images of a certain post type
I followed two posts related to my query. One was about the number of images attached to a post and second about showing all images of a certain post type. I tried to combine the two codes in the following way but it didn't help:
$query = new WP_Query( array( 'post_type' => 'gallery', 'posts_per_page' => -1 ) );
if( $query->have_posts() ){
while($query->have_posts()){
$query->the_post();
$attachments = get_children( array( 'post_parent' => $parent->ID, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => 'ASC', 'orderby' => 'menu_order ID' ) );
$count = count( $attachments );
}
}
Can anyone help me in counting all images attached to a certain post type? | Try putting this in your functions file, and then place `<?php $attachment_count; ?>` in a template file.
function attachment_count() {
global $post;
//Get all attachments
$attachments = get_posts( array(
'post_type' => 'attachment',
'posts_per_page' => -1
) );
$att_count = 0;
if ( $attachments ) {
foreach ( $attachments as $attachment ) {
// Check for the post type based on individual attachment's parent
if ( 'gallery' == get_post_type($attachment->post_parent) ) {
$att_count = $att_count + 1;
}
}
echo $att_count;
}
} | stackexchange-wordpress | {
"answer_score": 2,
"question_score": 1,
"tags": "custom post types, attachments, images"
} |
bbpress plugin moderation
I am using the bbpress wordpress plugin for the first time and I can't see any settings for moderation. Does bbpress have moderation built in? I did a search for any moderation plugins but only found one for the standalone version. Is there a way to enable moderation? | I'm looking for the same. I just found this, not tried yet but seems to be working: bbPressModeration | stackexchange-wordpress | {
"answer_score": 0,
"question_score": 0,
"tags": "bbpress, moderation"
} |
Renaming wp-admin without hard-coding it. Is it really possible?
I would like to rename my wp-admin folder due to some security concerns. Is it really possible?
**The less it looks/is built like default WP, the harder it is to attack known vulnerabilities. Being able to rename those directories can help stop an exploit dead in its tracks.**
Otto mentioned in this thread its possible using "admin_url" filter. Is it really possible? If yes can someone give me some sample code. I hope this is a useful question | For a fully-working solution, you _will_ need to modify certain hard-coded urls in core files, which is not fun to have to do each time WP is upgraded.
One easier option is to protect the wp-admin folder with an .htaccess file. You could basically deny all IP addresses and whitelist the few IP's that you or your editors might use. You could also use HTTP AUTH to add another layer of password protection. It will prevent unauthenticated users from viewing the wp-login page.
And regarding renaming your folder, I'm not sure that it will really make your site more secure. For example, if you use any AJAX plugins, a hacker will know your admin folder location right away! And there are other simple ways to determine it as well... | stackexchange-wordpress | {
"answer_score": 3,
"question_score": 0,
"tags": "wp admin, security"
} |
Buddypress Plugin for register user from other site's
Buddypress plugin which register user from other social sites like...Facebook, twitter and also from google.
I think there is one buddypress exist only for facebook but not for others.. any one know about. | I cannot fully understand your question,
But i think you need a plugin to make users register through their facebook, google, twitter id. If thats the case use janrain engage plugin. | stackexchange-wordpress | {
"answer_score": 0,
"question_score": 0,
"tags": "plugins, buddypress, user registration"
} |
Want to change my site root
Hello I have a wordpress site that has a url at some ip address. Now what I want to do change the url. Instead of IP Address", I want it IP Address"/wordpress. instead.Is there a way to do this in wordpress?
My document folder is called wordpress. It is stored in /var/www/ folder | * Open your site ` address"`
!enter image description here
* go to ` address"/wp-admin/options-general.php`
!enter image description here
* in the General Settings change the `Site Address (URL)` from ` IP Address"` to ` IP Address"/wordpress`
!enter image description here
* Its done
!enter image description here | stackexchange-wordpress | {
"answer_score": 1,
"question_score": 0,
"tags": "directory, site url, deployment, home url"
} |
Multi-page posts: A subdirectory for each post?
I am using Wordpress as a CMS and would like to add a 'Learn More' page to each post that is created within a particular category. For example, when
is created, I would also like for
to be created, too.
Ideally, this 'learn more' page would run on a template layout that I would create, and have it's content populated by a custom field within the main post.
Is this at all possible? Is there a plugin available that will allow me to achieve this?
Thanks, Ben | Use wordpress post tab plugin,
Else
Need some rewrite rules to do it,
refer these posts
Integrating a custom post type into a page hierarchy
How to handle a hierarchy with custom post types | stackexchange-wordpress | {
"answer_score": 0,
"question_score": 1,
"tags": "theme development, cms"
} |
Comments feed - Undefined named entity: ndash
I used to have a rss comment feed at the url /comments/feed which doesn't work anymore.
I checked the feed on feedvalidator and I've an error
> line 111, column 29: Undefined named entity: ndash [help]
The line in question is comment where the content is
<guid isPermaLink="false">
<description>Ou mettre des – à la place des -
Mais oui la solution de rcommande fonctionne bien :)</description>
In the context, it is normal that there was an `–` there (explaining to write `--` with `––`).
Any idea how to fix this feed error ? | This issue may be the same over here: <
Its currently submitted as a bug and hasn't been fixed yet. You can give the supplied attachment a go to see if it fixes the issue for you.
<description>Ou mettre des – à la place des -
Mais oui la solution de rcommande fonctionne bien :)</description>
<content:encoded><![CDATA[<p>Ou mettre des &ndash; à la place des -<br />
Mais oui la solution de rcommande fonctionne bien <img src=' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
You can see in your feed that the `–` is properly encoded in content but not the description.
Quick fix is to delete the comment with the `–` in it. | stackexchange-wordpress | {
"answer_score": 1,
"question_score": 1,
"tags": "comments, feed"
} |
Adding a Custom Post Type into the menu screen
I need a way of adding custom post types to the "Appearance-->Menus" option in Wordpress. i have created a custom post type with:
`register_post_type('produksjoner',$args);`
All examples I find just add the pages to the menu by manually adding the URL into a custom menu item. I want it to be able to add this automatically by choosing it like any other page.
I have been searching for two days now... please help me :-/ | To get your custom post types to show up in Appearance -> Menus, you need to do two things:
1. Check your arguments and make sure that **show_in_nav_menus** is set to **true**.
2. Go to the Appearance -> Menus page and at the very top, click on **Screen Options**. In the panel that opens, make sure that your custom post types are checked.
That's all! | stackexchange-wordpress | {
"answer_score": 111,
"question_score": 44,
"tags": "custom post types, menus"
} |
Double bar "|" in title (By WP SEO Yoast?)
I am wondering why my pages (post doesn't have this problem) have a double bar "`|`" in them
eg. `About || Jiew Meng's Blog`
**
Ok, I changed my title to
wp_title('')
Instead of the default `wp_title('|', true, 'right')` in TwentyTen. It fixed the double bar problem, but
If I go a Custom Post Type archive link, I get something like
PortfolioJiew Meng's Blog
If I go a custom post type single page link, I get
KLIF Media v2 - Jiew Men's BlogJiew Meng's Blog
If I force rewrite titles, it mostly works except for some pages, becoming
- Jiew Meng's Blog
I think I need to manually set the page title if I used this option? | I use this plugin together with TwentyTen too and encountered the same problem.
My solution is to leave `wp_title( '|', true, 'right' );` unchanged but only enable the call to function `bloginfo()` in the next line if plugin WordPress SEO is inactive.
include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
// Add the blog name.
if ( is_plugin_inactive('wordpress-seo/wp-seo.php') ) {
bloginfo( 'name' ); //this call conflicts with plugin "Wordpress SEO"
}
I don't use 'Force rewrite titles'. For the title templates I use `%%title%% | %%sitename%%`. For the homepage I've entered my custom title text. | stackexchange-wordpress | {
"answer_score": 1,
"question_score": 0,
"tags": "title, plugin wp seo yoast"
} |
How does WordPress tell which post is from which site in a multisite setup?
I'm aware that WordPress stores all the post content of a multisite in the same database table and I was just wondering how it internally differentiates post content from one blog to the other? | Posts from one site are not stored in the same table as posts from another site.
Each blog on a multi site gets an ID and that ID is used to generate a separate set of tables for each site in a multisite installation.
So for example site 1 gets:
wp_posts
where as site 2 gets:
wp_1_posts
and so on:
wp_2_posts | stackexchange-wordpress | {
"answer_score": 4,
"question_score": 2,
"tags": "multisite"
} |
Creating an RSS feed with all of the prior month's posts
How can I create an RSS feed that will display all posts from the prior month. So on any day in December, the feed will show all posts from November and so on.
Thanks. | take a look at **`this answer`** to a similar question which shows a template to create your custom feed and all you need to do is add `query_posts(array('monthnum' => (int)date("m") ));` before the loop. | stackexchange-wordpress | {
"answer_score": 0,
"question_score": 0,
"tags": "rss"
} |
How to include external page to wordpress page?
I have one external page (`google_map.php`) which contain code to display google map information based on the selection criteria.
And in the wordpress page I want to display the google map which is coded in `google_map.php`.
I want to ask that how can I add `google_map.php` page in my wordpress page?
Or other option,
Can i directly add my `google_map.php` page code to the wordpress page? I don't want to use any plugin to support php code in the wordpress page like Exec-PHP plugin.
Which is the better way? | It is actually very simple. just
* add the following text in at begining of google_map.php page
* upload this page to your theme folder.
* go to dashboard to create a page, when create a page chose page telmplate: google map.
that is it, you can read more here
<?php
/*
Template Name: google map
*/
?> | stackexchange-wordpress | {
"answer_score": 5,
"question_score": 3,
"tags": "php"
} |
Is there a plugin that will override the "Error establishing a database connection" message?
My provider's database server recently had some downtime and my site was displaying the classic "Error establishing a database connection" message for about an hour.
I knew what the problem was but realised it would be useful if I was able to replace that message with something a little friendlier (ideally a more verbose message contained within my site's template, so as not to scare users).
My question is: are there any plugins that provide this functionality? Or does this error occur at too low a level for any plugins to be invoked? If so, I'll probably edit the WP core, but it would be nice to use something more pluggable.
Many thanks,
Biggs | <
You can make your own Database Error page by adding a db-error.php to your wp-content folder (/wp-content/db-error.php). You can find a good example of such a page in the link above. Don't forget adding `header("HTTP/1.0 500 Internal Server Error");` in that file so it get a proper header message. | stackexchange-wordpress | {
"answer_score": 12,
"question_score": 10,
"tags": "plugins, database, errors"
} |
Non-UTF characters break RSS feed
I have nasty issue occuring every so often where sometime a guest blogger would inadvertently put a non-UTF character or an unbalanced HTML tag into a post, which will then break the RSS feed and will result in FeedBurner not being able to send it to subscribers via email.
Is there a technological way to avoid this kind of issues?
Thanks! | copy this code in a php file, copy this file in your plugins-folder and after this activate it on the backend of WordPress. I hope this helps, but i dont test it, write it on scratch.
<?php
/**
* Plugin Name: Non-UTF characters in RSS feed
* Plugin URI:
* Description: Filter content for unicode characters
* Version: 1.0.0
* Author: Frank Bültge
* Author URI:
* License: GPLv3
*/
// This file is not called from WordPress. We don't like that.
! defined( 'ABSPATH' ) and exit;
foreach ( array( 'the_content_rss', 'the_excerpt_rss', 'the_title_rss', 'comment_text_rss' ) as $filter )
remove_filter( $filter, 'filter_non_utf8_chars', 0 );
function filter_non_utf8_chars( $content ) {
return htmlentities2( $content );
}
?> | stackexchange-wordpress | {
"answer_score": 2,
"question_score": 1,
"tags": "rss"
} |
Read more does not show up when I write my own Excerpt
On my blog on all my main loops I have it set to show the `excerpt` instead of the `content`
If I make a longer post and leave the `excerpt` text box empty, then wordpress will make it's own excerpt from my post and show the `[...]` or a custom link at the end. Thats great however if I DO enter my own excerpt into the excerpt textbox, it will show that text but it will not show the read more part added to it.
Does anyone know how I can make it always show a read more? | Perhaps a conditional statement like the following will work. The logic is: "If the post has an explicit excerpt, add a read more link. Otherwise, use default excerpt behavior."
if($post->post_excerpt) {
the_excerpt();
echo '<a href="'.get_permalink().'">Read More</a>';
} else {
the_excerpt();
}
You can use this in combination with Gavin's suggestion to unify the appearance of the "Read More" link. | stackexchange-wordpress | {
"answer_score": 4,
"question_score": 2,
"tags": "excerpt"
} |
How to delete terms on plugin deactivate?
I created a list of terms under 'category' when activate plugin. When deactive the plugin, I want to delete them. My function doesn't work, how to make this working?
function ppcontent_deactivate() {
$terms = get_terms( 'category' );
foreach( $terms as $term ){
wp_delete_term($term->term_id,'category');
}
}
register_deactivation_hook( __FILE__, 'ppcontent_deactivate' ); | I recommend not deleting the terms at the point of deactivation.
Instead why don't you delete the terms at the point of uninstallation?
You can use the uninstall hook: <
Or bypass that.
The plugin should create a file named 'uninstall.php' in the base plugin folder. This file will be called, if it exists, during the uninstall process bypassing the uninstall hook.
This may be easier to manage code wise and sometimes people would like to deactivate a plugin and not lose all their data. | stackexchange-wordpress | {
"answer_score": 3,
"question_score": 2,
"tags": "plugins, custom taxonomy"
} |
Disable Visual editor for all users
Is there a way to Disable the visual editor for all users without logging in and setting each user's setting in the admin panel, preferable some way to do it with code in the functions file? | The easiest way seems to be to use the Disable Visual Editor Plugin.
The plugin also recommends that you remove the `wp-includes/js/tinymce/` directory, but will require maintenance every upgrade. | stackexchange-wordpress | {
"answer_score": 3,
"question_score": 11,
"tags": "editor"
} |
Wordpress theme switcher
I want to set up a theme demos site, so I am looking for a theme switcher. I have tried a few of them, they create the demo url like:
example.com/whatever?themedemo=theme-name
But I am looking for any plugin which generates cleaner urls, for example:
example.com/whatever/theme-name
If there is any, please let me know.
So I am looking | This has to do with `.htaccess` rather than wordpress itself.
You could just add a row to your htaccess files.
RewriteRule ^(.+)/theme-(.+)$ $1?themedemo=theme-$2%{query_string}
$1 is argument one, the first appearance of (.+) and is the page name
$2 is the second argument, the second appearnce of (.+) as in the theme name
so if you write:
**example.com/about/theme-thesis** it should get the content **from example.com/about?themedemo=theme-thesis**
try it out! | stackexchange-wordpress | {
"answer_score": 1,
"question_score": 1,
"tags": "theme development, themes"
} |
Terms not appearing in wp_dropdown_categories
I am trying to use wp_dropdown_categories at front end. I got the dropdown box with default "uncategorized", the rest of the category is not there.
function cats_dropdown(){
require_once(ABSPATH . '/wp-admin/includes/template.php');
$args = array('taxonomy' => 'category');
?>
<div>
<?php wp_dropdown_categories($args); ?>
</div>
<?php
}
In the same function, if I try to output wp_terms_checklist, it works. This is confusing. Anything I missed in the dropdown? | It could be that it won't show empty categories, categories that has no posts attached to them.
Try to change `$args = array('taxonomy' => 'category');` to `$args = array('taxonomy' => 'category', 'hide_empty' => 0);` | stackexchange-wordpress | {
"answer_score": 2,
"question_score": 0,
"tags": "taxonomy"
} |
How do you remove the ability for a user to make a comment or post on a page?
I am building a new website on Wordpress, and all my pages have the add comment box at the bottom. I wish fo rthis to be removed from pages such as Home, Contact Us, About etc etc, but want it to remain on the blogs and galleries.
I have read this question but do not really understand what this means to do. is there an easier way to do it. I do not have this option under Settings -> Discussions. | Since you want comments on posts, I would suggest that you not change the discussion options in the Settings section, but you can enable/disable comments on a per post or per page basis.
In the admin area, click to edit a page that you want to restrict comments from. Then, when you scroll down the page, you will see a section called 'Discussion' and you will have an option to disable comments or trackbacks. If you do not see 'Discussion', scroll to the very top of your page, click on 'Screen Options' and make sure that the checkbox next to 'Discussion' is checked.
Note: Depending on your theme. Your page might display 'Comments Closed', or something to that effect. If that happens and you want to remove that text, you might actually have to get your hands dirty and dig into your Pages template. | stackexchange-wordpress | {
"answer_score": 1,
"question_score": 0,
"tags": "comments"
} |
How to use add_action inside files included by theme's functions.php
I've a functions.php inside my theme folder. The first line of `functions.php` is
require_once 'custom.php';
inside `custom.php` I have this simple code:
add_action('wp_print_scripts','add_js_vars');
function add_js_vars(){
//some stuff here
}
The problem with the code above is that add_js_vars is not executed. If I move `add_action('wp_print_scripts','add_js_vars');` inside themes `functions.php` everything works fine. I'm not able to understand what's the problem. Any ideas? Thanks for your help. | Just wrap you `include`(s) in a function and hook it to `after_setup_theme` hook. | stackexchange-wordpress | {
"answer_score": 1,
"question_score": 0,
"tags": "actions"
} |
Store records for a table in wordpress
I need to create a page in wordpress that displays a table with 3/4 fields, and let editors add and update the records in this table.
I'm a drupal developer and don't have much experience with wordpress. I know that in drupal I would just create a content type 'record' and than create a view to display a list. I can't think of any way to achieve that in wordpress (in a user friendly way. apperenetly my suggestion to have an unpublished post for each record with a tag 'record' isn't acceptable on my employers...)
Thank you for your help... | You could use the WP-Table-Reloaded Plugin:
<
Screenshots are on the plugin author's website:
< | stackexchange-wordpress | {
"answer_score": 2,
"question_score": 1,
"tags": "php"
} |
Custom permalink structure only for default posts
Does anybody know how to modify the url struct only for the single post page?
When I go to a post page, the url should look like: example.com/xxx/my-post. All other urls (with the exception of the single post pages) should not contain "xxx" in the url.
Customizing the permalink settings would add xxx in front of taxonomies and categories as well, so that wouldn't work for what I need.
Essentially, I want that all "post" and "events" urls co contain an extra "xxx" segment in the structure. | The solution is to reregister the default post type just after Wordpress, and to add a rewrite slug. Also, the _builtin param needs to be set to false.
add_action( 'init', 'my_new_default_post_type', 1 );
function my_new_default_post_type() {
register_post_type( 'post', array(
'labels' => array(
'name_admin_bar' => _x( 'Post', 'add new on admin bar' ),
),
'public' => true,
'_builtin' => false,
'_edit_link' => 'post.php?post=%d',
'capability_type' => 'post',
'map_meta_cap' => true,
'hierarchical' => false,
'rewrite' => array( 'slug' => 'post' ),
'query_var' => false,
'supports' => array( 'title', 'editor', 'author', 'thumbnail', 'excerpt', 'trackbacks', 'custom-fields', 'comments', 'revisions', 'post-formats' ),
) );
} | stackexchange-wordpress | {
"answer_score": 3,
"question_score": 5,
"tags": "posts, url rewriting, permalinks, single, customization"
} |
Adding jquery and thickbox to WordPress theme
I would like to add thickbox for the template which I develop to WordPress. At this time I'm trying with a clean template that have only `header.php`, `footer.php`,`index.php`, and `functions.php`.
I've included the `<?php wp_head(); ?>` into `header.php` and the `<?php wp_footer(); ?>` into `footer.php`.
I've included the `wp_head` like this:
<?php
wp_enqueue_script('jquery');
wp_enqueue_script('thickbox');
wp_enqueue_style('thickbox');
wp_head();
?>
I've changed the gallery link classes to thickbox with this code in `functions.php`
<?php add_filter( 'wp_get_attachment_link', 'sant_prettyadd');
function sant_prettyadd ($content) {
$content = preg_replace("/<a/","<a class=\"thickbox[slides]\"",$content,1);
return $content;
}
?>
When I'm clicking on to a gallery image it should open with thickbox but it opens the imagefile only. | You need to use the wp_enqueue_script function (in your functions.php file) to call the relevant scripts you need. It allows for both built-in libraries and to add any custom that you're including in your theme. | stackexchange-wordpress | {
"answer_score": 1,
"question_score": 5,
"tags": "jquery, gallery, wp enqueue script, links, thickbox"
} |
On new server, site got hacked, permissions a bit strange? Please help
I moved to a new server recently, a week later a site got hacked, all they did was change the index.php file of the current enabled theme, no big deal. I did have a few security precautions in place, no admin user name, all latest versions, no timthumb issue, .htaccess security etc.
I dont want this to happen again, what I did notice is when logged into my WP admin I can edit the permalinks, or any file within the editor (I tested editing the index.php) and it will save.
On my last two servers, I had to go into the FTP set the permissions of the files to 755 or 777 before making any changes, then put them back to 644.
They are currently set to 644 but I can fully edit them within the admin, do you think this is my problem? Kinda worries me.
Thanks, Matt | You can...
1. Learn about file permission (on wordpress)
2. Install Wordpress Firewall plugin (version 2 for 3+ versions) (this dissalow access to any folder or file indirectly)
3. Hide Your Wordpress Version
4. Try to update plugins & Wp
5. install Login Lockdown Plugin (this stops any brute force attemts)
6. Verify that your theme doesnt show "publish by $username" but shows "display name"
7. Use secret Keys in wp-config.. Keys Generator: here
8. Move wp-config up one directory (wordpress would look for it dont worry..)
Hope this helps... if nothing else - at least install the plugins.
A small tale.. i used to host one of my website in some 1$ per month server (cant recall its name).. anyhow, it got hacked 4 times in 6 month's.. and i know a thing or two about wp security... nothing helped!
But - Once i left that hosting, the hacking stopped... :)
Have a gr8 day. | stackexchange-wordpress | {
"answer_score": 2,
"question_score": 0,
"tags": "security, server, permissions, hacked"
} |
loading custom.js file after jquery is loaded
I am adding a javascript file through the functions.php file. I am using the method as suggested on Wordpress Codex. One question I have is that what is the best way to handle the version number column. Is it recommended to send the version of jquery or the version of the script I am loading? Using this code.
<?php
function my_scripts_method() {
// register your script location, dependencies and version
wp_register_script('custom_script',
get_template_directory_uri() . '/js/custom_script.js',
array('jquery'),
'1.0' );
// enqueue the script
wp_enqueue_script('custom_script');
}
add_action('wp_enqueue_scripts', 'my_scripts_method');
?> | The version is the version of your own script, and is appended to the filename in the src attribute of the script tag. This is so you can employ long-term caching on the client-side and still insure a new version of your script will be fetched from the server rather than local cache if you update it. | stackexchange-wordpress | {
"answer_score": 0,
"question_score": 0,
"tags": "theme development, functions"
} |
Add Word Limit to Posts
Is there a way to limit the number of words per post through the the_content() function or something similar? | You can limit is through a filter on `the_content`
For example (in functions.php):
add_filter("the_content", "Content_Filter_Custom");
function Content_Filter_Custom($content)
{
// return a subset of it
return substr($content, 0, 300);
} | stackexchange-wordpress | {
"answer_score": 1,
"question_score": 1,
"tags": "posts, pages, content"
} |
List Sub-Categories of a Parent Category
I need to be able to list categories that are the sub-category of a specific category that is a sub-category of a primary category.
So something like this:
Print Categories where ParentCategory = 'Parent' And ParentCategoriesParent = 'Main Parent'
So I guess it's a depth of 2.
Kind of a complicated category i'm going for but it will help my users navigate the site much easier. | something like this : < ?? | stackexchange-wordpress | {
"answer_score": 1,
"question_score": 1,
"tags": "categories"
} |
Send a Notification to a Wordpress Theme
I'm basically looking for something or at least a base line to create a piece of code that allow me to send notifications to my clients via the Wordpress CMS.
The Study case is basically like, I'm creating some themes and clients can select between different "modules" to buy, so I'm looking for a way to notify when new modules are available, or when I update some of them.
I've been looking for a solution around and I cannot find anything good enough, would be great.
Thanks in Advanced. | You could add a dashboard widget that grabs a feed. | stackexchange-wordpress | {
"answer_score": 1,
"question_score": 0,
"tags": "plugins, notifications"
} |
Display custom content using page.php from theme
I am developing a plugin and need to generate a blank page (load the `page.php` from the current theme) and print custom content such as an HTML form or a message.
It should have a URL like `
How can I display a page with the current theme's page.php and custom content in it?
**EDIT (18 Jan 2012):**
Found a better and simpler working solution: **Generate a custom/fake/virtual Wordpress page on the fly** | Adding and catching the query vars (`wpex_page=confirm`) is the simple part **`as explained in this answer`** but sine you want to use the theme's default page.php there is something extra you need to do and **`this is a nice tutorial`** which covers it. | stackexchange-wordpress | {
"answer_score": 0,
"question_score": 1,
"tags": "plugins, plugin development"
} |
Error establishing a database connection
I was in the midst deleting trash file and the internet connection is becoming really slow. When I clicked the Products tab in the wp-admin it says that: "Error establishing a database connection", although I did not change anything on the database. Also, there are times that the message: "Access to the webpage was denied" is appearing. I've restarted several times, and tried copying and pasting the link in different browsers, but its still appearing and I wonder why. Hope you guys can get me out of this stuff. I think I'm gonna broke down into pieces now. :( | Try logging into FTP and making sure there is no .maintenance file, also erase the upgrade folder. Its never a good idea to stop wordpress during an automatic update. Take a look at your wp-config file to make sure everything appears correct, it could of been editing it and you cut it off half way. | stackexchange-wordpress | {
"answer_score": 0,
"question_score": 0,
"tags": "posts, wp admin"
} |
Does it matter if two people are using the same Wordpress admin account?
Just wanna ask around if its possible for a person to disconnect from wp-admin when someone is already using the same account? Like for example two people are sharing only one wp-admin account. One will disconnect and the other one will not be disconnected. Is this possible? | yes, It is possible . It is also possible to make it impossible . | stackexchange-wordpress | {
"answer_score": 1,
"question_score": 1,
"tags": "wp admin"
} |
Communicate between plugins
I have created two WordPress plugins. If both plugins are installed, some beneficial cooperation could take place between the two.
So my question: what is the best way to get them to work together? How do I detect a certain plugin is enabled? How do I transmit information? I suppose I could use globals, but is there a better way? | your question depends a lot on what you want to do ..
But in general , when a plugin is loaded or executed, the functions are being "registered" in PHP server and are available for all to use (depending of course HOW you write them) ...
So for example, to detect if a plugin is enabled or installed, the other plugin could have
`if (function_exists('NameOfFunctionFromPlugin1')`
there is also a wordpress function to check plugin activation
<?php is_plugin_active($plugin) ?>
<
as for "transmitting Info" : Because the functions are available, you could use them. so for example, a value that is returned from a certain function in one plugin, can be evoked by the other , calling this function , and getting the value returned for use . | stackexchange-wordpress | {
"answer_score": 2,
"question_score": 1,
"tags": "plugin development"
} |
I am looking for a specialist WordPress host
I am looking for a host to start my new WordPress site.
The criteria for this is that they must totally/truly specialise in WordPress hosting.
Many companies claim to have a certain expertise in hosting WordPress, but the fact is they just have it installed.
I would like recommendations for hosts in the UK but am open to worldwide offers. | A host doesn't need to _specialize_ in WordPress to be a good environment for it. Many hosts supposedly specialize in it, but don't provide any different features than their competitors. If you are looking for officially recommended hosts, take a look at the WordPress recommended hosts. However, I'm not a fan of all of the hosts on that list.
Any **GOOD** web host that meet or exceeds the minimum requirements, has guaranteed uptime and keeps its customers happy, would be a good match. As a web developer, and having built over 100 WP sites, three of my favorite hosts include:
* MediaTemple (Mid-priced)
* Rackspace (Higher-priced)
* HostGator (Cheap)
I like the above hosts because of a combination of great features (and freedom for your developer to manipulate certain configuration options that other hosts do not allow), great customer service, and good, fast, reliable servers.
If you do decide on a host, add a comment and let us know which one you ultimately choose. | stackexchange-wordpress | {
"answer_score": 1,
"question_score": -2,
"tags": "hosting, hosting recommendation"
} |
Updated Files Dont Show on Site. I had a cache program installed
Could that be the reason? I deleted the plugin files but the pages still won't update. When I edit them from the server I see the updated files, but they don't show on the browser.
Tried deleting cache on browser, still no changes. Removed cache code from .htaccess, still no changes. Not sure what else to try.
Thanks. | Did you disable the plugin before erasing the files? This happened to me when trying to update a site, I had to end up disabling the cache plugins, then I redid the .htaccess file. Once I completed the updates I simply re-enabled the plugins and modified the .htaccess. | stackexchange-wordpress | {
"answer_score": 1,
"question_score": 0,
"tags": "plugin wp supercache"
} |
is_front_page use in sidebar.php
I want to introduce some code into sidebar.php dependant on whether the site was on the front page or not. ( I have a static front page and am using the front-page.php file ).
To cut a long story short, I have done some testing and I now have the following code in BOTH my front-page.php file and also in the sidebar.php file; but the two bits of code are displaying conflicting results. The same page is telling me both that I am on front page and not on front page at the same time. The reality is that I actually AM on front page so the question i have is this. Is there something wrong with using the tag is_front_page() in sidebar.php ?
if( is_front_page())
echo "you are on front page";
else
echo "you are not on front page"; | strange thing - try is_home() . what does that returns ? | stackexchange-wordpress | {
"answer_score": 1,
"question_score": 0,
"tags": "theme development, template tags, frontpage"
} |
remove permalink trailing slash
I need to use the_permalink() in order to construct a simple link from each post . the link should be like
I use ?output=something" >
the problem is that the trailing slash of the permalink is giving me an extar trailing slash that is breaking my link .
I know that I can construct the structure in another way , but I want to use the permalink (much easier) and i do not want to change the permalink structure sitewide ...
any way of getting rid of the trailing slash ?? | You can use the `trim` command to do this, specifically, the `rtrim` to remove the character from the right side:
$url = rtrim(get_permalink(),'/');
Using a blanket `substr -1` technique would cause problems if there isn't a trailing slash in the permalink. Also, the function `the_permalink` echoes the link, and `get_permalink` returns it as a string. | stackexchange-wordpress | {
"answer_score": 5,
"question_score": 2,
"tags": "permalinks"
} |
How to Implement SAM Broadcaster with Wordpress?
I want to implement SAM Broadcaster software in wordpress. This is radio automation software. my client wants to implement with wordpress because he want to add some articles and videos regularly with this software.
Current Site: www.radiojazzplus.com
Already some of them Implemented in wordpress and their Link is
1.<
2.<
i can't open both sites due to ip lock for my country (India).I found plugin here Sam Broadcaster plugin but it's not working fully.
If you had done already like please Help me to figure out this problem. i was digging my head for past 4 days and i want your help friends.
Thanks in Advance. :) | The first and only thing I can add to this Q is: Avoid this plugin. At least the free version (don't know how the paid version bahaves).
I got dozens of errors and notices with `WP_DEBUG` set to `TRUE`.
* wp_enqueue_style was called incorrectly. Scripts and styles should not be registered or enqueued until the wp_enqueue_scripts, admin_enqueue_scripts, or init hooks.
* has_cap was called with an argument that is deprecated since version 2.0! Usage of user levels by plugins and themes is deprecated. Use roles and capabilities instead.
* Undefined index: sradiobfm_hidden in (...)\plugins\sam-broadcaster-wordpress-plugin\sradiobfm_admin_settings.php on line 5
It messes up all the admin menu, crashes the complete styles, etc. I'd say: Just tell your client to leave this plugin as it won't be a good choice (not reliable). | stackexchange-wordpress | {
"answer_score": 1,
"question_score": -1,
"tags": "plugin development, customization, plugin recommendation, radio"
} |
AddThis Sharing Bar Not Displaying on Custom Page Template - JS conflict?
< \- on the single posts the sharing bar displays.
< \- on the blog archive page it doesn't (even after choosing archive, category, index as options within the AddThis option, though I have not chosen excerpts at this point because that's not what we want).
This page uses the_content, not get_the_content, and when I view the source, I can SEE the bar in the source below the post meta, but it's just not displaying. Any thoughts as to why it's not showing on this particular page? I've deactivated all the plugins and that didn't fix it.
AddThis support suggests that it's then an issue with the JS in the theme itself, but javascript isn't in my strong skill set - I need help sorting that out. I've just started working with this client so I'm still learning my way around their installation. | The two functions operate differently. get_the_content retrieves the raw data from the database, where the_content retrieves the data, encapsulates areas with paragraph tags, cleans up, and applies filters.
I'm confused which is using which, but if the page that is missing the AddThis is using the get_the_content, try applying the filters from the plugins before displaying it:
<?php apply_filters('the_content',get_the_content( $more_link_text, $stripteaser, $more_file )) ?>
Make sure to use the same arguments as the original get_the_content function call. Strip out any that you aren't using, so the minimum would be:
<?php apply_filters('the_content',get_the_content()) ?>
I should add that the Javascript that you saw on the /blog/ page was not for individual AddThis instances, so it isn't a JS conflict. | stackexchange-wordpress | {
"answer_score": 1,
"question_score": 0,
"tags": "javascript"
} |
Create custom thumbnail size on existing posts
I'm applying a new theme to my site, and the theme has a custom thumbnail size. I realize that `add_image_size()` does the work of creating the custom thumb whenever a new post is created.
This in my theme's **functions.php** :
add_image_size('ttrust_threeColumn', 280, 170, true);
However, I have a bunch of old posts I need to create this thumbnail size for. These old posts have a filename stored in a custom "Thumbnail" field, e.g.:
/wp-content/uploads/2011/11/this-is-my-post-thumb.jpg
I can grab that file path with this:
get_post_meta($post->ID, 'Thumbnail')
Now if I loop through all the old posts, how can I create the custom **ttrust_threeColumn** thumbnail size for each post?
I appreciate the help! I've tried a bunch of different functions and methods, but I can't seem to get a grasp on thumbnail creation for existing posts. | Banjer,
Afaik add_image_size works for new IMAGES, and not for new posts, but regardless of this I think all you need to do is regenerate your thumbnails with the must-have "regenerate thumbnails" plugin.
< | stackexchange-wordpress | {
"answer_score": 2,
"question_score": 1,
"tags": "post thumbnails"
} |
Are tags different than categories?
I'm having a really weird issue where certain tags and categories seem to be linked:
"Linux" in Tags:
!enter image description here
"Linux" in Categories:
!enter image description here
If I try to lowercase the Linux **tag** (I prefer tags to be in lowercase and categories to be properly capitalized), then the Linux **category** gets capitalized too. Are they linked in the underlying database or something? I've made sure that my URLs for categories and tags are different, and they are.
Is this normal? Can I make the Linux tag lowercase and the Linux category have the first letter capitalized? | This is indeed strange behaviour. The slug is a unique key in the table that stores taxonomy terms, if you make sure to explicitly set the slug to something different when you create the term, they will not be linked. However, once you've created a tag and a category with the same slug, it appears they are forever connected, unless you delete one and recreate it with a new slug. I don't think this was always the case though, I distinctly recall WordPress appending `-2` to the slug when attempting to create a term that is the same as a term in another taxonomy. | stackexchange-wordpress | {
"answer_score": 1,
"question_score": 0,
"tags": "categories, tags"
} |
Include default functions and methods
I'm starting a new service for a customer consisting in adding a input API in their WP website. I started by creating a blank page on the root but then I realized I couldn't access all methods and function to insert datas in WP. Basically I need to insert strings and integers as custom post types and meta datas.
What would be the best way to make default functions and methods accessible in my script?
Thanks! | Put this code in the top of your api page, it will call in the functions, but you need to tell wordpress NOT to try and draw a page as well
define('WP_USE_THEMES', false); // Tell wordpress not to draw out a page
require('/path/to/public_html/wp-load.php'); // load wordpress functions | stackexchange-wordpress | {
"answer_score": 1,
"question_score": 1,
"tags": "functions, api, customization"
} |
Is there a has_more_tag() method or equivalent?
I need to determine if the current post has a "more" tag. I'm currently using
$pos=strpos($post->post_content, '<!--more-->');
Am I missing a built in method similar to has_excerpt()? | Quite simply put: there is no built in function that does the same thing as your code above.
Bonus content: More tag tricks | stackexchange-wordpress | {
"answer_score": 2,
"question_score": 8,
"tags": "theme development, read more"
} |
Editor doesn't load properly on my self-hosted WordPress 3.3
I have a self hosted WordPress install on my small VPS running WordPress 3.3.1 powered by nginx. As of the last 3.3 update, the editor fails to load properly - I cannot see the toolbar etc.
When trying to load and edit any existing posts, even the text of the post doesn't load.
My browser's error console shows the following error:
> Uncaught SyntaxError: Unexpected end of input load-scripts.php:153
>
> Uncaught ReferenceError: fullscreen is not defined editor_plugin.js:1
Screenshot:
!enter image description here
Any suggestions? | from wordpress.org/forums:
> WordPress 2.8 includes a concatenation of scripts and CSS. This puts the quality of these scripts at a higher level than before.
>
> The temporary solution is to place it in the wp-config.php one of these two values
>
> define('CONCATENATE_SCRIPTS', false );
>
> or
>
> define('SCRIPT_DEBUG', true);
Now this is from over a year ago, worth a shot. | stackexchange-wordpress | {
"answer_score": 2,
"question_score": 1,
"tags": "editor"
} |
post custom values
I have this code:
<?php $site= get_post_custom_values('projLink');
if($site[0] != ""){
?>
<p><a href="<?=$site[0]?>">Visit the Site</a></p>
<?php }else{ ?>
<p><em>Live Link Unavailable</em></p>
<?php } ?>
After clicking the link I get this adress in the browser <
So i don´t think the
<?=$site[0]?>
is correct.
How can I make it work? Thanks | Use `var_dump($site[0])` to see the structure of the array. And once you know that, then you can properly reference an item in that array. (You could also do `var_dump($site)` to get a full picture of what's going on.) | stackexchange-wordpress | {
"answer_score": 0,
"question_score": 0,
"tags": "array"
} |
Does using a custom query_var create a security hole?
Say I put the following code in functions.php
function add_my_query_vars($qvars) {
$qvars[] = "new_var";
return $qvars;
}
add_filter('query_vars', 'add_my_query_vars');
If somebody requests `my.site.com/?new_var=[MALICIOUS CODE]`, can they cause any damage? If not, why not?
**Edit for clarity** : I know that user input should be considered harmful. My question is whether WP vets the data that makes it into $wp_query. | Regardless of whether you registered `new_var` as a query_var, all GPC data (GET, POST, COOKIE) should be considered tainted. Basically, this data is user input. This means that you will need to clean and validate the data anyway.
Common cleaning methods include casting the variable to a certain type (like integer or string), using a regex to validate strings, etc. Also, if you are accessing `$_GET` data directly, don't forget to do an `isset()` or `empty()` check first to prevent "undefined index" notices.
**Edit:** In the first place, my answer applies to accessing GPC data via PHP's superglobals. That being said, if you use `get_query_var()` to retrieve your variable, as far as I see, you still need to clean the variables you registered yourself. WP will clean its standard query vars, of course. See the `parse_query()` function in `wp-includes/query.php`. | stackexchange-wordpress | {
"answer_score": 3,
"question_score": 0,
"tags": "wp query, security"
} |
How can I remove the "updates" menu in the Wordpress Admin panel?
How can I remove the "updates" menu in the Wordpress Admin panel?
Picture 1.png | You can use the `remove_submenu_page` function:
add_action( 'admin_init', 'wpse_38111' );
function wpse_38111() {
remove_submenu_page( 'index.php', 'update-core.php' );
} | stackexchange-wordpress | {
"answer_score": 8,
"question_score": 1,
"tags": "admin, menus"
} |
loading javascript after jquery is loaded
I want to load some javascript for the front page of my theme after jquery and jquery ui is loaded. what would be the hook to use?
I am aware of the functions.php and I have used is_front_page(). By inserting wp_register_script in functions.php, I can queue the script after the libraries I want loaded but I also want to load it only on the frontpage. Using is_front_page() on header.php, the script gets loaded ahead of jquery.
How could I load my javascript after loading the jquery and only on the front page? | Enqueue the script in your functions.php instead of the header, wrap it in the conditional tags ( in your case `is_front_page` ) and use the proper enqueue dependency, you can change the load order by altering the `add_action $priority` parameter or use `$in_footer` | stackexchange-wordpress | {
"answer_score": 1,
"question_score": 0,
"tags": "theme development, jquery"
} |
Is there a limit on the number of attachments?
It seems there's a limit on the number of attachments of a post?
I have 265 images uploaded for one of the posts (yes, I know it's quite a few), and when I want to put them into order. The result: only 125 of them gets number, the others a left without one and also I only see 140 images.
The tabs says "gallery (265)", and it is ok, but I only see 140 images when I open the gallery tab. | Just tested with WordPress 3.4.2 and 3.5.2-beta2.
With 317 files, this issue does not comes up (order or maximum number of shown items).
!wp3.4.2 snapshot | stackexchange-wordpress | {
"answer_score": 1,
"question_score": 2,
"tags": "uploads, media library, limit"
} |
Query posts alphabetically within this function
I've been given some code to tidy up and edit a bit and the client wants to organize a custom post type named "plans" alphabetically.
It's not a straight forward query and I've never come across anything like this before, any ideas?
<?php $planIDs = get_post_meta($post->ID, '_lm_comm_plans', false); ?>
<?php foreach ($planIDs as $planID) : ?>
<?php $pdfID = get_post_meta($planID, '_lm_plan_pdf', true); ?>
<?php $pdfURL = wp_get_attachment_url($pdfID); ?>
<?php $planTitle = get_the_title($planID); ?>
<li class="plan"><!-- content here --></li>
<?php endforeach; ?> | You'll need to run through get_posts() to apply the order by handling.
$planIDs = get_post_meta( $post->ID, '_lm_comm_plans', false );
foreach( get_posts( array( 'post__in' => $planIDs, 'orderby' => 'name', 'order' => 'ASC', 'post_type' => 'plans' ) ) as $plan ) {
$pdfID = get_post_meta( $planID, '_lm_plan_pdf', true );
$pdfURL = wp_get_attachment_url( $pdfID );
$planTitle = get_the_title( $planID );
?>
<li class="plan"><!-- content here --></li>
<?php
} | stackexchange-wordpress | {
"answer_score": 0,
"question_score": 0,
"tags": "query, sort"
} |
Change permalink for custom post type?
I have a page called Food which displays posts from 2 custom post types - Recipes and Restaurants.
How do I add 'food' to the permalink just for those two custom post types? - e.g. www.mysite.com/food/recipes/thepost | Check out the rewrite parameter for register_custom_post_type. You may specity a slug that will be added before. So if you have two separate post types for recipes and restaurants set for one '/food/recipes' and for the second one '/food/restaurants'. You must visit the Settings->Permalinks after this is done so that the rewrite rules will refresh. | stackexchange-wordpress | {
"answer_score": 1,
"question_score": 0,
"tags": "custom post types, permalinks"
} |
How to access variables from Functions file in theme files
I just noticed, in a theme file, I can access custom functions I add to my functions file, however I can NOT access variables I set in my functions file.
I have a few variables I set inside my functions.php file for example...
$feedburnerUsername = 'username';
Now in my sidebar.php file If I try to access this variable, it is not available, how can I make it available? | Whilsts @Shaon's answer is perfectly valid, I'm of the opinion you really shouldn't be throwing configuration settings around as global variables - use a constant instead.
/* Constants are in the global scope, but can only be defined once. */
define( 'FEEDBURNER_USERNAME', 'my_username' );
define( 'FEEDBURNER_PASSWORD', 'my_password' );
If the variable needs to be dynamic (for example, if it's an option in the database), use a function that returns it:
function get_feedburner_config( $option = null )
{
$config = get_option( 'feedburner' );
$config = wp_parse_args( $config, array(
'username' => 'default',
'password' => 'default'
));
if ( $option )
return isset( $config[ $option ] ) ? $config[ $option ] : '';
return $config;
} | stackexchange-wordpress | {
"answer_score": 3,
"question_score": 0,
"tags": "php"
} |
wp_mail is sending two emails when used after retrieving session data
I'm using the wp_mail function to send emails in WordPress. Before I run the function, I retrieve a heap of data from a session and some others from a form that was just submitted. For example:
$first_name = $_SESSION['first_name'];
$last_name = $_SESSION['last_name'];
$phone_number = $_POST['phone_number'];
$message = $first_name . $last_name . $phone_number;
wp_mail($myemail,"Email sent",$message);
I'm using the plugin called WP-MAIL SMTP to send via Gmail's SMTP servers. When I disable this, no emails are sent at all.
For some reason, I receive two emails. One has the POST AND SESSION information and the other only has the SESSION information.
Any help would be greatly appreciated! Thanks in advance,
Jamie
I'm using WordPress 3.3 | It sounds like you don't have your code wrapped into an `if` statement that'll check it only gets executed if the form was actually submitted, i.e. it gets run when you first view the page (`GET`) and again when you submit the form (`POST`). You can use the below snippet to ensure that the e-mail is only sent when the form has been submitted:
if ($_SERVER['REQUEST_METHOD'] == 'POST')
{
$first_name = $_SESSION['first_name'];
$last_name = $_SESSION['last_name'];
$phone_number = $_POST['phone_number'];
$message = $first_name . $last_name . $phone_number;
wp_mail($myemail,"Email sent",$message);
} | stackexchange-wordpress | {
"answer_score": 2,
"question_score": 1,
"tags": "wp mail, session"
} |
Which to use to execute code during the saving of a plugin settings page?
I'm writing a plugin with a settings/option page and I want some php code to be executed whenever someone saves the settings on that page and that page alone. Which actions do I need to hook into to accomplish this? | If you're using Settings API, then you should use a sanitize callback:
register_setting( $option_group, $option_name, $sanitize_callback );
The myth is that the `$sanitize_callback` actually is a filter for your options when it's saved in the database. This is the place where you can do something with your custom code.
This is the sample code:
register_setting( 'wpse38180', 'wpse38180', 'sanitize_wpse38180' );
function sanitize_wpse38180( $options )
{
// Do anything you want
return $options;
} | stackexchange-wordpress | {
"answer_score": 4,
"question_score": 5,
"tags": "plugin development, actions, customization, settings api"
} |
Using BuddyPress > 'Register page'
Can someone help me figure out the Buddy Press plugin.
I have a magazine Wordpress website created with an open source theme and style and very slight html alterations and customizations.
I've downloaded all the necessary BuddyPress plugins:
**BuddyPress
BuddyPress Sliding Login Panel
BuddyPress Template Pack**
And it allows me to set/define pages for 'groups, members, and activity' but I cannot figure out how to implement a 'Register' page for people to register as that's the whole point of using the plugin. Now the screen where I "can" select which page to devote to register, no matter which I set it to, it just redirects to my home page. It allows me to create forms for a sign-up/register page, but can't implement it and get it to appear.
Can someone help?
_Cheers as always_ | Have you tried logging out first, then going to the register page?
It won't show if you are logged in | stackexchange-wordpress | {
"answer_score": 1,
"question_score": 0,
"tags": "plugins, buddypress"
} |
Adding to he format dropdown menu tinyMCE in Wordpress
Does anyone know the steps needed to add a custom format to the blockformat (p,h1,h2,h3 etc.) dropdown in the tinyMCE editor in Wordpress?
I've found a lot of different ways to do that, which seem to either contradict each other or have absolutely no effect.
I've had very little interaction with Wordpress as a developer so I'm not even sure where what is located. wordpress tinymce | function extend_tiny_mce_defaults( $config )
{
// comma separated list of any block-level HTML tag
$config['theme_advanced_blockformats'] = 'h1,h2,h3,h4,h5,h6,p,code,address';
return $init;
}
add_filter( 'tiny_mce_before_init', 'extend_tiny_mce_defaults', 100 ); | stackexchange-wordpress | {
"answer_score": 0,
"question_score": 0,
"tags": "tinymce, formatting"
} |
Run a function when post is deleted?
Is it possible to run a function every time a post is deleted. The function has to be run when the post is deleted from the admin or by the wp_delete_post() function. | Yes, by adding an action to the before_delete_post, delete_post, or deleted_post actions. | stackexchange-wordpress | {
"answer_score": 4,
"question_score": 1,
"tags": "posts, functions, customization"
} |
Get post id in wordpress action?
I have this code
add_action( 'delete_post', 'my_delete_function' );
function my_delete_function() {
global $wpdb;
$wpdb->query("
DELETE FROM wp_votes WHERE post=".$thePostID."
;);
}
How can I get the id of the post being deleted?
Additionally, will this still work if multiple posts are deleted in the admin? | I haven't tested so I'm providing you with two possibilities, Inside a loop, use the following:
$post_id = get_the_ID();
Outside a loop, use the following:
global $wp_query;
$post_id = $wp_query->post->ID;
Or:
global $post;
$post_id = $post->ID
Or you can pass the post ID in a function, much like
function my_function($post_id){
// code
} | stackexchange-wordpress | {
"answer_score": 2,
"question_score": 1,
"tags": "posts, actions, customization"
} |
Custom Post Type with has_archive ignores my custom archive and single template
I'm trying to set up a new CPT called news (see code here: < and I'm specifying the has_archive parameter.
I've set up a new template called archive-news.php and single-news.php but its not being used when I go to /news/ or the permalink on the site. Instead the default archive.php and single.php gets loaded.
I've flushed the rewrite rules but still does not work.
This is the first time I'm using the has_archive parameter but after lots of searching I still can't see what I doing wrong.
Hopefully it's just a stupid mistake somewhere that someone can spot for me. | Your custom post type is `je_news`. This means that your single and archive files should be called **single-je_news.php** and **archive-je_news.php**.
The `has_archive` option enables you to change the archive url, but it doesn't override what the templates should be named. | stackexchange-wordpress | {
"answer_score": 2,
"question_score": 1,
"tags": "custom post types, custom post type archives"
} |
Remove Wordpress.org Meta link
In my footer, I have a set of links labeled Meta, it has...
Register
Log in
Entries RSS
Comments RSS
Wordpress.org
How can I remove just the wordpress.org and and comments rss link from the meta links? | Depending on your theme, they may be hard coded into a sidebar or footer file. If this is the case, you will need to get your hands dirty and edit your theme files.
But you can usually remove them by adding a widget, as these items often only show up when no widgets have been added. So go to Appearance -> Widgets and add the widgets that you want in the appropriate sidebar. | stackexchange-wordpress | {
"answer_score": 6,
"question_score": 3,
"tags": "post meta"
} |
Add Custom Profile Field as Notes
I would like to add a custom field "NOTES" to the user profile. This custom field should not only be updated,saved and display the current value but be displayed as ongoing (previous and current) notes on the user profile. For example:
1/1/2012 user xx wrote: Lorem ispum ispum 1/2/2012 user xx wrote: Lorem ispum ispum ispum 1/3/2012 user xx wrote: Lorem ispum ispum ispum ispum
All "Notes" that the user adds should be displayed on his profile.
Any help is highly appreciated! Thank you! | it would be easier to create a custom post type Notes, than on a user page just get all notes of a specific author and than display them. By creating a custom post type you may easily create a interface and all saving/handling functions. If you would like to do it as a custom field in the user edit screen it would take a lot of work, and it would be just a waste of time cause currently custom post types are really great to customize. | stackexchange-wordpress | {
"answer_score": 2,
"question_score": 0,
"tags": "custom field"
} |
Hide Selection of Text From Archive, but Show on Single Posts
I'm looking for a shortcode similar to this:
[hidetext]some text to hide[/hidetext]
Then what will happen is that the the tag will hide the text from any page that isn't the Single Post page. Only on the Single Post Page will the `[hidetext]` show. How can I do something like this? | add_shortcode( 'hidetext', 'my_hidetext_shortcode' );
function my_hidetext_shortcode( $atts, $content = '' ) {
if( is_single() )
return $content;
else
return;
}
Docs: `add_shortcode()`, `is_single()`
Solution is untested. | stackexchange-wordpress | {
"answer_score": 2,
"question_score": 0,
"tags": "shortcode, archives, single"
} |
Adding uploaded images to editor from metabox instead of default popup uploader
I need to find plugin or create listing of all uploaded images for some post in custom metabox. And i can click to thumbnail for add image to editor in custom format.
I downloaded a lot of photos to default upload box, and each time i will do a lot of clicks for insert new image to editor. It is very uncomfortable. | Faster Image Insert?
> Moves built-in Media Manager down in a meta-box, right next to main editing panel, so you have full control of the manager: opens it, makes it collapse or hidden from the interface completely.
>
> Best of all, is now you can insert image(s) much faster, and precisely where you want them to be. | stackexchange-wordpress | {
"answer_score": 1,
"question_score": 2,
"tags": "metabox, uploads, thumbnails"
} |
Disabling TinyMCE keyboard shortcuts altogether
I've disabled pretty much every button in the visual editor, besides bold and underline. The problem is that the functionality of the other buttons are still there with the keyboard shortcuts. Is there someway to disable the keyboard shortcuts. I don't need them at all. | Not really a wordpress question - but have you tried
tinyMCE.init({
..
custom_shortcuts : false
});
??
(might have a problem with IE though , on which case, you can override them with a foo function.)
function disableShortcuts(){
tinyMCE.get('elm1').addShortcut("ctrl+b","nix","foo");
tinyMCE.get('elm1').addShortcut("ctrl+i","nix","foo");
}
after that you will need to add the "foo" command to tinMCE:
tinyMCE.init({
//your other stuff
oninit : "disableShortcuts",
setup : function(ed) {
// Register foo command shortcuts
ed.addCommand('foo', function() {
//foo function does null
});
}
}); | stackexchange-wordpress | {
"answer_score": 2,
"question_score": 2,
"tags": "tinymce"
} |
Custom Module, Extending WP with a Plugin?
I'm trying to determine the best way to expand on WP.
I love the base of WP for a website... it has pretty much everything needed for a website.
But now and again I need to be able to create some custom "pages" or small apps within the WP framework. For example, I've created a small app within a sub-directory of my WP install (/cart) for a purchase form. I'm including the WP head for access to the WP methods, but I don't feel that this is the most effective way of extending WP.
I've also looked into integrating other PHP frameworks like CodeIgniter and Yii ... again, I'm not sure this is the best approach.
Is there a way to create a WP plugin that has it's own "directory" or path? <
WP has so many great things going for it, that I'd love to be able to expand on it without touching the core.
Thanks in advance. | I think you could do that by creating a plugin that you can integrate into a page.
E.g. mingleforum uses a shortcode, which you can use to create the forums. You create a page, with the URL you want, e.g. "CUSTOMAPP" page with URL "example.com/customapp", and then within that page use the shortcode to instantiate your app. | stackexchange-wordpress | {
"answer_score": 1,
"question_score": 0,
"tags": "plugins, plugin development, framework, customization"
} |
How do I know which plugin uses the most resource?
After installing several new plugins I discovered my site is getting slower. Is there a way to know which plugin utilizes the most resource without using the obvious method of activating/deactivating each plugin one by one? | Try this plugin: < | stackexchange-wordpress | {
"answer_score": 1,
"question_score": 2,
"tags": "plugins, performance"
} |
Is there a decent private message plugin for Wordpress?
I've tried Private Messages for Wordpress, but are there any alternatives? | I found the following ones with good or fairly good ratings:
* WP Private Messages
* Cartpauj PM | stackexchange-wordpress | {
"answer_score": 1,
"question_score": -1,
"tags": "plugin recommendation"
} |
User-friendly link to attached images for a certain post?
I have set up a slideshow running on the front page of my site that runs on images attached to a page called 'Home'.
I would like to be able to adjust its contents and order from the admin area. And lo, I can do this, by going to the 'Home' page in pages, clicking on the Media Library, going to the 'Gallery' tab and reordering/editing each of the attached images.
But this is not very convenient for the person who will use the site.
Can anyone recommend a plugin that allows for very simple management of attachments for a given post? Even if it's just a link I can place it in a metabox on the Dashboard and they needn't follow the above tortuous route to get to where they need to be.
Thanks! | The Gallery tab of the Media Uploader for an individual post is located at this link: (change the post ID as needed.)
I have no idea how robust this is, but I did a quick test on my own site, and the changes I made were saved correctly. | stackexchange-wordpress | {
"answer_score": 1,
"question_score": 1,
"tags": "plugin recommendation, media library"
} |
Why max-width:97.5% on content images?
Is there a specific reason why we find `max-width:97.5%` instead of `100%` in common themes such as Twenty Eleven? | Since the TwentyEleven theme also includes some default padding and a border for (fluid) images (see CSS below), a width of 100% would push the image outside of its container's width. This is because of how the box model works: border and padding are added to the width/height.
img[class*="align"], img[class*="wp-image-"], #content .gallery .gallery-icon img {
border: 1px solid #DDDDDD;
padding: 6px;
}
A better solution would be to change the box model calculation for images in this case. A CSS3 property called `box-sizing` is available for that.
img.size-full, img.size-large {
height: auto;
width: auto;
max-width: 100%;
-webkit-box-sizing:border-box;
-moz-box-sizing:border-box;
box-sizing:border-box;
}
Note: `box-sizing` does not work in Internet Explorer 7 or lower. | stackexchange-wordpress | {
"answer_score": 4,
"question_score": 3,
"tags": "theme development, css, theme twenty eleven"
} |
What happened to convertEntities?
I was using the javascript function convertEntities in a plugin that worked great until recently and now the function seems to have vanished under 3.3 - Is there a substitute function I should be using?
I am tempted to just copy the function into my script - is there a reason that is a bad idea? | `convertEntities` was removed because strings are passed to JavaScript via `json_encode()` now:
< | stackexchange-wordpress | {
"answer_score": 2,
"question_score": 3,
"tags": "plugins, javascript"
} |
Get user id from email?
I'm working on an email system, and I'm onto the unsubscribing stage. Since most of my users would not know their user ID, I'm asking them to put their email into a text box (definitely preferred, since this IS an email system). In order to change their user meta (their subscribed status), I need to know the users ID. I mean I suppose I could pass it into an email and put it in the unsubscribe link, but I'm planning on sending out emails to people who don't have wordpress accounts.
So my main question is this:
What logic or functions should I use to determine a users ID from an inputted email address, and if none are found, store them in the wordpress database?
Thanks, I appreciate every answer!! | You are probably looking for the `user_exists` function. <
> This function will check whether or not a given email address ($email) has already been registered to a username, and returns that users ID (or false if none exists).
If the email address does not exist (`user_exists` returns `false`), you may want to use the `wp_create_user` function. <
> The wp_create_user function allows you to insert a new user into the WordPress database
Only do that if you want to create a WordPress user though, which you may or may not. I'm a bit confused by this part of the question. | stackexchange-wordpress | {
"answer_score": 3,
"question_score": 3,
"tags": "functions, email, id, input"
} |
Assign Custom post to Custom Taxonomy
I have a custom taxonomy called 'product_type' and a a custom post called 'product'. I have a cron job that is pulling in data from an external system and adds products as custom posts using `insert_post($post)`. This returns the post id. I now need to assign the product to the 'DVD' product_type in the taxonomy. I have tried `wp_set_object_terms( $object_id, 'dvd', 'product_type' )` but I dont know what goes in the object_id variable, post_id doesnt work.
Can anyone help please? John | $object_id is supposed to be a post's ID, make sure first that $post->ID would even output an ID, if not, the problem lies there. | stackexchange-wordpress | {
"answer_score": 0,
"question_score": 1,
"tags": "custom post types, custom taxonomy"
} |
Why am I timing out when using the Menu Editor?
I'm using a more or less fresh local install of WP 3.3.1. A few days ago I set up a couple menus (Appearance > Menus) without a hitch. Today I tried creating a new menu and add a page to it, but the page was never successfully added to the menu; the spinner just went on forever.
I thought maybe the menu name was conflicting with one I had deleted earlier, but I can no longer add pages to new or existing menus. The same goes for custom links; I just get the spinner even after waiting 15 minutes.
I only have one plugin enabled, Advanced Custom Fields 3.0.6, which I disabled to no avail. I have no custom post types or taxonomies. There are about 15 pages total with very little content on them, so WP isn't getting stuck sifting through a bunch of data. Any other ideas? | OK, I looked through the error log in MAMP and discovered a bunch of weird garbage. After Googling some pertinent strings (i.e. "caught SIGTERM, shutting down"), the best advice I got was to reinstall PHP with MAMP; now it's working as expected. | stackexchange-wordpress | {
"answer_score": 0,
"question_score": 1,
"tags": "admin, menus, admin menu"
} |
How does wordpress link page templates to individual pages
According to the Codex docs, wordpress uses the query string and the template hierarchy to determine which template to use for a certain page.
> First, WordPress matches every Query String to query types — i.e. it decides what type of page (a search page, a category page, the home page etc.) is being requested. Templates are then chosen — and web page content is generated — in the order suggested by the WordPress Template hierarchy...
However, using Dashboard settings, you can hand pick templates for pages:
!screenshot of dashboard page attributes
So, in this case, how does the Wordpress engine determine this, and where is the information stored? | It's stored in post meta under the key `_wp_page_template`. | stackexchange-wordpress | {
"answer_score": 1,
"question_score": 0,
"tags": "pages, templates"
} |
Conference website with ticket-sales + sponsorship sales with WordPress?
I am considering moving away from Drupal and drupal-cod due to the lack of good themes.
The two major features I am looking for are:
1. Ticket sales (PayPal), with receipts sent to attendee
2. Sponsorship sales (PayPal with different options: Gold, Silver, Bronze by price-range)
Secondary features:
* StackOverflow style forum accessible by users within a specific role
* Facility to send newsletter to all attendees
**Can you recommend a good set of free plugins, preferably built into one project for WordPress?** | I recently used < for WDC2011 in October, I didn't look to far in to all the options but I think it can do everything you're looking for.
I'd suggest also using MailChimp for emailing attendees as it is far better than anything I've found to plugin to WordPress. | stackexchange-wordpress | {
"answer_score": 1,
"question_score": 0,
"tags": "plugin recommendation, events, paypal, forum, stackoverflow"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.