INSTRUCTION
stringlengths 11
999
| RESPONSE
stringlengths 0
999
| SOURCE
stringlengths 16
38
| METADATA
dict |
---|---|---|---|
'Remote Login' with MultiSite Domain Mapping still forcing users to login to all blogs individually?
I'm having trouble with the 'Remote Login' option of MultiSite domain mapping. I have a local dev install which allows me to swap between network blogs _without_ needing to login to each blog individually (which is my understanding of what Remote Login allows?). But the live version of the Network forces all users to login to each network blog individually (which is frustrating).
I have picked Otto's brain about it --as he mentioned some time ago that the Remote Login feature was "iffy at best"-- and he suggest he's not had any later success without custom scripting. @pwcc has had success with it though not whilst using Theme My Login plugin (which I'm using).
Any suggestions anyone?
* I have tested in multiple browser, and cleared cookies
* I do not have any cache plugins installed
|
I wonder why there seem to be so few people having trouble with this. It's a major bug and thus I created the following ticket just now:
<
Not an answer, but just FYI.
|
stackexchange-wordpress
|
{
"answer_score": 1,
"question_score": 3,
"tags": "multisite, login, remote"
}
|
Report spam button
I can't find any plugin or script to place a "report as spam" button in my comments section.
The button could simply: \- open a form to report a spammy or problematic comment to the admin \- send an email or store in the db the problematic comment ID ready for being checked/deleted by admin.
I have a lot of comments that are not really spam, but people trying to advertise products/services where they shouldn't (akismet of course doesn't work for them). It could add an extra layer of spam fighting with the direct help of users.
Any ideas on how to achieve that?
|
There a a few plugins that allow visitors to report comments
* AJAX Report Comments
* Safe Report Comments
|
stackexchange-wordpress
|
{
"answer_score": 1,
"question_score": 2,
"tags": "comments, admin, spam"
}
|
Numbering only parent comments
I am actually displaying a number beside my comments putting `$counter = 0;` before wp_list_comments in comments.php and
global $counter;
$counter++;
inside the comments callback function in functions.php
Now this is working fine, but since I'm using threaded comments, my numbers are looking strange (1,4,10,14) because it's counting also the child comments.
Is there a way to count only parent comments (1,2,3,4,5...)?
Thanks
|
You can check if the comment has a parent and only count if not:
global $counter;
if ($comment->parent == 0){
$counter++;
}
|
stackexchange-wordpress
|
{
"answer_score": 1,
"question_score": -1,
"tags": "comments"
}
|
Multiple Page Templates & CSS
What's the best practice for handling CSS on a theme with multiple page templates?
For example: I will have a Full Width page template and a 2-column page template.
Is it best to just call out the containers in a single CSS (#fullWidthContainer vs. #twoColumnContainer)
Or is it better to have separate CSS files for each page template?
|
This isn't really WordPress specific, but from the server perspective it would add additional http requests for visitors to load additional css files, versus pulling the same site-wide css file from cache.
From a css perspective, I prefer to keep it all in one file. Some people prefer to organize things differently, like all text styles in one file and then layout specific stuff in another. In that case, they may keep layouts specific to certain templates separate.
For simple layout differences, I do something like:
template a:
<div id="main-content" class="full-width">
</div>
template b:
<div id="main-content" class="narrow-width">
</div>
css:
#main-content {
/* common to all content */
}
.full-width {
width:500px;
}
.narrow-width {
width:300px;
}
I keep IDs meaningful to the content, and use classes to define layout.
|
stackexchange-wordpress
|
{
"answer_score": 2,
"question_score": 1,
"tags": "theme development, css, page template"
}
|
Is there a way to specify an extra class for a post or page with no title?
If I do a post or a page with no title, I'm left with an empty `h1` tag at the top of the post/page.
I'd like to either get rid of the `h1` in these cases, or else be able to add an extra CSS class to the post/page so that I can specify how to display the post (and the `h1`) differently when the post/page is published with no title.
Are either of these things possible?
Thanks.
|
To add an extra class when there is no title
<h1<?php if(!get_the_title()){echo ' class="no-title"';}?>><?php the_title();?></h1>
Or to only display h1 tags when there is a title
<?php if(get_the_title()) { ?>
<h1><?php the_title();?></h1>
<?php }?>
|
stackexchange-wordpress
|
{
"answer_score": 4,
"question_score": 0,
"tags": "posts, css, pages, title"
}
|
Define new user capability for custom post types?
If I create a custom post type and want to create custom capabilities for that, how do I do this? For example, I want to let my Editors to edit and create and delete posts and pages, but not the custom post type I've created? I also want to have the possibility to change the capabilities later with this plugin: < (see the screens of the available capabilities: < I've done this by now this way:
global $wp_roles;
if(!isset($wp_roles)) {
$wp_roles = new WP_Roles();
}
// add capability $cap to role $role
$roles = $wp_roles->get_names();
$wp_roles->add_cap('administrator', 'organize_matches');
But then even I as administrator am not able to save the custom post type (and yeah, I mentioned 'organize_matches' in the 'capabilities' argument when registering the custom post type). Really appreciate Your help!
|
Use `'capability_type'` & `'capabilities'` when you `register_post_type()`.
|
stackexchange-wordpress
|
{
"answer_score": 1,
"question_score": 1,
"tags": "custom post types, customization, user roles, capabilities"
}
|
Wrap Post count in a span
I'm using this code:
$args = array(
'hide_empty' => FALSE,
'title_li'=> __( '' ),
'show_count'=> 1,
);
wp_list_categories($args);
How can i wrap the post count in a span for further styling?
Thanks
|
adding a filter to functions.php of your theme is one possibility:
add_filter('wp_list_categories', 'cat_count_span');
function cat_count_span($links) {
$links = str_replace('</a> (', '</a> <span>(', $links);
$links = str_replace(')', ')</span>', $links);
return $links;
}
this would add the spans to any occurrence of 'wp_list_categories()' site wide.
or change your code into:
$args = array(
'hide_empty' => FALSE,
'title_li'=> __( '' ),
'show_count'=> 1,
'echo' => 0
);
$links = wp_list_categories($args);
$links = str_replace('</a> (', '</a> <span>(', $links);
$links = str_replace(')', ')</span>', $links);
echo $links;
|
stackexchange-wordpress
|
{
"answer_score": 13,
"question_score": 4,
"tags": "categories"
}
|
How to enable hierarchical permalinks for hierarchical taxonomies
If you have a category called "term" and a subcategory called "subterm", your can access subterm posts at /cat/subcat. But this doesn't work out of the box with custom taxonomies. They are accessible at /taxonomy/subterm, but not /taxonomy/term/subterm.
They've gone over this in the Wordpress Trac (< and it kind of _looks_ like they have a solution, but as I've never used the Trac and don't fully understand its language (diffs, etc), I need someone more experienced to actually tell me how to implement this. Is there code there that I have to paste into Wordpress core files? Is this already implemented and I can add something to my theme's functions.php?
If possible I'd prefer not to modify any core files. Help!
|
This is implemented in WordPress now as of 3.1.
When you register your taxonomy, make sure to set rewrite hierarchical to true as well as the taxonomy itself:
<?php
register_taxonomy('genre',array('book'), array(
'hierarchical' => true, // this makes it hierarchical in the UI
'labels' => $labels,
'show_ui' => true,
'query_var' => true,
'rewrite' => array( 'hierarchical' => true ), // this makes hierarchical URLs
));
|
stackexchange-wordpress
|
{
"answer_score": 9,
"question_score": 3,
"tags": "custom taxonomy, permalinks, rewrite rules, hierarchical"
}
|
Looking for a good way to include php code in posts, but using special include markup rather than direct php code
Ok, bit of a weird one... I want to include php code on one of my pages within the content by adding something like:
Welcome to the payment page
[paymentform]
Blash blah vlha...
And then [paymentform] resolves to a bit of code either somewhere on the filesystem or within the database and handled by a settings page in the backend.
I didn't want to use the exec-php plugin for several reasons - mainly I don't want our client messing with the php code, secondly there are limitations using that with the visual editor etc..etc..
Cheers, John.
|
Have a look at the Shortcodes API <
|
stackexchange-wordpress
|
{
"answer_score": 1,
"question_score": 0,
"tags": "plugins, php, code"
}
|
post count is wrong when using same taxonomy for 2 different CPT
1 custom taxonomy registered for 2 different CPT (custom post type). When i entered to edit tag section on edit-tags.php?taxonomy=mytaxonomy&post_type=cpt1 it displays total post count of 2 different CPT. Is there any way to fix that?
|
This is a known issue see Custom taxonomy count includes draft & trashed posts. It might not be fixed in version 3.2 but most likely in the next version.
|
stackexchange-wordpress
|
{
"answer_score": 3,
"question_score": 3,
"tags": "custom post types, custom taxonomy, terms"
}
|
register_taxonomy and register_post_type does not work
I have a problem using the register_post_type and register_taxonomy on my Wordpress. I created the code on my functions.php and it does not update my panel. Why?
//Categorias personalizadas
register_taxonomy('produtos', 'produto', array('hierarchical' => true, 'label' => 'Categorias de Produtos', 'query_var' => true, 'rewrite' => true));
//Posts personalizados
add_action('init', 'create_post_type');
function create_post_type() {
register_post_type('produto',
array(
'labels' => array(
'name' => __('Produto'),
'singular_name' => __('Produto')),
'public' => true,
'rewrite' => true,
'supports' => array('title','editor','author','thumbnail','excerpt','comments','custom-fields','image'),
'has_archive' => true)
);
}
|
I copy pasted your code into my functions.php and it worked for me, make sure you are using a recent version of WordPress that supports Custom Post Types
|
stackexchange-wordpress
|
{
"answer_score": 3,
"question_score": 1,
"tags": "custom post types, actions, filters"
}
|
Migrating users from .com to .org?
I am in the process of migrating my blog from my wordpress.com address to a self-hosting (wordpress v3.1.2) address.
Blog has migrated across nicely.
Appears my users have also migrated across, but they cannot login with there old credentials (which are tied to wordpress.com, right)?
I have around 30 users, and I would like to minimise the amoutn of work they have to do, to re-register to get access to the wp-admin console.
What is the best way to keep the new users, but perhaps reset all there password to 'password'?
|
I don't know if you can see the email addresss of your users in wordpress.com blog as i never used it. If you can, as you have not too many users you may try to add them manually from wordpress dashboard and send them an email with the password if you have access to the email address.
|
stackexchange-wordpress
|
{
"answer_score": 1,
"question_score": 3,
"tags": "users, migration, password"
}
|
Redirect from home page to post list page?
There is a site at ` that I want to be redirected to ` when a user enters the site. I've tried some stuff like
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} ^/$ [OR]
RewriteCond %{REQUEST_FILENAME} ^$
RewriteRule . [R=301,L]
but it doesn't work.
Also there are some redirections that were put into `.htaccess` by WordPress
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
I guess they should remain as is?
|
Here is how I'd do it:
<
1. Install above plugin
2. Create a page
3. Add custom field: redirect of a value of <
4. Set page you have created to the sites homepage.
|
stackexchange-wordpress
|
{
"answer_score": 1,
"question_score": 1,
"tags": "redirect, apache"
}
|
Plugins Page - "Page disabled by the administrator"
I've encountered an issue on a site I'm looking after.
The 'admin' account no longer has access to the plugins page, if I try and manually type in the URL to the page, I get the following error:
"Page disabled by the administrator"
Any idea what could be causing that?
Thanks!
|
I've actually just fixed it myself.
The problem was as follows:
I had changed the username of the admin account to 'new-admin'. What I had missed when making this change was to update the 'wp_sitemeta' table in the database. meta_id 8 (site_admins) still had the old admin name set. Once I updated this, the plugins menu reappeared!
|
stackexchange-wordpress
|
{
"answer_score": 0,
"question_score": -1,
"tags": "permissions"
}
|
Limit number of posts on a custom category template - breaking pagination
The following code was mentioned from one of the commentors, however it is breaking the pagination. Any corrections please
<?php
include(TEMPLATEPATH. '/includes/headline.php'); rewind_posts();
if (have_posts())
{
echo '<div class="gridrow clear">';
while (have_posts()) : the_post();
global $post;
$query_string;
query_posts( $query_string .'&posts_per_page=5' );
include(TEMPLATEPATH. '/includes/loop.php');
$q = $wp_query->current_post;
$maxq = tj_current_postnum();
if($q < $maxq-1 && is_int(($q+1)/2)) echo '</div><div class="gridrow clear">';
$postcount++;
endwhile;
echo '</div> <!--end .gridrow-->';
} else {
include(TEMPLATEPATH. '/includes/not-found.php');
}
if ( $wp_query->max_num_pages > 1 ) tj_pagenavi();?>
|
You need to tell Wordpress to get only 5 posts per page. The parameter to do this is posts_per_page. You should use query_posts() function before your have posts as in the following example.
<?php
// your includes and stuff
global $query_string;
query_posts( $query_string . '&posts_per_page=5' );
// now your have_posts
if ( have_posts() ) {
// list the posts
} else {
// not found msg here..
}
?>
|
stackexchange-wordpress
|
{
"answer_score": 2,
"question_score": 0,
"tags": "categories, templates"
}
|
How to let contributors to create a new revision(draft) editing their published posts
I'm using a custom post type to let contributors have a personal page on the site.
Any time a user registers on my site a script creates a custom type post that has the registering user as the author.
To moderate users' entries this post is published by an editor.
I would like users (contributors) to be:
* unable to add other posts of this custom type;
* able to edit the already published post they are the author of;
* and their changes must be approved by an editor before being published.
I'm using User Role Editor to manage roles and capabilities.
Is there a way to do that?
|
Using Role editor or role scope you can set contributors to edit you custom post type but not publish so every change will be set as draft until approval, and to limit the creation of new posts of your custom post type you can use my plugin **Bainternet Posts Creation Limits**
## Update
To force re approval of edits add this code
add_filter( 'wp_insert_post_data', 're_aprove', '99', 2 );
function re_aprove( $data, $postarr ) {
//check if current user is not admin
if ( ! current_user_can( 'manage_options' ) && 'YOUR_CUSTOM_TYPE' === $postarr['post_type'] ) {
if ( 'publish' === $data['post_status'] ) {
$data['post_status'] = 'pending';
}
}
return $data;
}
and change `YOUR_CUSTOM_TYPE` to your custom post type name.
|
stackexchange-wordpress
|
{
"answer_score": 6,
"question_score": 6,
"tags": "users, author, user roles, capabilities"
}
|
Multiple Meta Boxes in separate files
So here's the problem, I want to have a few different meta boxes on my sites, but I'd like to be able to store each of them in separate files and included them into functions, so I can just copy specific ones to new installs and included them on a case by case basis.
From what I can gather though, it seems like I need to put them all into one array?
|
Save each meta box out to a file with the code as if they were in your functions.php file. Maybe place these in a folder called meta_boxes. Then to include into your theme just `include()` them into your functions file
<?php
// all the code that your functions file contains
include("meta_boxes/meta1.php");
include("meta_boxes/meta2.php");
include("meta_boxes/meta3.php");
include("meta_boxes/meta4.php");
// As so on....
?>
|
stackexchange-wordpress
|
{
"answer_score": 1,
"question_score": 1,
"tags": "metabox"
}
|
Custom Post Type Templates from Plugin Folder?
I'd like to offer my custom post type as a Plugin, so that people can use it without touching their theme folder. But custom post type templates -- such as single-movies.php -- reside in the theme folder. Is there a way to get WP to check for a single-movies.php in the plugin's folder? Hooking a function into the Filer Hierarchy? Or get_template_directory(); ?
|
You can use `single_template` filter hook.
/* Filter the single_template with our custom function*/
add_filter('single_template', 'my_custom_template');
function my_custom_template($single) {
global $post;
/* Checks for single template by post type */
if ( $post->post_type == 'POST TYPE NAME' ) {
if ( file_exists( PLUGIN_PATH . '/Custom_File.php' ) ) {
return PLUGIN_PATH . '/Custom_File.php';
}
}
return $single;
}
|
stackexchange-wordpress
|
{
"answer_score": 115,
"question_score": 76,
"tags": "plugins, custom post types, themes, directory"
}
|
WP-navi plugin and post sorted alphabetically
I've got an issue with using the WP-Navi plugin and posts sorted alphabetically. The first page of posts (5 - set in the plugin settings) appearing properly, but when one navigates to subsequent pages, I lose that sort. In fact, I can't tell how the posts are being sorted - it appears to be random.
The plugin's author has a description of this problem, but says that it's fixed in the plugin version that I have and I can't figure out where in the plugin code to verify. Should I abandon the plugin and try to code into the template or functions file?
Can anyone help?
|
Switching to a new navigation plugin solved this problem!
`
|
stackexchange-wordpress
|
{
"answer_score": 0,
"question_score": 0,
"tags": "pages, navigation"
}
|
wp_link_page - wrap current page element
I'm trying to make something more meaningful out of the `wp_link_pages()` result:
$paged_page_nav = wp_link_pages( array( 'echo' => false ) );
// Now let's wrap the nav inside <li>-elements
$paged_page_nav = str_replace( '<a', '<li class="'.$classes.'"><a', $paged_page_nav );
$paged_page_nav = str_replace( '/a>', '/a></li>', $paged_page_nav );
// here I'd need to wrap the currently displayed page element
echo '<ul>'.$pages_page_nav.'</ul>';
Currently my link pages (numbered nav/pagination) displays like this:
<!-- assuming we display page(d) 2/5 -->
<ul>
<li><a href="...">1</a></li>
2 <!-- This is the currently displayed paged, wrapped in nothing -->
<li><a href="...">3</a></li>
<li><a href="...">4</a></li>
<li><a href="...">5</a></li>
</ul>
|
I wouldn’t use WordPress’ internal function.
We had a very similar question recently: How to style current page number (wp_link_pages)? I wrote a small but flexible function to replace `wp_link_pages()`. It is probably easier to extend this than hacking around the return value of the native function.
|
stackexchange-wordpress
|
{
"answer_score": 3,
"question_score": 1,
"tags": "pagination, pages, wp link pages"
}
|
Looking for plugins that notify users of comment replies
Is there a plugin that will notify users of comment replies? I don't want a email notification but something on the sidebar where a user can click and see what posts have been replied to. Kind of like a subscription thing?
|
Recent Comments Widget shows recent comments(including author name and link to the blogpost). You can add it to the sidebar as well.
|
stackexchange-wordpress
|
{
"answer_score": 0,
"question_score": -1,
"tags": "notifications"
}
|
How to display a link in the footer section
i'm using the BAAP Mobile version plugin and the footer link that switches between desktop and mobile version is being displayed outside of the wrapper>footer divs. Is there a hook or a method to have the switcher link display in the footer section?
This is the function that creates and displays the links in the wpmp_switcher.php file.
function wpmp_switcher_wp_footer($force=false) {
if(!$force && (get_option('wpmp_switcher_mode')=='none' || get_option('wpmp_switcher_footer_links')!='true')) {
return;
}
switch (wpmp_switcher_outcome()) {
case WPMP_SWITCHER_MOBILE_PAGE:
print wpmp_switcher_link('desktop', __('Switch 2 our desktop site', 'wpmp'));
break;
case WPMP_SWITCHER_DESKTOP_PAGE:
print "<p>" . wpmp_switcher_link('mobile', __('Switch to our mobile site', 'wpmp')) . "</p>";
break;
}
}
|
If you look in the plugin's directory `plugins/wpmp_switcher/wpmp_switcher.php` on line 53 you will see this:
add_action('wp_footer', 'wpmp_switcher_wp_footer');
so you can either remove this action and call it in your theme your self with:
remove_action('wp_footer', 'wpmp_switcher_wp_footer');
or you just make sure that `wp_footer();` is inside your wrapper>footer divs.
|
stackexchange-wordpress
|
{
"answer_score": 0,
"question_score": 0,
"tags": "plugins, hooks, footer"
}
|
Does codex.wordpress.org use a plugin of some sort? If so what plugin?
I'm attempting to set up a wiki within a Wordpress install and love the way codex.wordpress.org is set up. Are they using a specific plugin to accomplish that or just well structured pages? Is there a similar plugin available to users?
|
Hi in the wordpress.org header is this:
<meta name="generator" content="MediaWiki 1.15.5" />
which leads me to think that it is this that is used
**MediaWiki**
regards Martin
edit: something similar was aked before and it looks like a plugin solution was found **Plugin Similar To MediaWiki** by Bainternet
|
stackexchange-wordpress
|
{
"answer_score": 3,
"question_score": 1,
"tags": "plugins, wiki, codex"
}
|
Set a background color per image added to a post
When using a modal window such as lightbox or shadowbox to display a post's images, client would like to be able to choose the background color that would be used for the modal window according to the image to be shown: color would be either black, white or grey.
I'm thinking such hack should be done via a plugin but i didn't find any, so i guess i should do it myself. It scarces me a bit: where should i store the chosen value? What hooks ? Any help would be welcome.
|
You can store the chosen color in a meta field. We have a question about adding a custom field to attachments, it contains an example. The hooks you need are `attachment_fields_to_edit` and `attachment_fields_to_save`.
|
stackexchange-wordpress
|
{
"answer_score": 2,
"question_score": 1,
"tags": "images"
}
|
Show Custom Taxonomy Slug(s)?
can anyone help me with this?
I need to print the slug of my custom taxonomy, can this be done?
The following kind of works but it just shows the name, rather than the slug which i need for a class purpose..
<?php $terms = get_the_terms( $post->ID , 'area' ); foreach( $terms as $term ) {print $term->name; unset($term);}?>
Any way of just getting the slug for my custom taxonomy 'area' ??
Many thanks for any help :)
|
$term->slug
Here is an example return of $term:
stdClass Object (
[term_id] => 31
[name] => Architectural Items / Salvage
[slug] => architectural-items-salvage
[term_group] => 0
[term_taxonomy_id] => 31
[taxonomy] => dcategory
[description] =>
[parent] => 5
[count] => 10
[object_id] => 197
)
If you don't know what's in `$term` or any other variable then print_r() and var_dump() are your friend.
|
stackexchange-wordpress
|
{
"answer_score": 1,
"question_score": 2,
"tags": "customization, taxonomy"
}
|
How to modify the HTML formatting of an oEmbed link?
I am trying to add oEmbed DeviantArt integration to a custom theme.
I found that first step is quite easy, I added
wp_oembed_add_provider( ' ' );
to theme's _functions.php_.
Now, I would like to change the default HTML output to add more information, available in DeviantArt JSON response (DeviantART reference), like author_name, author_url, etc.
If I have studied well the WP code that manage the output is inside function _data2html_ in _class-oembed.php_ , but I don't like change the code here.
How can I add a function to my theme, to achieve the desired result?
|
`WP_oEmbed::data2html()` has a filter, `oembed_dataparse`. You can use this to change the output, based on the extra data which is passed as the second parameter.
Something like this for example:
add_filter( 'oembed_dataparse', 'wpse17461_oembed_dataparse', 10, 3 );
function wpse17461_oembed_dataparse( $html, $data, $url )
{
if ( FALSE !== strpos( $url, 'deviantart.com' ) ) {
return $html . '<br/>Author: ' . $data->author_name;
}
return $html;
}
|
stackexchange-wordpress
|
{
"answer_score": 4,
"question_score": 1,
"tags": "oembed"
}
|
How to internationalize header image?
I have in the following code in the template:
<img src="<?php header_image(); ?>" />
However, I want to change this image according to the language selected (through GET parameter lang).
The question is, how to change this function to look for different images according to the received GET parameter?
I thought of:
1. Change this code on header.php to a fixed image path, so I could put an if and choose between the images I want.
2. Replace the result of the function get_header_image() and use it instead on header.php according to the received parameter, sort of replacing the string suffix .png to _en.png or .png to _es.png.
3. Change the header_image() function to behave the way I want.
All these ways look ugly to me. Are there better ways?
|
Filter the `get_theme_mod()` function (`wp-includes/theme.php`):
add_filter( 'theme_mod_header_image', 'localized_header' );
function localized_header( $img )
{
// Do something awesome with the $img path.
return $img;
}
|
stackexchange-wordpress
|
{
"answer_score": 1,
"question_score": 0,
"tags": "php, images, filters, headers, get theme mod"
}
|
Change custom post type GUID in RSS
So i got the RSS feed which output some custom post types, but the GUID looks bad to me, it's like:
?post_type=mycustompost&p=124
The reason i want to change this is that I don't need people to know it's Wordpress or to see my custom post type name (this is very important in this project)
Is there a filter or hook to rewrite this?
Thanks
|
The feed template files call `the_guid()`, which calls `get_the_guid()`, which has a filter named (surprisingly) `get_the_guid`. You can hook into this filter to change the output. The filter only gets the current GUID, not the post ID, so look this up in the global variable if you need it.
add_filter( 'get_the_guid', 'wpse17463_get_the_guid' );
function wpse17463_get_the_guid( $guid )
{
return ' . sha1( $guid );
}
See also this Trac ticket which proposes to change the current GUID format to a more unique hash.
|
stackexchange-wordpress
|
{
"answer_score": 2,
"question_score": 0,
"tags": "filters, urls, hooks, rss, guids"
}
|
Include widget within newsletter template?
I'm using the Newsletter plugin ( to compose e-mail newsletters. Using the "auto-compose" feature to pull website data via the theme included with the plugin, which I have begun to customise.
It's pulling posts just fine, which is a good start - but I would also like to pull some data that a custom widget on our site is displaying. I'm fairly new to Wordpress and the custom widget in question was not developed by me. Can I include a specific widget via my theme template?
Thanks
|
You may already know this, but you need to specify the widget's class name as the $widget_name variable in the template tag. For example,
Depending on the widget, you may also need to add parameters to the_widget() to get it to display properly — see notes on thewidget() $instance and $args in the codex. <
Alternatively, you can use a plugin like Widgets on Pages, which will let you include a widget anywhere using by using a shortcode like this: [widgets_on_pages id=WidgetName] <
|
stackexchange-wordpress
|
{
"answer_score": 0,
"question_score": 0,
"tags": "widgets, newsletter"
}
|
excerpt - don't use main content if empty
trying to stop get_the_excerpt() from defaulting to the_content() if its empty.
this kinda works - well it seems to return 'xxx' so i think has_excerpt() isn't working?
function get_link_excerpt(){
if(has_excerpt()){
$LinkExcerpt = get_the_excerpt();
return $LinkExcerpt."...";
}
return 'no excerpt';
}
add_filter('get_the_excerpt', 'get_link_excerpt');
what's the best way to control this?
best,Dc
|
WordPress sets up a default filter for `get_the_excerpt`: `wp_trim_excerpt()`. It is this function that will generate an excerpt from the content "if needed". If you don't want this behavior, you can just unhook the filter:
add_action( 'init', 'wpse17478_init' );
function wpse17478_init()
{
remove_filter( 'get_the_excerpt', 'wp_trim_excerpt' );
}
Now `get_the_excerpt()` will just return the contents of the `post_excerpt` database field. If you want to return something when it is empty, you only need to check this case:
add_filter( 'get_the_excerpt', 'wpse17478_get_the_excerpt' );
function wpse17478_get_the_excerpt( $excerpt )
{
if ( '' == $excerpt ) {
return 'No excerpt!';
}
return $excerpt;
}
There is no need to call `get_the_excerpt()` \- it could even introduce an endless recursion because it applies your filter again!
|
stackexchange-wordpress
|
{
"answer_score": 3,
"question_score": 1,
"tags": "excerpt"
}
|
modify wordpress default search
I would like to modify WordPress default search.
I have 2 questions: which template file to modify, and how can I include posts ids that I want to include in search?
I need to search from specific post ids, so I want to modify search in this particular way.
|
The output of search results is controlled by `search.php` template (or generic `index.php` if it's not present).
And search is technically a usual WordPress loop with `s` query argument, so any snippets that apply to loops can be used to tweak search.
|
stackexchange-wordpress
|
{
"answer_score": 1,
"question_score": 1,
"tags": "plugin development, search"
}
|
Post thumbnails not working in my new install of WP 3.1 with Twenty Ten theme
I am working in a new project, and I just realized that in the page/post edit pages, I don´t have the option to set a featured image/ post thumbnail.
I have checked and Twenty Ten has thumbnails support by default ( add_theme_support( 'post-thumbnails' is in functions.php). I also tried setting the thumbnails size with set_post_thumbnail_size, but no luck.
Any ideas?
P.D: I installed this in a new server, is it possible that it has something to do with that? Are there any specific requirements to use post thumbnails?
|
The featured image meta box is enabled under following conditions:
if ( current_theme_supports( 'post-thumbnails', $post_type ) && post_type_supports( $post_type, 'thumbnail' )
&& ( ! is_multisite() || ( ( $mu_media_buttons = get_site_option( 'mu_media_buttons', array() ) ) && ! empty( $mu_media_buttons['image'] ) ) ) )
add_meta_box('postimagediv', __('Featured Image'), 'post_thumbnail_meta_box', $post_type, 'side', 'low');
So check that:
* nothing messes up theme's declaration of thumbnails support;
* you are not using CPT with thumbnails support undeclared;
* whatever that multisite-related stuff means, if you are using multisite (I do and I don't remember having to do anything specific for featured images).
|
stackexchange-wordpress
|
{
"answer_score": 0,
"question_score": 1,
"tags": "customization, post thumbnails, theme twenty ten, troubleshooting"
}
|
Author page doesn't change after username change
I changed my user profile name with WP-Optimize from 'admin' to 'indie' (not really 'indie', just to show you better) but author page still is available only trough example.com/author/admin - not example.com/author/indie. Is there anything I missed?
Greetings, .wired
|
take a look at **Change the Author Slug from Username to Nickname** more specifically at Jan's answer.
|
stackexchange-wordpress
|
{
"answer_score": 3,
"question_score": 1,
"tags": "author, permalinks"
}
|
Featured image with the same height thumbs returns wrong thumb
I have 2 sizes thumbs for featured images with the same height:
* 300 x 200
* 540 x 200
I've checked the uploads folder and both thumbs with different sizes appear correctly:
* file_name-300x200.jpg
* file_name-540x200.jpg
I'm trying to get the bigger thumb size (540x200) as following:
$width = 540;
$height = 200;
echo get_the_post_thumbnail( $post->ID, array($width,$height) );
However, the image markup that is returned is for the smaller thumb zise (300x200). Interestingly, the class is displayed with the correct domantions as 'attachment-540x200':
<img width="300" height="200" src=" class="attachment-540x200 wp-post-image" alt="file_name" title="file_name" />
Would really appreciate if anyone could explain what's happening and why the correct size thumb isn't returned.
Many thanks, Dasha
|
I think you've hit interesting logic issue in `image_get_intermediate_size()`. This function loops through available images and tries to find best possible match for custom dimensions you provided.
First it attempts to find image as per comment in code:
// already cropped to width or height; so use this size
See the issue? Not image, perfectly matching dimensions, but image that matches in width or height, with remaining dimension being smaller or equal than required to fit in dimensions.
So your 300×200 image has equal height and fits inside 540×200 dimension you want (and probably comes earlier in meta data) so WP happily grabs it to use.
> Interestingly, the class is displayed with the correct...
No mystery there, class is simply generated from your input, without regard if values make sense and/or available.
|
stackexchange-wordpress
|
{
"answer_score": 2,
"question_score": 4,
"tags": "post thumbnails, images"
}
|
In need of array of post tags
On the single-post page within the loop I need an array of the_tags() which is a string. and get_tags() gives me all of the tags not only this posts. Is there an easy way to get this?
|
the function `get_the_tags()` does for a single post, what `get_tags()` does for the site.
|
stackexchange-wordpress
|
{
"answer_score": 4,
"question_score": 1,
"tags": "tags, single"
}
|
Whats wrong with my wp gallery?
i was making a gallery on my clients site using `[gallery]` sortcode. The gallery appears but when clicked it goes to clients other website which i have no idea why?
here is the link < check the wired link of the pictures.
The wordpress version is 3.1.1. Please let me know what is your advice. Thanks!
|
look at your javascript in the header for the thumb info:
script>
var thumbfile = "
also repeated on line 179 when viewing source
|
stackexchange-wordpress
|
{
"answer_score": 1,
"question_score": 0,
"tags": "media, gallery, uploads"
}
|
Mass Import Users without sending new user notification
I need to import users via csv file. I see lots of plugins that do mass imports, but they all seem to send out new user emails to the new users. Since this is currently being set up on a dev site, I don't want to send out the new user emails.
Are there any plugins that import users without sending out new user notifications
|
The CSV User Import looks promising...looking through the plugin file, I don't see anything regarding registration emails.
|
stackexchange-wordpress
|
{
"answer_score": 0,
"question_score": 2,
"tags": "plugins, users"
}
|
Looks like image resize is not working well
Im searching for some clue about this behavior? I think it is a PHP memory_limit or WP define('WP_MEMORY_LIMIT', 'X') issue?
Sometimes images are resized and sometimes not, in other scenarios the browser crash:
1. Im using Dreamhost as shared hosting, and their 7 upload limit.
2. Error printed with an uploaded image of 6.4MB of size and with a width and height of: 11684x3855: Fatal error: Allowed memory size of 268435456 bytes exhausted (tried to allocate 46736 bytes) in /PATH/wp-includes/media.php on line 254
3. Other users reports the same issue with files, for example, of 3MB but with higher width and height (superior to 2000px or 3000px).
Any help is welcome.
Thanks in advance.
|
I've had the same issue in the past when uploading very large images. When it comes to crunching the image it fails and shows HTTP ERROR in red. However other images continue to load. It wasnt file size where it would fail but rather the pixel width and height of the images.
By default PHP settings, the most GD libary can handle per image is 1,000,000 pixels which is 1024px*1024px
Did you know: 8,000 pixels times 8,000 pixels times four bytes for truecolor equals a walloping 256 megabytes. Now I know no shared hosting webhost that allows you a PHP memory limit of 256MB
The only solution I was able to find, of which I'm offering to you, is to reduce the size of the images beging uploaded. Alternativly convince your webhost to up PHP memory limit, which is unlikely.
|
stackexchange-wordpress
|
{
"answer_score": 6,
"question_score": 1,
"tags": "uploads"
}
|
How can I split long posts into pages?
I want to make one long post, but have it paginate. I read that you could add this: `<!--nextpage-->`, but all it did was hide the content under the tag. Is there a plugin that helps do this? Is it possible that my theme may not allow this?
|
Your theme must have support for the `<!--nextpage-->` tag.
You will need to add `<?php wp_link_pages(); ?>` in your post loop.
<
|
stackexchange-wordpress
|
{
"answer_score": 3,
"question_score": 1,
"tags": "pages"
}
|
Limiting posts_join, where, etc to a specific WP_Query object?
I hope this makes any type of sense. I want to be able to add clauses to a specific query object without effecting the main loop on a page, for example for content in a side bar or footer. Is it possible?
|
The most reliable way is to define your own query var and then check it:
$my_query = new WP_Query( array(
...
'context' => 'my_query'
) );
Then, from your callback:
function alter_post_clauses( $clauses, $wp_query ) {
if ( 'my_query' == $wp_query->get( 'context' ) ) {
// do stuff
}
return $clauses;
}
add_filter( 'posts_clauses', 'alter_post_clauses', 10, 2 );
|
stackexchange-wordpress
|
{
"answer_score": 4,
"question_score": 0,
"tags": "custom post types, wp query"
}
|
Display one post based on ID from $_GET
I am using products as a 'custom post type' then I'm displaying a gallery of all products on the home page with a buy button next to each one. When the buy button is clicked, I would like it to redirect to a page with some more info of that product and a checkout form. What do I need to send to the URL using the button to retrieve this type of page? Should I just write my own query or is there something in wordpress that can do this for me?
This is my form right now:
<form class='product_form' action="checkout" method="get">
<input name="post_id" type="hidden" value="<?=$post->ID?>"/>
<input type='image' src='<?php bloginfo('template_url'); ?>/images/buy.png' class='wpsc_buy_button' />
</form>
|
If you want to reach the "single" page of a custom post type (or even a regular post), you can do this by going to ` If you use _Pretty permalinks_ WordPress will redirect you to the "canonical" link, which may look like `
So by changing the `target` of your form and the `post_id` hidden input to `p` it should work:
<form class='product_form' action="checkout" method="get" target="<?php home_url(); ?>">
<input name="p" type="hidden" value="<?=$post->ID?>"/>
<input type='image' src='<?php bloginfo('template_url'); ?>/images/buy.png' class='wpsc_buy_button' />
</form>
|
stackexchange-wordpress
|
{
"answer_score": 0,
"question_score": 0,
"tags": "custom post types"
}
|
Change the avatar ratio?
Is there any way to change the aspect ratio of the WordPress Avatars? Or is this hardcoded?
|
Possible sollutions:
* Use Css with something like `overflow: hidden;` and "cut out" what you need.
* Use the filter `apply_filters('get_avatar', $avatar, $id_or_email, $size, $default, $alt);` and override the output of `$avatar` completely.
* The function `get_avatar()` is pluggable. That means if you hook a plugin function early enough that already defines `get_avatar()` then this function will be used instead of the core function. See Core (link).
|
stackexchange-wordpress
|
{
"answer_score": 1,
"question_score": 0,
"tags": "images, avatar"
}
|
Highlight nav menu terms
OK so i have `custom post types` and `custom taxonomies`. I have a sub-menu that is made of the custom taxonomies.
### Example:
**registered taxonomy:** _Movies_
and
**terms:** _action_ , _adventures_ , _etc_. (= menu items)
### Problem:
Now **I need to add a _highlight_ -class** to the terms when the currently displayed page is an archive of one of the terms.
I am almost looking to use my nav menu as a breadcrumb so to speak.
|
Ok. So instead of pasting the code here ill just link to it since i do not feel like adding the code format to each line. This is most likely just temporary but will get what i need done. It is used with some of jquery scripting but should not need it. Feel free to edit as you wish and update this question with your re-writes <
|
stackexchange-wordpress
|
{
"answer_score": 0,
"question_score": 3,
"tags": "custom post types, custom taxonomy, navigation, filters"
}
|
If I change permalink structures, can I use htaccess to permanantly redirect links?
Ive got some super old links that have a lot of SEO juice and I dont want to lose that if I change permalink structure. This is partly due to the older version of WP i have (2.1)
I want to use post ids in the structure now, and not the slug name or maybe both
myblog.com/post/12121/slug-name
If i use htaccess for this will Google and other search engines update their links without penalizing me?
|
Yes you need 301 redirection and you will carry on your SEO juice to the new URLs.
|
stackexchange-wordpress
|
{
"answer_score": 2,
"question_score": 1,
"tags": "permalinks, redirect, htaccess, seo"
}
|
user contributed content as custom post types
We are looking into creating a solution that allows user to contribute media files by filling out a form (without access to the admin) and have it ןד created as a custom post type. The files will be either YouTube Movies, PowerPoint Files etc. Is that possible at all? Do you know any example of something similar?
|
Yes, this is pretty easy using something like Gravity Forms
|
stackexchange-wordpress
|
{
"answer_score": 2,
"question_score": 2,
"tags": "posts, customization"
}
|
What causes an Unexpected HTTP Error within install plugins?
Within "install plugins" I'm receiving an error stating "An Unexpected HTTP Error occurred during the API request." When I do a plugin search it throws me back to my site's 404 page. Any idea what would prevent my site from syncing properly with WordPress's servers?
!enter image description here
I added Hameedullah's code to functions.php and recevied this returned `object(WP_Error)#21 (2) { ["errors"]=> array(1) { ["http_request_failed"]=> array(1) { [0]=> string(75) "Could not resolve host: api.wordpress.org; No data record of requested type" } } ["error_data"]=> array(0) { } }`
Is this a curl transport issue?
|
You can use the following code to dump the HTTP Api response, will help you figure out the cause of error.
function dump_http_api_response($response, $type="", $transport=null ) {
if ( $type == "response" )
var_dump ( $response );
}
add_action('http_api_debug', 'dump_http_api_response', 1, 3);
Example Output:
object(WP_Error)#15 (2) { ["errors"]=> array(1) { ["http_request_failed"]=> array(1) { [0]=> string(41) "Couldn't resolve host 'api.wordpress.org'" } } ["error_data"]=> array(0) { } }
|
stackexchange-wordpress
|
{
"answer_score": 3,
"question_score": 1,
"tags": "plugins, 404 error, installation, search"
}
|
Create theme files for plugin
Basically I've made a plugin to create a new post type (event).
Now I want to create a `single-event.php` layout file.
I don't want to have to stick it in the theme folder, I want to put it into my plugin folder. How do I make wordpress know its there?
Thanks
|
Here is the code that will let you return your single-event.php if the post type is event:
function my_event_template($single_template) {
global $post;
if ($post->post_type == 'event') {
return dirname( __FILE__ ) . '/single-event.php';
return $single_template;
}
add_filter( "single_template", "my_event_template" ) ;
|
stackexchange-wordpress
|
{
"answer_score": 6,
"question_score": 6,
"tags": "plugins, themes"
}
|
Plugin similar to Taxonomy Drill-Down for custom fields?
Is there a plugin available that does for custom fields what Scribu's excellent Taxonomy Drill-Down (formerly called Query Multiple Taxonomies) does for taxonomies?
|
I used to have a plugin that did exactly this. It was called Custom Field Taxonomies. Then custom taxonomies happened:
<
That said:
<
Let me know if you would like to adopt it.
|
stackexchange-wordpress
|
{
"answer_score": 2,
"question_score": 2,
"tags": "custom field, plugin recommendation, query"
}
|
Custom post type archive with dynamic taxonomy filtering - is it possible
I have a custom post type archive template archive-my-posttype.php with pagination.
These post types have a custom taxonomy called theme.
I am displaying these themes(terms) in the sidebar as a checkbox list.
How can I filter the custom post type based on the selected themes/checkboxes?
Can this be accomplished by adding a query_var parameter (theme_filter) and somehow modifing wp_query with the pre_get_posts filter?
I am trying to let WP handle pagination rather than have to rewrite it myself.
Thanks
|
I believe that what you are describing is how WordPress works out of the box. You will just need to create custom links in your sidebar. Something like `example.com/?post_type=your-custom-post-type-slug&theme=taco` should query for "all custom posts about the theme named taco".
|
stackexchange-wordpress
|
{
"answer_score": 1,
"question_score": 0,
"tags": "custom post types, custom taxonomy"
}
|
Use template tags in code snippets wordpress
I'm trying to use WordPress template tags (through shortcodes) to merge the post title and url into hyperlink html code. Which looks like this:
<a href="[Permalink]">[Post Title]</a>.
Problem is the text output uses curly quotes around the "Permalink" that are not compatible with html code. I tried placing hyperlink code using template tags (shortcodes) into a code snippet box, however then the shortcodes won't run.
I would like to merge the template tags (through shortcodes) into the hyperlink html code first, then have it show up in a code snippet box. Any ideas on how to do that?
|
Just tested this and it worked on my end. The shortcode itself would be [titlelink]
function titlelink_ssc($content = null) {
ob_start();
echo '<a href="'.get_permalink().'" title="'.get_the_title().'">'.get_the_title().'</a>';
$titlelink_ssc = ob_get_clean();
return $titlelink_ssc;
}
add_shortcode("titlelink", "titlelink_ssc");
|
stackexchange-wordpress
|
{
"answer_score": 0,
"question_score": 0,
"tags": "template tags"
}
|
Duplicate attribute class causing site validation error
The following bit of code results in a duplicate attribute site validation error.
This template script:
<div class="clearfix" <?php post_class() ?>>
produces this source output:
<div class="clearfix" class="post-263 post type-post status-publish format-st…
WordPress adds its own post-related classes to format the blog entry. Is there any way I can add my "clearfix" class to the template without producing the duplicate attributes?
Thanks.
|
Simple fix:
<div <?php post_class("clearfix"); ?>>
See post_class() for more details
|
stackexchange-wordpress
|
{
"answer_score": 6,
"question_score": 1,
"tags": "css, validation, post class"
}
|
Single dash converted to double dash
As the title says, if a single dash is used with a space between each side eg. 'Die Hard - Action Film' is written in to a WordPress post, once published it comes out as 'Die Hard -- Action Film'. If no spaces are used around the dash it works, but obviously this isn't desired.
I've obviously found out it's not something that happens with a default install of Wordpress but I can't seem to pinpoint what the cause is in my theme.
|
It's lines 396 - 398 in the smart youtube plugin's `smartyoutube.class.php` file:
function check($the_content, $side = 0)
{
if (strpos($the_content, "httpv") !== false )
{
$char_codes = array('×', '–'); // <-- 8211 is an en dash
$replacements = array("x", "--"); // <-- here's where it's swapping in --
$the_content = str_replace($char_codes, $replacements, $the_content); // <--
|
stackexchange-wordpress
|
{
"answer_score": 0,
"question_score": 0,
"tags": "plugins, functions, content"
}
|
Single Domain/Multiple Domain installation restrictions allowed for plugins?
From what I have read, I have come to understand that all WordPress plugins,(including premium ones) should be GPL licensed. If this is the case, can the installation be limited to a single domain? As far as I understand, GPL allows you to reuse the code. Doesn't it? I'm asking this because I have seen some premium plugins have single site/multi site licenses. Please correct me if this question is wrong.
|
GPL prohibits restricting the code in any way. You can restrict the support or non GPL parts of the plugin (images/css) to a single domain but you can't restrict the GPL code to a single domain.
Q&A: WORDPRESS & GPL
MATT MULLENWEG's response to the same question:
!enter image description here
|
stackexchange-wordpress
|
{
"answer_score": 1,
"question_score": 0,
"tags": "plugins, licensing"
}
|
How do I set a custom base URL for standard posts?
Currently, permalinks are set to /%postname%/.
I'd like to prefix "blog" before all standard posts.
I'm using several custom post types, each with their own rewrite rules in the setup.
How can I setup a custom prefix for my standard WordPress posts?
|
did you try defining your perm structure like: /blog/%postname%/
If each one of your custom post types has its own slug defined, this should work like you are asking.
|
stackexchange-wordpress
|
{
"answer_score": 7,
"question_score": 8,
"tags": "permalinks"
}
|
Display most recent posts in category with Twenty Ten theme widget
I am fairly new to WordPress, and I would like to have a list of the most recent posts in a certain category appear in a right-hand panel (I can do this with all posts, but not specific categories)
I am using the Twenty Ten theme, on wordpress.com. I have found the following code, but unsure if or where this can be added:
<ul>
<?php $recent = new WP_Query("cat=10&showposts=5"); while($recent->have_posts()) : $recent->the_post();?>
<li><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></li>
<?php endwhile; ?>
</ul>
|
The fastest way, a plugin:
<
|
stackexchange-wordpress
|
{
"answer_score": 1,
"question_score": 0,
"tags": "posts, categories, sidebar, theme twenty ten"
}
|
Browser loading content from Twitter in admin area?
I have noticed that when I am in my Dashboard and switching from main Dashboard to for example plugins, Twitter seems to be loading something.
As I am located in China where Twitter is blocked, it always takes forever for my browser to realise that Twitter cannot be loaded, and thus before the page(s) finish loading.
This screenshot is for going to the plugins page, but it happens everywhere in the Dashboard.
!Browser at plugin page loading something from platform.twitter.com
Is this normal? And can it be blocked/removed/undone?
|
problem not resolved, temporary solution is to add a host entry for the twitter host to point it to localhost as offered by @Dunhamzzz and explained further by @Roman and @Jan
|
stackexchange-wordpress
|
{
"answer_score": 0,
"question_score": 2,
"tags": "dashboard, twitter"
}
|
How to use WP default post list tables in a plugin?
I'm developping a plugin to manage a base of users and I'd like to show them in the same type of table used in other parts of the WP admin (post lists, user lists, etc.), I'd like to have the same look and the if possible the column sorting too.
|
You came to this in a bad time of changes. Tables in admin are being migrated from the old and scary ways to new shiny `List Tables API` using subclasses of `WP_List_Table`.
Problem is - while classes are already in and being using core code, they are currently not meant for being used otherwise. Proper API for theme/plugin usage is planned, but I think it didn't make it in 3.2 version, so 3.3 (at best).
Your options are:
1. Do custom table, reuse CSS styling from core. Long run - leave as is or recode when `List Table API` is implemented and finalized.
2. Extend appropriate `WP_List_Table` class with your own and use that. Long run - likely watch it explode at every following WP version from here until `List Table API` is implemented and finalized.
For simple things I'd prefer **1**. But for complex stuff **2** is pretty much only way to go, because custom table is very hard to get right when a lot of global variables and other joys of admin side are involved.
|
stackexchange-wordpress
|
{
"answer_score": 2,
"question_score": 1,
"tags": "plugin development, posts, users, sort, listing"
}
|
Creating directory in uploads - wp_mkdir_p() or WP_Filesystem?
I don't think I ever had practical need to create folders/files in WP before, but for a plugin I need cache (for resized images) folder in `wp-content/uploads`.
Which raises the question - do I really need to go through all the process with `Filesystem API` (including messily asking for FTP credentials when needed), or `wp_mkdir_p()` is good enough for this?
|
`wp-content/uploads/` should be writable for the server (otherwise it would be impossible to upload a file, no?). If you are going to create something under this directory, it is safe to use `wp_mkdir_p()`.
I would only use `WP_Filesystem` if there is a chance the server does not have permissions to write to the location, like in `wp-content/plugins/`, which does not have to be writable for the server (at least I think it doesn't have to be?).
Sidenote: The File Permissions page of the Codex also talks about a `wp-content/cache/` directory. Would this be a "more standard" location for cache files?
|
stackexchange-wordpress
|
{
"answer_score": 7,
"question_score": 10,
"tags": "filesystem, wp filesystem"
}
|
How to redirect a virtual page (e.g. /blog) to the home page?
I want my to reach my website's main page when entering an url like:
<
However, I can't seem to get it to work with a typical rewrite rule:
RewriteRule ^/blog$ /
I'm always taken to my site's 404 page.
Works fine if I specify a specific file (e.g. "/foo.html") instead of "/", but "/index.php" doesnt't work.
How can I make this work?
|
The redirect has to be a 301, not an internal request. Otherwise WordPress will search dor a page named **blog**.
And you don’t need mod_rewrite.
# Apache 1.3 needs a complete URL
RedirectMatch Permanent ^/blog$
# Apache 2.x needs just the path
RedirectMatch Permanent ^/blog$ /
|
stackexchange-wordpress
|
{
"answer_score": 0,
"question_score": 0,
"tags": "url rewriting, pages, htaccess, mod rewrite"
}
|
How to: Retrieve an attachment image from post and output it
If anyone can help me I would be gratefull!
* * *
I got a _gravity form_ with the post_type fields including the submit image when submited it displays the:
* title
* content
* image
* tags
**So my question is:**
When I go to single.php I posted a code: `get_related_author_posts();` which calls the authors last two posts in function.php.
_Please take a look at the code, that contains/illustrates the problem:<
* * *
I need a little help from my friends the wordpress gurus :)
Thank You all in advance. I'm still learning the more advanced functions but this is where I'm stuck:)
|
I would use `wp_get_attachment_image()` (Codex ref), which returns a fully-formed HTML IMG tag:
<?php
wp_get_attachment_image( $attachment_id, $size, $icon );
?>
I assume you already know how to get the attachment image ID?
The default image size is `thumbnail`, but you can pass any standard image size (e.g. `full`, `large`, `medium`), or any custom image size added via `add_image_size()`.
|
stackexchange-wordpress
|
{
"answer_score": 2,
"question_score": 0,
"tags": "attachments, author, forms"
}
|
Displaying Subpages while on Parent page?
I would like to create a navigation menu where I will be displaying two level pages.
To illustrate that:
* Parent 1
* Parent 2
* Parent 3 (current)
* Child 1
* Child 2
* Child 3
* Parent 4
So I would like to display all the parent pages in my navigation container but only display children pages when the user is currently on its parent page.
|
This is pretty easy, as WordPress sets css classes for the parent pages. Default we hide all sublists (ul) from the menu with
.menu ul {
display: none;
}
Then when the parent page is selected we use the css classes that are set by WordPress to show the sublists again.
.menu .current_page_ancestor, .menu .current_page_parent {
display: block;
}
So all you need is this in your template
Template:
<ul class="menu">
<?php wp_list_pages('title_li=') ?>
</ul>
and this in your css file.
CSS:
.menu ul {
display: none;
}
.menu .current_page_ancestor > ul, .menu .current_page_parent > ul {
display: block;
}
|
stackexchange-wordpress
|
{
"answer_score": 1,
"question_score": 1,
"tags": "pages, navigation"
}
|
URL rewrite rules for multiple taxonomies query
I'm trying to create some pretty URLs for links querying multiple taxonomies. I'm using the "Taxonomy drill-down" plugin, although the main usage is now integrated @ the core it still has some helpful function for templating :)
An example URL querying multiple taxonomies ( working ) would be: _domain.com/?tax1=foo &tax2=bar_
My goal is to have links like - _domain.com/tax1/foo/tax2/bar_ \- translating to the above example
tax1/2 = taxonomy name
foo/bar = required term
I stumbled upon Examples of WP Rewrites but i think i suck with those patterns and something like:
$newrules['tax1/(.*)/tax2/(.*)/'] = 'index.php?tax1=$matches[1]&tax2=$matches[2]';
doesn't seem to work ( that's just a portion of the whole function based on the Wordpress example )
Any ideas? :)
|
`(.*)` matches everything, so it will "eat up" the extra characters (it is "greedy"). If the URL is `/tax1/foo/tax2/bar/`, the first `(.*)` will be `foo/tax2/bar/`, so nothing is left for the second match.
Instead of `(.*)` you can use the "non-greedy" version `(.+?)`. This will match as much as possible, but still keep the rest in mind. You can also use the even stricter version `([^/]+)`: this will match everything up to the next `/` \- but this will not work for nested categories, so `/category/fruit/banana/tag/flies/` will not split up in `fruit/banana` and `flies` like you might expect.
If you are going to play with the rewrite rules I recommend you to install my Rewrite analyzer plugin. It allows you to see the current rewrite rules and play with URLs to see which rules will match.
|
stackexchange-wordpress
|
{
"answer_score": 5,
"question_score": 3,
"tags": "custom taxonomy, url rewriting"
}
|
Call dynamic_sidebar but include/exclude named widgets?
Is it possible to include or exclude specific named widgets that are assigned to a named dynamic_sidebar call?
For example, if I've registered a sidebar named "my_sidebar" and the user had placed a "Links" widget into it, I want to be able to include or exclude it based on a custom setting in my theme options panel.
Is this possible?
Any insights much appreciated.
|
`dynamic_sidebar()` calls `wp_get_sidebars_widgets()` to get all widgets per sidebar. I think filtering this output is the best way to remove a widget from an sidebar.
add_filter( 'sidebars_widgets', 'wpse17681_sidebars_widgets' );
function wpse17681_sidebars_widgets( $sidebars_widgets )
{
if ( is_page() /* Or whatever */ ) {
foreach ( $sidebars_widgets as $sidebar_id => &$widgets ) {
if ( 'my_sidebar' != $sidebar_id ) {
continue;
}
foreach ( $widgets as $idx => $widget_id ) {
// There might be a better way to check the widget name
if ( 0 === strncmp( $widget_id, 'links-', 6 ) ) {
unset( $widgets[$idx] );
}
}
}
}
return $sidebars_widgets;
}
|
stackexchange-wordpress
|
{
"answer_score": 7,
"question_score": 6,
"tags": "theme development, widgets"
}
|
How to show a admin bar menu item only to users with certain capabilities?
I'm trying to add items to the admin bar but only for users with certain capabilities, such as `add_movies` in a plugin. The problem is that, according to @toscho and @TheDeadMedic, the plugin executes its code too early in the order of operations to use `current_user_can`.
I tried using `if ($user->has_cap('add_movies'))` but get `Fatal error: Call to a member function has_cap() on a non-object in xxx.`
Am I missing an obvious global or is the solution more complicated?
|
The check will be called too early if you just write it in your plugin file like this:
if ( current_user_can( 'add_movies' ) ) {
add_action( 'admin_bar_menu', 'wpse17689_admin_bar_menu' );
}
function wpse17689_admin_bar_menu( &$wp_admin_bar )
{
$wp_admin_bar->add_menu( /* ... */ );
}
Because it will execute when your plugins is loaded, which is very early in the startup process.
What you should do is always add the action, but then in the callback for the action check for `current_user_can()`. If you can't do the action, just return without adding the menu item.
add_action( 'admin_bar_menu', 'wpse17689_admin_bar_menu' );
function wpse17689_admin_bar_menu( &$wp_admin_bar )
{
if ( ! current_user_can( 'add_movies' ) ) {
return;
}
$wp_admin_bar->add_menu( /* ... */ );
}
|
stackexchange-wordpress
|
{
"answer_score": 2,
"question_score": 1,
"tags": "capabilities, user roles, admin bar"
}
|
is_home() returns false on the home page! When is the home page NOT the home page?
I've placed the following code in my functions.php file
if(!is_home()){ echo "Not Home";}
if(is_home()){ echo "Home";}
However, no matter what page I'm on, I get "Not Home", And I'm real sure I'm on the home page, but still get "Not Home". What am I missing?
|
If you just place it in `functions.php`, not in a function in `functions.php`, it will be called too early. WordPress includes `functions.php` before it parses the URL and determines whether you are actually on the homepage or not.
Since WordPress 3.1 there is an extra warning (only visibile if you enable `WP_DEBUG`) if you call these too early, to prevent these confusing situations.
|
stackexchange-wordpress
|
{
"answer_score": 6,
"question_score": 4,
"tags": "theme development"
}
|
Add_settings_field() parameterizing callback?
I'm trying to create a rather large and extensive settings page with various options of very similar type.
Since there will be about 20 different fields, and the differences between most of those being simply their ID, I'd like to avoid creating a separate callback for each one.
Is it possible to make a callback with a variable for the settings ID of each of these fields? That way one callback can server various settings fields of the same type.
I've tried using the $args parameter for add_setitngs_feild(), but sadly, it does not work. For example:
add_settings_field('name', 'Field Name', array($this, 'fieldCallback'), 'SettingsGrouP', 'SettingsSection', array("settingID!"));
function fieldCallback($id)
{
echo "<input id='" . $id . "'/>";//etc, etc
}
fieldCallback si being called, but the ID of the input is blank.
|
The last optional `$args` argument the you can pass to `add_settings_fields()` is passed to callback. So it seems you can use same callback just fine.
Hope I am right because I just stumbled onto this two minutes ago because of discussion in chat. :)
PS looked through code and it's indeed relatively recent, before ~2.9 arguments weren't passed.
|
stackexchange-wordpress
|
{
"answer_score": 2,
"question_score": 4,
"tags": "options, callbacks"
}
|
Plugin search sorting for admin section - Wordpress
> **Possible Duplicate:**
> Sort plugins by rating
Just curious if anyone knows of a plugin or a way to add sorting for Plugin searches in the Administration of a Wordpress site. I find myself searching through all kinds of plugins, ultimately just wanting to see what has the best rating or highest number of downloads.
Kind of surprised Wordpress hasn't added this feature already. Anyone know of a fix?
|
Good question, I have noticed it and couldn't (at the time) find a plugin that fixed it.
My solution:
Open the Wordpress Plugin Directory page and search there - you get a lot more options. Copy the plugin title over to your site's plugin admin page and search there - then install from there. It's quicker than downloading from the Plugin Directory and reuploading, but you have to watch out because sometimes the plugin titles don't correspond to your search string (the plugin search is kind of odd that way).
|
stackexchange-wordpress
|
{
"answer_score": 0,
"question_score": 3,
"tags": "plugins"
}
|
How to reduce the number of pages in pagination
The code below is the function for pagination in my wordpress blog. Presently it outputs 7 pages and then the .. last page number.
How can I reduce this number so it shows only 5 pages and then ... last page number?
function emm_paginate_loop($start, $max, $page = 0) {
$output = "";
for ($i = $start; $i <= $max; $i++) {
$output .= ($page === intval($i))
? "<span class='emm-page emm-current'>$i</span>"
: "<a href='" . get_pagenum_link($i) . "' class='emm-page'>$i</a>";
}
return $output;
}
|
I believe you're using 2 custom functions one of them is emm_paginate_loop() you're showing. But i saw that settings for that custom pagination is on function emm_paginate() and specifically "gap":
> 'gap' - Default is 3 (int). The minimum number of pages before a gap is replaced with ellipses (...).
But that only sets a minimum number...
|
stackexchange-wordpress
|
{
"answer_score": 0,
"question_score": 0,
"tags": "pagination"
}
|
Delete the original big size image after upload and leave only 3 images crunched by media gallery
I need to know is it possible to somehow erase the original image uploaded via Gravity form : post image - post field?! With the situation now I receive 4 images. 1 original (can be whatever user has on his PC - up to 4 MB which clutters the server) and 3 which Wordpress creates according to specifications (thumbnail, medium, large). I would like to have the ability when user uploads the "original big image" to be deleted upon upload and be left with 3 remaining in media gallery?!. It will dramatically improve the storage on my server.
Cheers!
|
How about this:
add_filter( 'wp_generate_attachment_metadata', 'delete_fullsize_image' );
function delete_fullsize_image( $metadata )
{
$upload_dir = wp_upload_dir();
$full_image_path = trailingslashit( $upload_dir['basedir'] ) . $metadata['file'];
$deleted = unlink( $full_image_path );
return $metadata;
}
Not 100% sure everything will work ok without the main image, but it does the trick. You wont be able to regenerate the thumbnails / sizes as the main image is required for this.
Edit: I just re-read the question, I noticed you are wanting this to only happen when people upload via a form. Must be early for me, the above code will delete any attachment uploaded. I guess all you would need to do is find someway of checking if the upload was via your gravity form. Hope it helps you anyway.
|
stackexchange-wordpress
|
{
"answer_score": 6,
"question_score": 5,
"tags": "posts, images, plugin gravity forms"
}
|
How do I add media to a custom post type?
I want to add some custom fields to allow a user to select items from the Media library for the custom post (in the add/edit view)
Is there a way to do this?
|
My answer will be in the form of links.
The WPAlchemy meta box class supports this: < \+ tutorial <
A tutorial on how to do it, mainly javascript: <
|
stackexchange-wordpress
|
{
"answer_score": 3,
"question_score": 3,
"tags": "custom post types, custom field, media library"
}
|
How do I pull excerpts from pages?
So I enabled custom excerpts on my pages with this function.
add_action('init', 'page_excerpts');
function page_excerpts() {
add_post_type_support( 'page', 'excerpt' );
}
However, When I enter a data into the excerpt field I still have the content returning in the loop instead of my newly added excerpt.
<?php the_excerpt(); ?>
Do I need to do anything else to force the content to be pulled from the excerpt field on pages?
|
Perhaps try this:
<?php
global $more;
$more = false;
?>
<?php the_content('<span>Continue Reading</span>'); ?>
<?php $more = true; ?>
|
stackexchange-wordpress
|
{
"answer_score": 2,
"question_score": 0,
"tags": "functions, loop, the content, excerpt"
}
|
Add User meta fields, which only admin can edit
Is there a way to add custom user meta fields (like the one in the profile.php, which contains specific user data), but only an admin or an other user with enough capabilities can change them?
Maybe I'm thinking too complicated. How would you tell your site visitors, who from your users is having which position / status without manually updating a static page?
|
I think I get what you are saying, and if not, forgive me:
just add your meta fields / metabox inside:
if( current_user_can( 'administrator' ) ){ // put code here }
*this is assuming you aren't asking how to add a metafield or metabox.
|
stackexchange-wordpress
|
{
"answer_score": 3,
"question_score": 2,
"tags": "admin, users, profiles"
}
|
Custom Caption on WP Nivo Slider
I'm trying to set the Post Title or Post Content as the caption in my Nivo Slider. Any ideas on how to do this?
|
You need to set the "title" attribute of the images to be the post title. You can do it like this:
title=' . get_post_title() . '
You will have to modify the HTML output of the plugin, but it should not be very difficult at all.
|
stackexchange-wordpress
|
{
"answer_score": 1,
"question_score": 0,
"tags": "plugins, slideshow"
}
|
Override dynamic_sidebar() in plugin?
I'm writing a custom plugin that allows a particular page to have it's own sidebar with widgets. It works great so far, but what I'd like to do is generalize it more and allow the plugin to "override" the dynamic sidebar of any page (if it has a custom sidebar) without having to edit any template files.
I've tried several hooks and have delved into the code a bit, but nothing stands our or works so far.
To save some time I thought I'd see if anybody has any working solutions to this issue? I might be able to solve this issue, but it is straining my "after working hours" brain.
If it isn't possible I'd be more than willing to have a short-code or function call that does this for me, but I'd really like to make it idiot proof and just have it work without any template changes.
|
`dynamic_sidebar()` calls `wp_get_sidebars_widgets()` to get the list of all sidebars and their widgets. This output is filtered through `sidebars_widgets`, so you can modify it to add or remove widgets.
This array only contains widget IDs, so you need to register the widget instance too (it should end up in the global `$wp_registered_widgets` array). I think you can do this with `wp_register_sidebar_widget()`, but it is possible that this is older code from the time when a widget could not have multiple instances yet.
|
stackexchange-wordpress
|
{
"answer_score": 3,
"question_score": 3,
"tags": "plugins, widgets, sidebar"
}
|
How to insert image from link in TinyMCE
In the TinyMCE editor that comes with WordPress there is no button to insert image from link. I know that you can do this using the upload/insert section. But let us say that I don't want to allow users to upload images but want them to be able to insert images by linking them. If I remove the upload capabilities, the upload/insert section disappears altogether.
Is there already a method to do this on WordPress?
|
TinyMCE Advanced allows you to add several buttons including images.
|
stackexchange-wordpress
|
{
"answer_score": 0,
"question_score": 0,
"tags": "tinymce, images, buttons"
}
|
Wordpress get from single.php back to the right category page
in my **single.php** i have a link back to the category:
`$category_id = get_the_category(); $category_link = get_category_link( $category_id[0]->cat_ID );`
If i am now coming from **page 2** to the single, is there a way to go directly back to the second page?
* * *
Edit
is there a better way than using the js `history.back()` method?
|
You could try:
<?php
if ( ! empty ( $_SERVER['HTTP_REFERER'] ) )
{
?>
<a href="<?php echo esc_url( $_SERVER['HTTP_REFERER']; ) ?>">Go Back</a>
<?php
}
|
stackexchange-wordpress
|
{
"answer_score": 3,
"question_score": 0,
"tags": "categories"
}
|
How do I allow users to supply a photo/image to be used instead of the grey/white silhouette?
I am sure I am missing something very straightforward, but there seems to be no way for me to upload a photo for my profile or for a user profile the will be used in place of the placeholder white on grey silhouette that my theme displays.
I did Google for this, and I seem to get a bewildering array of possible plugins, but I would have thought that there was an easier way of doing this?
If I must install a plugin, what is the best one? (I realize that is a difficult question, but even getting it down to a shortlist would be nice!)
I am using Wordpress version 3.1.2 with the Twenty Ten theme version 1.2
I have the following plugins active:
Google Analytics for WordPress version 4.1 SyntaxHighlighter version 3.1.1
Thank you in advance.
|
These images are called _Avatars_. By default, WordPress works with the Gravatar service, which hosts your avatar on one central location so you don't have to upload it to every site you comment on. It is based on your e-mail address (you see it on action on this site too).
If you want to provide the functionality to load avatar images from your own site you will indeed need to load an extra plugin. Some popular plugins are:
* Add Local Avatar
* Simple Local Avatars
|
stackexchange-wordpress
|
{
"answer_score": 1,
"question_score": 0,
"tags": "plugins, posts"
}
|
Exclude User from Activity Stream in BuddyPress?
I'd like to exclude a specific user account from showing up in the activity stream. I found this code that's supposed to exclude the Admin. Any clue how to exclude a specific user? (this code goes in bp-custom.php)
<?php
add_action("plugins_loaded","bpdev_init_sm_mode");
function bpdev_init_sm_mode(){
if(is_site_admin())
remove_action("wp_head","bp_core_record_activity");//id SM is on, remove the record activity hook
}
?>
Thank you.
|
<?php
add_action("plugins_loaded","bpdev_init_sm_mode");
function bpdev_init_sm_mode(){
global $current_user;
if(is_user_logged_in()) {
get_currentuserinfo();
if("someusername" == $current_user->user_login) {
remove_action("wp_head","bp_core_record_activity");//id SM is on, remove the record activity hook
}
}
}
?>
|
stackexchange-wordpress
|
{
"answer_score": 2,
"question_score": 2,
"tags": "buddypress"
}
|
is_wp_error() and handling errors
Im trying to build a function which grabs the feedburner "readers" using `wp_remote_get()`. I noticed that it frequently returned a value of `0`.
I assumed at first that it was a WordPress error (handled by `is_wp_error()`) or a flaw with `wp_remote_get()`. Wrong of-course..
Feedburner just kept crashing, so I used a second transient to store a result (never `0`) with an expiration of 7 days. The part which i cant get my head around is handling errors with `is_wp_error()`. I need to force an error so i can handle it properly, before I put it up on production.
Heres an illustration:
$result = wp_remote_get( ' . urlencode($username) );
if ( is_wp_error($result) )
return false;
Whats the best way to force an error? Should i use `new WP_error()`?
|
WordPress can be inconsistent as to when is returns a `WP_Error` object and when it just returns `false` or `string(0)` when actually there was an error. I am not sure exactly what feedburner is returning that is not triggering a `WP_Error` from `wp_remote_get()` \- but if you know `wp_remote_get()` will return an WP_Error, I would just set `$result = new WP_Error( 'my-error' );` This is the same object that `wp_remote_get()` will return on error.
|
stackexchange-wordpress
|
{
"answer_score": 6,
"question_score": 2,
"tags": "errors, transient, customization"
}
|
Author website URL
I've assigned a specific html page (let's call it an author bio page) to each user in the 'website' field within the user admin area. How do I get that URL to display within a single page post? I'm assuming that I'm to use $curauth->user_url but it returns a blank page.
|
you need to assign `$curauth` and since you are not on an author archive but on a regular page you can use get_userdata function and pass the user ID like so:
$curauth = get_userdata(1);
//and then use
echo $curauth->user_url;
or if you are in the loop you can use `the_author_link();` which will Displays the author's Website URL as a link and the text for the link is the author's Profile Display name publicly as field.
|
stackexchange-wordpress
|
{
"answer_score": 2,
"question_score": 2,
"tags": "author"
}
|
Anyone know why wordpress converts some html entities to their numeric equivalents?
Does anyone know why wordpress converts some html entities to their numeric equivalents?
I've found that in some posts, where a non-breaking space ` ` entity would be appropriate, wordpress uses ` ` instead.
Seems to me that using the symbolic version of the entity would be better than a numeric version.
The routine that this is being done in (appears to be) ent2ncr in wp-includes/formatting.php.
When I converted my blog from a single site to multi-site (different install & database), the numeric entities were not converted properly (possibly due to a database difference). Had the symbolic entities been used, I doubt this would have been a problem.
|
In XHTML entities are not part of the DTD, and user agents are not required to support them. Exceptions: `&`, `<`, `>`, `"` and `'`.
To keep WordPress X(HT)ML compatible numeric references are used instead.
|
stackexchange-wordpress
|
{
"answer_score": 6,
"question_score": 0,
"tags": "posts, database, html"
}
|
How do you get thumbnails to show up in the admin edit post?
I tried to add thumbnail support to my theme
add_theme_support( 'post-thumbnails' );
set_post_thumbnail_size(133, 133, true);
add_theme_support( 'post-thumbnails', array( 'post' ) );
add_theme_support( 'post-thumbnails', array( 'page' ) );
So this isnt working, or at least I'm not sure how this should work, help!
|
This looks flawed:
add_theme_support( 'post-thumbnails', array( 'post' ) );
add_theme_support( 'post-thumbnails', array( 'page' ) );
Do you see the post thumbnail box on pages? If so, you have just overwritten the support on posts with the second declaration.
Better:
add_theme_support( 'post-thumbnails', array( 'post', 'page' ) );
|
stackexchange-wordpress
|
{
"answer_score": 2,
"question_score": 1,
"tags": "themes, admin, post thumbnails"
}
|
Display KML (or other "raw data" file) nicely in WP?
I want to display this file:
<
on wordpress.barrycarter.info, but all my attempts fail because of preprocessing:
<
(use "view source" to see what parts of the file WP "hides" from view).
|
Use a plugin like syntax highlighter evolved. <
Or wrap it in `<pre>` or `<code>` tags.
|
stackexchange-wordpress
|
{
"answer_score": 1,
"question_score": 0,
"tags": "formatting"
}
|
Change CSS/formatting on specific page, but not pages in general?
How do I change the formatting on < so that (for example) the map's nearly flush with the bottom of the menubar?
I don't want to edit page.php, since that'll change all pages, not just this one.
|
After creating the specific CSS you need to format the page how you like, you could:
1. Create a custom page template with the CSS and assign the template this page.
2. Create a page-{slug}.php file with the CSS, where {slug} is the page slug for this page (most likely the filename should be page-voronoi-temperature-map.php).
3. Create a page-{ID}.php file, where if the page ID is 6, WordPress will look to use page-6.php.
These three options were mentioned in the Codex, under Template Hierarchy. By using any of these 3 options, you can alter the layout for this page without affecting all the rest of your pages.
|
stackexchange-wordpress
|
{
"answer_score": 5,
"question_score": 11,
"tags": "formatting"
}
|
use child theme for mobile version
I have never used the child theme function. so I am curious if it is possible to use this function to create a mobile version or no? I know that there are mobile plugins for this but I was curious if can use a child there for this
|
I don't see why it wouldn't be possible. I use a switch plugin to display a totally different theme for mobile. A child theme is a totally different theme. The dependencies on the parent theme should still work, as they are WP functions built in.
Give it a try with a super simple child theme so you don't waste too much time. Just set up the style.css, use the import rule, but do something simple and drastic like changing a really obvious colour. See if it works.
|
stackexchange-wordpress
|
{
"answer_score": 1,
"question_score": 0,
"tags": "child theme"
}
|
How do you protect a premium theme from being copied?
I'm thinking of doing up a couple of premium themes, and selling copies of them. I've never done anything like this before, so I have a couple of questions.
I appreciate that this is mainly a forum for asking technical questions, so if anyone wants to point me in the direction of somewhere that might be more appropriate for these questions, please let me know.
My main question is about copies of a theme. If I sell a copy of a premium theme, and the end result is that a person gets a zip file of my theme, is there any technical way to limit them to only using it in one installation of WordPress? Or do I just rely on the goodness of their hearts?
Also, a related question: What kind of license, if any, should I include with a premium theme?
Thanks.
|
There is no way to prevent the free distribution of your theme. You could make it harder by selling a copy that is restricted to a license key and a salted hash of the domain. But even if you put the code for this in a pre-compiled script it will be possible to get around it.
Sell support, upgrades and reliability, not the naked code.
For the license: PHP code which is uses WordPress functions and hooks is GPL per default by some peoples interpretation.
For your stylesheets, images and standalone PHP code you can use a different license.
|
stackexchange-wordpress
|
{
"answer_score": 4,
"question_score": 2,
"tags": "theme development, themes, licensing, ziparchive"
}
|
Download PHP and CSS from the Wordpress admin page without FTP
Some of my clients don't have CPanel access to their WordPress, so I have to copy and paste from the built-in editor to pull out the PHP.
Is there a way within that admin interface to grab all the PHP files? I don't have FTP acces.. gr...
|
You should demand access to ftp or the command line, working without is is crippling and to be blunt, silly.
|
stackexchange-wordpress
|
{
"answer_score": 3,
"question_score": 0,
"tags": "ftp"
}
|
Adding a div class or id inside the_content()
I'm trying to create an advertisement block to be placed on a single post (single.php) such that the div class or id is left aligned and the post content wrapped around it. I checked the single.php and this is the only piece of code I notice is what displays the post.
<div class="entry entry-content">
<?php the_content(); ?>
<?php wp_link_pages( array( 'before' => '<div class="page-link">' . __( 'Pages:', 'themejunkie' ), 'after' => '</div>' ) ); ?>
I tried adding the code both above the 'entry-content' div and also after the_content, but with both methods it either displays the div either at the beginning or at the end of the post content.
Can someone tell me which files to look into in order to add this?
|
You have to put your advertisement block just before `<?php the_content(); ?>` in a separate div-layer and add some css to it. E.g.
## single.php
<div class="entry entry-content">
<div class="advertisement">
<p>Your advertisement</p>
</div>
<?php the_content(); ?>
</div>
## CSS
div.advertisement {
float: left;
width: 150px;
padding: 0px 10px 10px 0px;
}
|
stackexchange-wordpress
|
{
"answer_score": 2,
"question_score": 4,
"tags": "posts, the content"
}
|
How to create posts or pages with the names in wordpress?
When you develop a site on wordpress you may want to create posts/pages with the same name, something that wordpress does not allow by default.
Use cases:
example.com/en/contact
example.com/fr/contact
example.com/en/support/contact
I am currently using WPML plugin in order to create multilanguage sites and I encountered this limitation in wordpress.
How can I solve this problem? Do you know any tricks or plugins that would allow me to deal with this problem.
|
> When you develop a site on wordpress you may want to create posts/pages with the same name, something that wordpress does not allow by default.
This is statement is not true. WordPress will allow you to set up pages with the "directory" structure that you specified right out of the box. I was just able to do this on my test installation. I created a page with slug "en" and then created a child page named "taco". Next I created a page named "fr" and added a child to this page named "taco". Both taco pages have the slug of "taco". There may be an issue with the plugin that you are using. Have you tried this without the plugin installed?
|
stackexchange-wordpress
|
{
"answer_score": 1,
"question_score": 0,
"tags": "permalinks, multi language, slug, plugin wpml"
}
|
A plugin where users can comment with Facebook or Twitter or OpenID
Is there any plugin where users can comment with Facebook or Twitter or OpenID...
|
I use disqus on my site and it works quite well.
|
stackexchange-wordpress
|
{
"answer_score": 4,
"question_score": 5,
"tags": "comments, facebook, twitter, openid"
}
|
Favicon plugin for WordPress running in network mode (multisite)?
What favicon plugin should I use in order to define favicons for Wordpress when I run in multi-site mode.
Uploading favicon.ico files is not an option for multi-site wordpress instances.
I am looking for something simple that will not pollute the generated pages with hidden advertising.
**EDIT:** Looking to be able to define favicons on a per site basis. Different favicons for different sites.
|
Now I am successfully using All In One Favincon Plugin.
|
stackexchange-wordpress
|
{
"answer_score": 0,
"question_score": 3,
"tags": "multisite, network admin, favicon"
}
|
Is there any way to display the link of a Wordpress page without relying in its slug (or full path)?
Say I want to add this link: < Which is a Page with a template called **page user-login.php** :
<?php
/**
* Template Name: bbPress - User Login
*
* @package bbPress
* @subpackage Theme
*/
// No logged in users
bbp_logged_in_redirect();
// Begin Template
get_header(); ?>
I used to just paste the url of the site (using template_directory) plus the slug (/user-login). The problem is that I have to stick with he same slug (/user-login).
Is there any other alternative?
|
From what I understand, you want a URL to your page, that will work even if you change the page slug?
You can do this by linking to the **default permalink** for that particular page, for example <
This URL will always work even if your permalinks are updated. WordPress handles the redirects for you.
|
stackexchange-wordpress
|
{
"answer_score": 2,
"question_score": -1,
"tags": "links"
}
|
Expanding the allowed HTML tags in comments?
I have no problem doing this in a comment, as an administrator:
<b>bold test</b> <i>italics test</i>
<u>underline test</u> <font
color="#ff9900"> color test</font>
But the subscribers can't underline, add color to words nor add images.
Is it that only the admin can use more HTML tags than those suggested under the comment form?
<a href="" title=""> <abbr title="">
<acronym title=""> <b> <blockquote
cite=""> <cite> <code> <del
datetime=""> <em> <i> <q cite="">
<strike> <strong>
How to enable the subscribers to add color to text, and add images?
|
The tags that are allowed in comments are stored in the `$allowedtags` global variable. You can try adding elements to that list (the key is the tag name, the value is an array of allowed attributes). If you have problems with the timing you can play with the `CUSTOM_TAGS` global variable.
|
stackexchange-wordpress
|
{
"answer_score": 3,
"question_score": 1,
"tags": "comments, user roles, permissions"
}
|
Call to undefined function `get_plugin_data()`
I have a class inside a file that i `include_once()` from the functions.php of my theme. The class can be used as stand alone plugin, or integrated in a theme.
Inside the class i want to fill a class variable (inside the `__construct()` function) with the native wordpress function `get_plugin_data()`. Fun as it is, i get the following error:
> Call to undefined function `get_plugin_data()`
Am I asking for the plugin data too late, or what else might be my problem?
Thanks!
|
get_plugin_data() is only defined in the administration section. What info did you need to get from the plugin's header that you would need to display in the theme? If the answer is none, I would suggest that you place a conditional call in your constructor. Something like:
if ( is_admin() ) {
$var = get_plugin_data();
}
|
stackexchange-wordpress
|
{
"answer_score": 9,
"question_score": 8,
"tags": "get plugin data"
}
|
Switched server & domain name, now custom post types won't save
I had the site on oldsite.com but was using the database at newsite.com, everything was working great. I moved the site to newsite.com, now when I try adding a new post using a custom post type, it disappears, I am still able edit older posts, of the same custom post type. I checked the db when I create a new post nothing is saved, when I make changes to existing posts the change is saved.
Not sure where to look next. Thanks
this is in my functions.php <
|
Try re-generating the permalinks structure. And check that you have the correct urls in the general options (WPURL and URL)
|
stackexchange-wordpress
|
{
"answer_score": 0,
"question_score": 0,
"tags": "custom post types, database"
}
|
Get search term not on searh results page?
I would like to get the last term that was searched, but when not in the search.php page. For that, I know, I could use **get_search_query()** function, but if user clicks on a post for example, so he is now in the single item and that function will retrieve an empty string. I want to preserve that search phrase and get it on other page.
Any ideas?
Thanks
|
Best solution would be to store the search phrase on the client-side via local storage or, where not available, in a cookie.
|
stackexchange-wordpress
|
{
"answer_score": 4,
"question_score": 1,
"tags": "search"
}
|
Image gallery plugin
Can you recommend a tutorial or a plugin in wordpress that lets you achieve a similar gallery, like this <
Large Preview then at the bottom a thumbnails then an album.
I also like cooliris because it supports fetching images from facebook and flikr. Another feature I like about it is its sharing options, you can easily share those images in facebook. The only thing I don't like is its interface, its not fully customizable, the arrows left and right are hardly to be seen, the animation is too techno for my project.
I need a gallery where thumbnails where thumbnails can easily be browse, and it also has an album so its organize. It would be a plus if you have an option to pull images from flikr or facebook and you can share them via facebook or twitter.
Let me know if you know a software that is close to my description.
Thanks so much!
|
You would have to create custom templates, but your reference page is fully achievable using the NextGen Gallery plugin.
|
stackexchange-wordpress
|
{
"answer_score": 1,
"question_score": 1,
"tags": "plugins, images, gallery"
}
|
Disable front end to use as CMS only?
I'm using the WordPress database and back end to administer the news for my band's website and everything is working great however I'd like to disable the front end of WordPress itself.
I have the WordPress installation installed in `/wordpress/` and obviously the admin section is under `/wordpress/wp-admin/`.
What would be the best way to restrict someone from accessing the rather *un*setup WordPress site itself without affecting the admin section?
If anything, I could simply redirect to the website's proper home page (`domain.com/`).
|
To make sure only the front end redirects to `domain.com`, make a theme that uses the PHP header() function.
* Create a folder called redirect or something.
* Add two files to the folder: `style.css` and `index.php` (necessary for a valid WP theme)
* In `style.css`, add something like this:
/*
Theme Name: Redirect
Description: Redirects the front end to domain.com
*/
* In `index.php` add this:
<?php
header( "Location: );
?>
* Upload the folder to the themes directory and then activate it in the admin UI.
|
stackexchange-wordpress
|
{
"answer_score": 30,
"question_score": 29,
"tags": "redirect, front end"
}
|
Will my Wordpress site become vulnerable to Cross-Site Scripting (XSS) if I allow img tags in the comments area?
I'm planning to follow this tutorial in order to allow my subscribers to add images to comments (actually a custom post type called "Replies").
Wordpress filters `<img>` tags by default (except for the admin).
Will my Wordpress site be vulnerable to Cross-Site Scripting (XSS) if I allow img HTML tags in my comment section?
|
Many evil things can be done by including an image. The question is how well WordPress filters them. To give you an idea:
* File names should be checked properly.
* The actual image data can contain javascript.
* Also, EXIF data could contain javascript.
|
stackexchange-wordpress
|
{
"answer_score": 3,
"question_score": 4,
"tags": "html, security"
}
|
Mail isn't sent after local site registration
I installed a new WP site on local machine with wamp server. When a new user registers it gets the "registration successful" message but a mail with the password is never sent. Also checked the junk folder.
What can be the cause?
|
Probably your local setup since Wamp does NOT come with mail server. But you can configure the STMP settings of PHP to point to another server in your LAN which runs an SMTP server, or to the SMTP server of your ISP.
this thread has an example of how to set it up: <
|
stackexchange-wordpress
|
{
"answer_score": 3,
"question_score": 3,
"tags": "user registration, local installation, email"
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.