INSTRUCTION
stringlengths
11
999
RESPONSE
stringlengths
0
999
SOURCE
stringlengths
16
38
METADATA
dict
What is a reasonable get_num_queries() result? What is a reasonable number of results I should expect with get_num_queries()? I know it depends on the theme, and I know that smaller is better, but what is a ballpark figure? 10s? 100s?
Depends on the use case. But 100 def. says there's something gone wrong. If you got a lot of custom tables and a lot of different stuff from different tables that you need to display on one page/request, then I'd say 40 is _higher_ than usual. My personal framework does around 10-15(?) queries for a _normal_ blog.
stackexchange-wordpress
{ "answer_score": 1, "question_score": 3, "tags": "performance" }
Finding posts containing matching array elements in a meta field usign WP_Query I have a metafield, that contains a series of options and writes the results to an array in a single meta field: array([0]=>'First', [1]=>'Second', [2]=>'Third', ); I find posts that contain any of the array elements, and display them using `WP_Query` $search = new WP_Query('meta_key=mykey&meta_value=second'); But this doesn't seem to work. Any idea on how to achieve this? * * * I have edited my method, following this question: $arg['meta_key'] == $key; $args['meta_value'] = "%|".$value."|%"; $custom_query = new WP_Query($args); But no darts.
I believe you have to use meta compare LIKE. If you do a regular meta query, the resulting SQL will be meta_value = your_value, which is never going to find anything because it's trying to match the entire contents of the field.
stackexchange-wordpress
{ "answer_score": 2, "question_score": 1, "tags": "plugin development, theme development, wp query, loop" }
Jigoshop - change the order in which products show up in a grid Using the < plugin, is it possible to change the order in which the products are displayed in the different grids. I'm not quite sure how it decides the order but is it possible to change it to sort it via menu order? This is the page I'm working on - < (I've yet to check browser compatibility with the site - I'm using Chrome)
As Bainternet said you need to adjust the query vars, however I needed to change the order well before 'jigoshop_before_shop_loop' hook to get this to work. This function fires at pre_get_posts and orders by title. add_action('pre_get_posts', 'my_custom_query'); function my_custom_query($wp_query){ if(is_tax('product_cat')){ $wp_query->query['order'] = 'ASC'; $wp_query->query['orderby'] = 'title'; return $wp_query; } }
stackexchange-wordpress
{ "answer_score": 2, "question_score": 0, "tags": "e commerce" }
Custom post type permalinks I have a custom post type called "number" and I would like to achieve URL's for it's "posts" to be the following < instead of < I tried to set the 'rewrite' parameter in register_post_type to: `'rewrite' => array( 'slug' => '', 'with_front' => false )`, but it didn't worked. Even if I saved my permalinks settings to flush it. (I have my permalinks set to Day and name - /%year%/%monthnum%/%day%/%postname%/) Do you have any ideas how to achieve it? I am doing a transfer of one website to WP and I would like to keep the current URL structure, so it will be safe for Google as well. Thank you in advance for any tips.
You could use a rewrite rule in your .htaccess file to remove number from the link. You'll need something along the lines of: RewriteRule ^number/(.+)$ $1 [R=301,L]
stackexchange-wordpress
{ "answer_score": 1, "question_score": 1, "tags": "custom post types, permalinks" }
Cannot get redirect working I can't get wp_redirect working correctly? I thought I'd figured this out (see wp_redirect not working when going to www version of site) but apparently not; no idea what changed between last week when it was working and now. I tried simplifying the function down but using the following I get an infinite-redirect error: add_action ('after_setup_theme','mkm_restrict_access',10); function mkm_restrict_access() { if (!is_user_logged_in() && !is_page('splashpage') && !is_page('login')) { wp_redirect(' exit; } } I've tried using wp_footer and almost everything up the chain in terms of calling the function but nothing seems to help. I am running Theme My Login and User Domain Whitelist, if that matters. I tried disabling them but it didn't help. I suspect I'm doing something REALLY STUPID. :( Thanks for your help!
none of those conditionals will work at after_theme_setup. Look at the Action Reference page in Codex for the order actions are executed in a request. Try hooking `template_redirect` instead.
stackexchange-wordpress
{ "answer_score": 1, "question_score": 0, "tags": "wp redirect" }
Data sanitization for user registration and user login What kinds of data sanitization I have to do if I make a front end login and registration system for wordpress users? 1. For login function `wp_signon()` should I escape the data for possible sql injection or wordpress will automatically do it for me? 2. For registration I have found two function so far `wp_insert_user()` and `wp_create_user()` and for updating user `wp_update_user()` For the registration function I think `wp_create_user()` will do the job for me. Again how much sanitization should i do? Do i need to do the password hashing? Also i have found some filters on the function reference page of the `wp_create_user()`. Those are `pre_user_user_pass`, `pre_user_user_login`, `pre_user_user_nicename` etc. Do, I need to use those filter before insert a new user?
You can check my tutorial for front-end user registration and login in WordPress: < As to the wp_signon, wp_insert_user, wp_create_user and wp_update_user they take care of all sanitation and validation of your content. Also you don't need to use those filters in wp_create_user to create your users.
stackexchange-wordpress
{ "answer_score": 1, "question_score": 1, "tags": "validation, wp create user, user registration, sanitization" }
All Updated Plugins Disappeared I had 5 plugins with updates. After updating all of them through the Available Updates tool they disappeared from the Network Plugins page. I received errors like this for all plugins: The plugin custom-post-type-ui/custom-post-type-ui.php has been deactivated due to an error: Plugin file does not exist. The folders still exist in /wp-content/plugins/ When I deleted the folders and uploaded them through FTP they do not appear on the Plugins page. When I install them through wp-admin I receive this log text: Downloading install package from Unpacking the package… Installing the plugin… Successfully installed the plugin Custom Post Type UI 0.7.1. Network Activate | Return to Plugin Installer But when I click Network Activate, I receive this error: The plugin does not have a valid header. This happens for all 5 plugins and only happened beginning today.
We resolved this issue by removing re-uploading the admin and includes folders, although I'm not sure what originally caused the issue.
stackexchange-wordpress
{ "answer_score": 2, "question_score": 2, "tags": "plugins, updates" }
I've been out of the loop since 2.8. What did I miss? I haven't done any serious WP development since version 2.8, although I fiddled a bit with version 3.0. Short of reading the release notes on each version, what are the major things to take note of as 1) a theme/plugin developer and 2) an administrator? I've already identified three things: * Custom Post Types and Taxonomies * Custom Menus * Post Formats (a la Tumbr) What else do I need to take note of?
In no particular order, other notable things are: * old default theme was deprecated in favor of annual theme changes, you jumped over Twenty Ten theme and current one is Twenty Eleven * WordPress MU was merged into mainline WordPress and is now called multisite feature * serious improvements to complex querying by taxonomies and custom fields * server requirements had been bumped to newer versions of PHP and MySQL There had also been a lot of work done on admin UI and such. Too much of smaller stuff to list, just go through version pages in Codex (click version numbers, changelog pages are useless).
stackexchange-wordpress
{ "answer_score": 2, "question_score": 1, "tags": "loop" }
How to prevent specific plugin files or subfolders from appearing under "plugin files" listing I have a folder inside my plugin that's used to store cached data for the application. There's no need for the user to edit these files so I'd like to remove this folder's files from appearing in the "Plugin files" listing that appears in the right sidebar when editing the plugin files via "Plugins > Editor". Is this possible?
Use the upload directory to store files. You should **never** store files in the plugin directory. There is no guarantee that you have write access there.
stackexchange-wordpress
{ "answer_score": 4, "question_score": 1, "tags": "plugin development" }
Creating custom tags Hi there Best Wordpress Gurus, i've a question about using tags to simplify my HTML. For example if i want to ad a block of content lets say a contact form. I don't want to ad all the time my html code can i use a tag something like: `#contact_form` and that this tag output a contactform for me. If this possible can someone please give me a link to tutorial or gives a example. Tnx in advance.
Navid, There is functionality which will for the most part accomplish what you are looking for. In WordPress you can create what are known as shortcodes. These, when inserted into a post or page, will allow you to display complex information, much like using a macro Shortcodes can be used for very simple or more complex tasks. Here are some articles to help you get started. Wordpress Shortcode API Wp Tuts+ Shortcode Article
stackexchange-wordpress
{ "answer_score": 2, "question_score": 1, "tags": "tags" }
How do I override all stylesheets and scripts without a plugin I'm finding that plugins completely destroy my source formatting and generally suck at following standards. How can I absolutely block all style-sheets and move all .js to the footer of the site without modifying the plugins or adding an additional plugin? Here's an example of what my homepage looks like under their rule <
WordPress plugins usually enqueue's their stylesheets and js files using wp_enqueue_style and wp_enqueue_script functions. You can dequeue script / dequeue style the scripts/styles if you don't want them in your theme. These css/js files usually loads with wp_head() action, which usually resides in your header.php in the theme
stackexchange-wordpress
{ "answer_score": 1, "question_score": 0, "tags": "plugins, css, javascript" }
Display tags with a twist I would like to display the tags of a post different than what's standard in WordPress. If I've understood it correct, all I can do with the regular tags is to display different things between them and at the end. The tags should be displayed like this: Read more about tag 1, tag 2, and tag 3 Read more about tag 1 and tag 2 How can I get that "and" word in there?
the_tags() is simple for convenience, if you want more control over formatting, use get_the_tags() and output them however you want. EDIT - quick example for the template: <?php $posttags = get_the_tags(); if ($posttags) { echo 'Read more about '; $tag_count = count( $posttags ); $count = 0; foreach( $posttags as $tag ) { $count++; if( $tag_count == $count ) $sep = '.'; elseif( $tag_count - 1 == $count ) $sep = ', and '; else $sep = ', '; ?> <a href="<?php echo get_tag_link( $tag->term_id ); ?>" title=""><?php echo $tag->name; ?></a><?php echo $sep; ?> <?php } } ?>
stackexchange-wordpress
{ "answer_score": 3, "question_score": 2, "tags": "customization, tags" }
functions.php conditional tag only for custom post type I'm using gpp slideshow, which overwrites wordpress's default gallery display. I only want to use it on my custom post type, "listings" - how would I reference it to only replace wordpress's default gallery on the "listings' page? I have this code in my functions.php, and I can't seem to get the reference right for the custom post type: add_action('wp_head','add_gpp_gallery'); function add_gpp_gallery() { if( ( is_single() || is_page() ) && ( !is_page_template('page-blog.php') ) ){ remove_shortcode('gallery', 'gallery_shortcode'); add_shortcode('gallery', 'gpp_gallery_shortcode'); } } above is the code the plugin uses, and I added it to my functions.php and tried this change: if (is_single() && is_post_type('post_type'){ and that returns an error. thoughts & thanks
Try using `get_post_type()` instead: if ( is_single() && 'post_type' == get_post_type() ) { // Do something } The `is_post_type()` conditional is deprecated. But even when it existed, it returned true if _the current post is any registered custom post type_. It has been replaced with `post_type_exists()`. (More information on Post Type conditional tags.)
stackexchange-wordpress
{ "answer_score": 4, "question_score": 3, "tags": "custom post types, get posts, conditional tags" }
How to get a retweet button on my wordpress.com blog? Is is possible to get a retweet button on a WordPress.com blog? I see that plugins are not an option, and the only widget that I found was for adding my tweets to my blog. I'm looking to add my blog to other peoples tweets, and I'm surprised that isn't built in, like the FaceBook 'like' widget. Can this be done?
In your dashboard, go to Settings > Sharing, and drag the available social networks into the "Enabled Services" area to accomplish this. See <
stackexchange-wordpress
{ "answer_score": 2, "question_score": 0, "tags": "wordpress.com hosting, twitter" }
Use wp_enqueue_style based on user option in widget I currently developing wordpress widget for my website. This widget will pull user latest post in my website and show in their blog. In the widget there is option for user to use their css or my css for the widget I use this code in my widget and its work perfectly but this code will always load the css. add_action( 'widgets_init', 'load_my_widgets' ); function load_my_widgets() { register_widget( 'My_Widget' ); wp_register_style( 'my_widget_css', ' ); wp_enqueue_style( 'my_widget_css' ); } The problem is how can I enable the CSS based on the user option? I try something like this but its not working function widget( $args, $instance ) { $own_css = isset( $instance['own_css'] ) ? true : false; if ( ! $own_css ) { wp_enqueue_style( 'my_widget_css' ); } }
This is sort of sloppy as the style will still be enqueued regardless. In the code to display your widget, change the CSS selectors based on whether or not the user selected own style: <?php $prefix = $instance['own_style'] ? 'ownstyle_' : 'pluginstyle_'; //then.... ?> <div id="<?php echo $prefix; ?>selector"> ...</div> etc A user would be able to use both a widget with custom style and one with default style this way. Enqueue your style separately in its own function. add_action( 'wp_print_scripts', 'wpse26241_enqueue' ); function wpse26241_enqueue() { if( is_admin() ) return; if( is_active_widget( 'My_Widget' ) ) wp_enqueue_style( 'my_style' ); }
stackexchange-wordpress
{ "answer_score": 1, "question_score": 2, "tags": "widgets" }
Migrating from other CMS to WP - losing SEO juice? I'm thinking about migrating a client's website from a super-old cms (xoops) to WP. However the site is quite old so I don't want him to lose any SEO juice he acquired through the years (PR: 2). Anything I'd have to consider doing the migration? (I was thinking about setting up WP on a separate folder and then moving it to root for the full migration - anything I have to consider here?) Thanks a lot! Edit: Mike Hudson (comment below) made me aware of an error. I thought PR = Ranking in the results. Meaning: I'm more concerned with the ranking than the PR, so redirect is the way to go! Thanks folks!
You should use a sitemap module to generate a list of URLs created by XOOPs e.g. [xSitemap]. Then you have to set up your .htaccess to 301 redirect each URL to its corresponding page in the new Wordpress instance. Finally, you should consider installing a Wordpress plugin like Redirection to check for 404s and redirect them nicely to the new instance.
stackexchange-wordpress
{ "answer_score": 3, "question_score": 2, "tags": "seo, cms, migration" }
How to put a Worpdpress theme in spanish (having the po file)? I am building a Wordpress blog system in Spanish and I'd like to have the default theme also translated to "es_ES". I am already running this Wordpress installation in Spanish. What I'd like to know is how to do the same with the default theme (twenty-eleven). This site allows us to download the po file with the translation: < But I don't know what to do next. Thanks.
You need create a **es_ES.mo** file, using the .po file included with the Theme. Try using something like POEdit or a similar utility.
stackexchange-wordpress
{ "answer_score": 1, "question_score": 1, "tags": "themes, theme twenty eleven, language, translation" }
What is a reasonable memory limit for Wordpress Although the accounts on my server generally have a lower memory limit, I've configured my Wordpress user accounts with a memory limit of 32Mb using the php.ini file and `memory_limit = 32M` Unfortunately I've found that I'm still getting the odd memory error, even on small tests blogs. I've had to increase the limit to 64Mb which in my mind seems a little high for normal usage. What should be a reasonable upper memory limit to have on standard Wordpress installs with popular plugins? For your information some of the plugins that I suspect might be causing memory issues are: * W3 Total Cache * Role Scoper * Smush.it
Obviously this question is a little squishy, as YMMV, but I've run several WP sites using W3TC and similar plugins to yours on 32M, and haven't had an issue. That being said, when are you typically running into issues? Is it on post submission? On gallery operations? Looking for a pattern there could be helpful. Let us know if you find one. Also remember that a limit is just that, a limit. The majority of the time your site will not be running at the max of 32 or 64M, especially with a caching plugin like W3TC installed and properly configured. PHP may burst to 64, but so long as your server can handle bursts up to that level, then you should feel comfortable with it. Generally, memory limits can be set a little higher than what you'd expect, and so long as you aren't causing your server to thrash then you are fine. Try running `top` or `free -m -s 5` to examine memory usage over time, and see if you're constantly running close to the limit, or if it will continue fine as it is.
stackexchange-wordpress
{ "answer_score": 2, "question_score": 0, "tags": "plugins, server, memory, server load" }
How do I access cPanel features within Wordpress? Is there a plugin that can access cPanel features from within Wordpress? In particular I'd like to be able to: * View bandwidth, quota and other server info from the WP Dashboard * Access my webmail * Access the file manager to edit files (useful for .htaccess, php.ini and non-WP files) I know I can just open a new tab and log on to my cPanel account, but it would be great if it could be integrated some how. If there isn't a plugin to achieve the above, then I suppose an easier way would be for some links to be added to the Dashboard menu (for example webmail and file manager) which would link directly to those sections in cPanel and perhaps open in an iframe. So, to recap... does a plugin exist to achieve the above (or it easy to make one) or if not, does a plugin exist (or how do I create one) that adds these links to the dashboard. Any ideas from people who use cPanel and WP on a regular basis would be helpful.
I do not believe there are any plugins specifically catered to cPanel, however there are a few plugins which will allow you to add an iFrame to your admin pages. I have not used any of these, and agree with the other commenter (Chip) who mentioned that it may pose a security risk. With that said, check out plugins like this: < search for similar: <
stackexchange-wordpress
{ "answer_score": 0, "question_score": 0, "tags": "plugins, server" }
Extending the user profile Is there any way that developing a Wordpress admin panel like this would be possible? < My client wants it to be displayed within the website template aswell. I really don't want to have to outsource this, but I'm stumped as to how to achieve this. Any help would be greatly appreciated.
I second what @Viruthagiri said. You can also use the plugin Theme My Login if you want to hide the real WordPress control panel from your users and only show them their own profile/edit profile page, themed just like your site. Best of luck!
stackexchange-wordpress
{ "answer_score": 0, "question_score": 0, "tags": "admin, dashboard, users, profiles" }
Where can I find admin-header.php file online? I am using Wordpress for my website. I was working on CPANEL yesterday and was browsing `public-html/wp-admin folder` under the `File manager`. There were many files and I accidentally deleted the `admin-header.php` file. Where can I get an another copy of that file so that I can upload it to the same folder from where it got deleted?
Couldn't see a download link on the Github page for downloading single files(i don't use it so maybe i'm just not seeing it). Alternatively you can download single files for WordPress from trac. **Example:** < Scroll to the bottom of the page(or hit the `End` key), look for the text " **Download in other formats:** " click the " **Original Format** " link below that text to download the single file. Can't hurt to have options right.. ;)
stackexchange-wordpress
{ "answer_score": 2, "question_score": 0, "tags": "wp admin, installation" }
MailChimp integration that allows users to select from multiple lists I'm integrating Mailchimp signup into a WP install and I have 2 questions. 1. What is the best way or best plugin to integrate mailchimp signup? 2. Is it possible to allow the user to select from multiple lists to be subscribed to. I realize the latter is more closely related to MailChimp but I'm hoping that someone has an answer for that as well.
The current Mailchimp Plugin for Wordpress does not allow user to select multiple lists. Infact Mailchimp discourage this practice. Instead what they advocate is to create groups within the lists and then use segmenting while sending campaigns. These links might be useful MailChimp Documentation Google Groups discussion
stackexchange-wordpress
{ "answer_score": 1, "question_score": 2, "tags": "plugins, customization, plugin mailchimp" }
Exclude function from homepage only? There is a function in a theme that I am using that does some pagination stuff. I do NOT want that function to show up on my home page (only), so I'm trying to set up an if/else statement but can't for the life of me can't get it to work right. Using the following code, the function shows up not only on the homepage but also on the category pages. I am using this code in my index.php file and my site is setup to show posts from a custom post type. <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?> <div>My Loop Stuff Here</div> <?php endwhile; ?> <?php if (!( is_home() || is_front_page() )) : function_to_NOT_show_on_homepage(); endif; ?> <?php else: ?> [else stuffs] <?php endif; ?> <?php wp_reset_query(); ?>
Based on your pastes, i think what you're going for is.. function cp_do_pagination() { if( is_home() || is_singular() /* || is_front_page() */ ) return; global $post; // <-- do you need this for something in particular? if( !function_exists('appthemes_pagination') ) return; appthemes_pagination(); } The `is_singular()` function covers `is_page()`, `is_single()` and `is_attachment()`, so no need for the additional conditionals. Info on that function here, for reference. <
stackexchange-wordpress
{ "answer_score": 1, "question_score": 0, "tags": "theme development, homepage, get template part" }
How can I call plugin function from a custom template? I've just developed a calendar plugin. To display a calendar in a template, I call `do_shortcode(args...);`. This works fine. But how can I call a function from my plugin that will return data? I don't want to use `include_once` \- I really just want to call a function E.g. $events = calendar->getEvents(args...)
As long as the plugin is active, the function will work perfectly fine from any template.
stackexchange-wordpress
{ "answer_score": 4, "question_score": 2, "tags": "plugins" }
Best way to enable sorting by 3 criteria on a page of listings If you go to this site: < and click on one of the links in the Directory (left column of homepage) you generate a page with listings, and at the top of each page there's 3 links that let you sort the page content by city, county or product. I want to rebuild the site in WP, but am wondering how to enable that kind of sorting. I was going to enter the listings via custom post types. Any advice greatly appreciated!
Could you clarify, I think what your asking is if your able to specify post types when querying - you certainly can. < If you asking about category searches, then yes of course. That same link also has information on querying taxonomy, there are many ways to do that thought that depend on the actual site being built. Edit: From the comments it seems you need to Orderby metadata.. <
stackexchange-wordpress
{ "answer_score": 0, "question_score": 0, "tags": "posts, customization" }
Getting custom-sized featured image's URL? I'm adding additional image sizes to my theme: **functions.php** add_image_size( 'my-thumbnails', 122, 122, true ); I used to get thumbnails URL like this: wp_get_attachment_url(get_post_thumbnail_id($post->ID)); And it works like a charm, but I'm not sure how to display 'my-thumbnails' version of the thumbnail? This doesn't work: wp_get_attachment_image_src( get_post_thumbnail_id($post->ID),'my-thumbnails' ); What's wrong?
You should use one of the following: // Thumbnail wp_get_attachment_thumb_file( $GLOBALS['post']->ID ); // Custom wp_get_attachment_image_src( $attachment_id, $size='my-thumbnails' ); // Or: wp_get_attachment_image( $attachment_id, $size='my-thumbnails' );
stackexchange-wordpress
{ "answer_score": 2, "question_score": 5, "tags": "post thumbnails, images" }
WordPress User Roles, Custom Post Types, and Admin views My friend mentioned that there is a simple way to modify what users see in the admin sidebar based on their user role. I have a large number of custom post types, one for each user, and I need to limit these users (currently given the role 'author') access to only their own post type and the Posts (not even Pages). I also want to hide Widgets from them. Is there a bit of PHP I can stick in my functions.php file to accomplish this easily?
To anyone else having the same problem as me, I used the Role Scoper plugin, which is recommended by WordPress on their page that describes user roles. It has a very simple UI, and is easy to install and use.
stackexchange-wordpress
{ "answer_score": 1, "question_score": 2, "tags": "custom post types, wp admin, admin" }
Need help with a custom rewrite rule - http://domain/custom post slug/replies I had asked this question in a different way too, but no one replied there! I guess I should rephrase it here. My custom post is 'company'. I'm trying to add a custom rewrite rule. When the 'url < is accessed, I want redirect to a custom template(applied to a page named 'replies') with all the comments for this custom post listed. If I add the comment id in the url like this 'url < I want to redirect to another page with a custom template applied for displaying a single comment. This is what I did for accessing the url... ' and it works fine. add_rewrite_rule('^replies/(.*)?$','index.php?pagename=replies&reply_id=$matches[1]','top'); Please guide me in the proper direction, having a real hard time with the url rewrite stuff! Thanks in advance!
I haven't tested it, but what about: add_rewrite_rule('^company/(.+)/replies/(.*)?$','index.php?pagename=replies&reply_id=$matches[2]','top');
stackexchange-wordpress
{ "answer_score": 1, "question_score": 0, "tags": "url rewriting" }
How was my WP site hacked My site, < has been hacked, and I can't login to wp-admin. Can you say how it has been hacked and what can I do to undo the damage? I have access to the host.
If you do a Google search, you will find many topics on this. Here are some links: First read this: < Then take a look at these links: < < < If you have access to your database, login using PHPMyAdmin and change admin username / password, delete users you don't know and change password for rest. Then start the process of backing up data and do a clean install. **Note.** If you can't find out how they got access to your site, doing a clean install and putting back data, will still leave whatever hole open. Also not that backdoors (links / code) could have been added to your posts, so all content must be checked before you import exported data.
stackexchange-wordpress
{ "answer_score": 5, "question_score": 1, "tags": "hacked" }
How to make that all permalinks would open in a new window? Where should I amend to make this happen? I should add somewhere target="blank_" Regards,
in the link tag of course: <a href="<?php the_permalink(); ?>" target="_blank">link title</a> but it is `_blank` and not `blank_`
stackexchange-wordpress
{ "answer_score": 0, "question_score": -2, "tags": "wordpress.com hosting" }
how to only have one custom post type post? Is it possible to limit a CPT to just one? What I'd like to accomplish is creating a CPT called "Home". It will manage any and all elements on the home page. I want to program it so when the user clicks on the "Manage Home Page" link they will go straight to the edit post screen. They will skip over the "All Post" screen. Does anyone think this is even possible? Or maybe someone has an idea to accomplish this goal a completely different?
I would suggest creating a Theme Options page for this purpose. < add_options_page() in Codex. Or is there anything special in the post edit screen that you want to use that would be hard to get into the Theme Options page?
stackexchange-wordpress
{ "answer_score": 4, "question_score": 2, "tags": "custom post types, admin menu" }
Plugins in mu-plugins folder are not loaded I'm trying to load plugins automatically by putting the plugins into `mu-plugins` folder. But if the plugin is put in a folder, it isn't loaded. I tried some popular plugins such as W3 Total Cache, WordPress SEO By Yoast, but all of them are not loaded. Does WordPress only loads plugins which are just single files in `mu-plugins`?
> Does WordPress only loads plugins which are just single files in mu-plugins? No, they do not need to be single files but you cannot use plugins in their own subfolders as in the standard `plugins/` folder. **The main plugin file** (one with the specified plugin header info) **has to be right there in** `mu-plugins/` **.** Other files can be put in a subfolder and referenced from there. I used it with my own plugins. I've never tried moving any robust plugin in there. Also note that not all plugins are _must-use-compatible_ see <
stackexchange-wordpress
{ "answer_score": 18, "question_score": 13, "tags": "mu plugins" }
Use [embed] filter in template files WordPress automatically embeds a youtube video's if I use: [embed] [/embed ] This is great, but it doesn't work if I use it in a template file. I have a custom field where the admin can put a URL to a YouTube video. I want to get the video in the single-post using the following code: <?php $custom = get_post_custom($post->ID); $url = $custom['_videoLink'][0]; ?> <div class="video"> [embed]<?php $url; ?>[/embed] </div> How can I convert the Youtube URL into an embed URL using the standard WordPress [embed] function?
Use `wp_oembed_get( $url )` instead. Make sure you `echo` it in your template file. So, something like this: <?php // tot necessary to set this but good if $url is coming from a function $url = ' // echo the function in your template to render the video echo wp_oembed_get( $url ); ?>
stackexchange-wordpress
{ "answer_score": 17, "question_score": 10, "tags": "templates, embed, youtube" }
Best Practice for Displaying Categorized Posts on Front Page I am building a custom wordpress theme from a clients mockup. On the homepage there are 2 sliders, and 4-5 areas for recent posts of different types. I would like to have all the content be editable in wordpress what is the best way to create a post, apply some sortof value to it (category,taxonomy,tag,custom post type), and then retrieve more than one loop on a single page or is it best to use feeds? Any suggestions greatly appreciated
You can use WP_Query in your template to select groups of posts by type, category, tag, custom taxonomy, meta field, etc., and create additional loops: <?php $news = new WP_Query("post_type=mynews&posts_per_page=1"); while($news->have_posts()) : $news->the_post(); the_title(); endwhile; $events = new WP_Query("cat=2&posts_per_page=3"); while($events->have_posts()) : $events->the_post(); the_title(); endwhile; // etc.. It's up to you how to best organize your content in a way that makes sense as far as how you use your taxonomies and types.
stackexchange-wordpress
{ "answer_score": 2, "question_score": 0, "tags": "customization, frontpage" }
how is the theme unit test data licensed? Can I use the theme uint test data in a demonstration site for a commercial theme? Or am I only allowed to use it for internal development? <
Everything on the Codex is GPL (or can be considered as GPL-compatible). Insofar as any part of the Theme Unit Test data are copyrightable, unless stated otherwise you may assume that the WordPress Foundation holds the copyright, and that the work is released under the GPL. Feel free to use it however you see fit!
stackexchange-wordpress
{ "answer_score": 3, "question_score": 5, "tags": "licensing" }
remove the 'page' URL parameter in previous/next posts link I want to remove the "page" bit from the URL when I use the `previous_posts_link` and `next_posts_link`. Right now, it looks like: < I want it to look like this: < How can I do it? Thanks!
So yeah, got the tumbleweed badge :(. I ended up doing a 301 with the .htaccess, but If someone has a better idea please share it!
stackexchange-wordpress
{ "answer_score": 0, "question_score": 0, "tags": "links" }
How can I create custom URL routes? I have a very peculiar requirement, but hopefully I can explain it without being too confusing. I created a page template where I list some properties I get from an external XML file. So far no problems, and let's say the URL is like this: Each property has a link that should redirect the user to a "Single Property" page that displays more information about it. I was wondering if there's a way to make the link like this: Where `123` would be the id of the property. So if I have the URL like `properties/some_id` I want to be able to load a view file (like the `single.php` or `page.php` files), but specific to this URL condition. Is this possible?
Add this to your theme's functions.php, or put it in a plugin. add_action( 'init', 'wpse26388_rewrites_init' ); function wpse26388_rewrites_init(){ add_rewrite_rule( 'properties/([0-9]+)/?$', 'index.php?pagename=properties&property_id=$matches[1]', 'top' ); } add_filter( 'query_vars', 'wpse26388_query_vars' ); function wpse26388_query_vars( $query_vars ){ $query_vars[] = 'property_id'; return $query_vars; } This adds a rewrite rule which directs requests to `/properties/` with any combination of numbers following to pagename `properties`, with the query var `property_id` set. Just be sure to visit your permalinks settings page and save to flush rewrite rules, so this new rule will be included. In your `page-properties.php` template, `get_query_var('property_id')` will return the property id if it was set, if it's not then show the default properties page.
stackexchange-wordpress
{ "answer_score": 83, "question_score": 68, "tags": "url rewriting, templates, rewrite rules, mod rewrite, template redirect" }
Find out how many times the user has logged in I'd like to determine how many times a user has logged in. Does WordPress retain that information or will I have to add a db entry every time they log-in? if(is_user_logged_in() && ($logged_in_times == 2)) { // do something }
I don't think so. You will need to do something like this (untested): add_action("wp_login", "my_login_function"); function my_login_function($username){ $userdata = get_user_by('login', $username); $n = get_user_meta($userdata->ID, "my_login_counter", true); if (! is_numeric($n)) $n = 0; $n = intval($n) + 1; update_user_meta($userdata->ID, "my_login_counter", $n); }
stackexchange-wordpress
{ "answer_score": 3, "question_score": 0, "tags": "mysql, login, users" }
Review site custom post type structure I build a review site with Wordpress. I created a custom post type called "Reviews", inside this, theres two taxonomy, one called "Genres" and one called "Types". Inside the Genres, i have a couple of subcategory, action, comedy, drama etc... and inside the Types, i have 2 subcategory: Movies and TV Shows I want to create a navigation on my homepage like this: * Movies * Action * Comedy * Drama * Tv Show * Action * Comedy * Drama And of course, if i click on the Tv Shows/Action, i only want to display all of the reviews inside the Tv Shows category which has an Action genre, and only the TV show, not the movies. What is the easiest solution to do this?
The way that I would approach it is using the tax_query to create a query that looks for both the correct genre and type. For example, to query all Movies that are Drama: $myquery['tax_query'] = array( array( 'taxonomy' => 'genre', 'terms' => array('drama'), 'field' => 'slug', ), array( 'taxonomy' => 'type', 'terms' => array('movie'), 'field' => 'slug', ), ); query_posts($myquery); Hopefully that will get you started in the right direction.
stackexchange-wordpress
{ "answer_score": 0, "question_score": 1, "tags": "custom post types, taxonomy, menus" }
Why would a GET variable one one page of a site cause a 404 error when a GET variable works on another page of a site? For example I have 20 pages on a site. one of them is called bacon another called eggs. on the same site...lets say breakfast.com I have the permalinks set up properly and have used them successfully on all pages, including Eggs by way of this: www.breakfast.com/eggs?cooked=scrambled. This works 100% as it should. However, on a different page of Breakfast.com called sausage...this, does not work. www.breakfast.com/sausage?type=spicy this is causes a 404 error. I don't see why it would as it's the same format. I have verified that the page exists in my pages directory in WP-admin. If I strip away the GET variable the page works. Google is not helping me. Anyone have a similar experience?
WordPress has a list of reserved terms that you _cannot_ use for taxonomies. From your question, I gather that "cooked" is a taxonomy that applies to eggs and "type" is a taxonomy that applies to sausage. Unfortunately, "type" is a reserved term in WordPress, so it interprets your query string differently than you expect. The full list of reserved terms is available in the Codex. Just use a different term ... maybe "sausage-type" ... for your taxonomy and you should be in the clear.
stackexchange-wordpress
{ "answer_score": 13, "question_score": 5, "tags": "php, html, 404 error" }
How to disable monthly archive Is there a way to disable archives pages, specifically monthly archives?
Check this post by BetterWP. You may need to edit the code as it does not mention about monthly archives.
stackexchange-wordpress
{ "answer_score": 1, "question_score": 1, "tags": "archives" }
Why is 'is_multisite' returning true when it's a single install? I've installed a single site WP. In one of my plugins, I have the following code: if(is_multisite) { $upload_dir = get_upload_dir(); $_SESSION['root_image_dir'] = str_replace('\\','/',$upload_dir['basedir']); echo 'IS MULTI.'; //<-- this is outputted every time } else { $_SESSION['root_image_dir'] = ''; echo 'IS NOT MULTI'.$_SESSION['root_image_dir']; } For some reason, the `echo` statement is triggered every time. Why is `is_multisite` not working?.
If that's the code you have in your plugin, you're writing it wrong. You have `if(is_multisite)` which is treating the string `is_multisite` as a constant and evalutation to true. Essentially you're writing `if(true) ...` Remember, `is_multisite()` is a _function_. You need the parenthesis at the end for PHP to actually evaluate the function. Change your code to the following: if( is_multisite() ) { $upload_dir = get_upload_dir(); $_SESSION['root_image_dir'] = str_replace('\\','/',$upload_dir['basedir']); echo 'IS MULTI.'; //<-- this is outputted every time } else { $_SESSION['root_image_dir'] = ''; echo 'IS NOT MULTI'.$_SESSION['root_image_dir']; }
stackexchange-wordpress
{ "answer_score": 7, "question_score": 1, "tags": "multisite" }
How to use WordPress authentication on non-WordPress page? I have a site based on WordPress. This site has some functions for member only. One of the functions is a external script and I believe anyone can access this without authentication. I can add .htaccess to this script to prevent unauthorized access. But then my users have to login again and it's kind of inconvenient. Is there any solution to add some check to my script that use the same WordPress authentication mechanism, that is, if user already login, he have full access to the script. If not, he will be redirected to WordPress login page. **EDIT** : My script is written in PHP
Just add this at the top of your file: require_once($_SERVER['DOCUMENT_ROOT'].'/wp-blog-header.php'); // If you run multisite, you might nees this to prevent 404 error header('HTTP/1.1 200 OK'); Note that the file must be in the same folder as your theme. Then you can use `is_user_logged_in` before executing the rest of the script. If use is not logged in, then just trigger the login form or a login plugin.
stackexchange-wordpress
{ "answer_score": 11, "question_score": 4, "tags": "authentication" }
What 'function' will 'update' a post? I am using a script to import my vbulletin forum posts into wordpress as posts. One quick issue I ran into is there are numerous forum posts with the same title 'please help me'. When I go into the post edit screen the permalink will show 'please-help-me-2' for the second one, and 'please-help-me-3' for the third one. That is exactly what I expect. However, when you go to **view the second one on the front end of the website** , instead of having the -2 appended to the end of the url, it simply says 'please-help-me'. If I 'update' the post, then the permalink saves properly and the front end link changes like it should. **What I need:** Is there a function that I can use to go through the posts database and have it automatically 'update' all the posts so that the permalinks will change properly on the front end? *we're talking 1.25million posts here, so automation is important. thanks
There is a function called wp_insert_post that takes a parameter for post ID. If the post ID is an ID that already exists, this function will update the post with the information you pass in the function parameters. I think using that function you could find a way to retrieve all of your post ID's in an array and then use a foreach loop to update each one.
stackexchange-wordpress
{ "answer_score": 0, "question_score": 1, "tags": "wp update post" }
view queries made? I know I can use `get_num_queries()` for the number of queries. However, how can I see what queries Wordpress actually makes? I've tried using $query but that didn't work.
See this codex page. in `wp-config.php`: define('SAVEQUERIES', true); then in your template: if (current_user_can('administrator')){ global $wpdb; echo "<pre>"; print_r($wpdb->queries); echo "</pre>"; } or without the above `SAVEQUERIES`, you can still see just the main query: global $wp_query; echo $wp_query->request; or to see all of `$wp_query`: <pre> <?php print_r($wp_query); ?> </pre>
stackexchange-wordpress
{ "answer_score": 7, "question_score": 2, "tags": "wp query, query" }
Wordpress Multisite - Can 2 domains share a database of users? I'm creating a Wordpress site for a client. In the future, my client would like to have a second site that uses Wordpress as well. Ideally, we'd like people that have accounts on the first site to be able to use that same account on the second site. Is this something that can be achieved with Wordpress Multisite? If so, how? The kickers is that each site would need to have it's own domain. For example, < and < would be two different sites sharing the same user accounts. Any help or insight would be greatly appreciated.
WordPress multisite only has one table for users, so yes, users can use the same account on both sites. You will just have to be sure to set the appropriate role on each site, as network users are not necessarily users of a given site.
stackexchange-wordpress
{ "answer_score": 1, "question_score": 1, "tags": "multisite" }
Naming Admin Menus and Submenus I'm building a plugin that requires its own set of admin pages. I know how to create the top-level link and how to add sub-menus to it. However, what seems to happen is when I create the top-level link, it also automatically adds a submenu page of the same name if I add another submenu page to it. I'm simply looking for a way to change the name of my first submenu page so that it is different from the parent name. (i.e. in the admin panel, expanding the "Links" menu shows an "All Links" submenu page. Mine would instead say "Links" on top and then "Links" instead of "All Links")
You just have set the name of the `$menu_slug` exactly the same as the parent slug.
stackexchange-wordpress
{ "answer_score": 3, "question_score": 3, "tags": "plugin development, admin menu" }
Can't Find a "Most Popular Tags" Hack Anywhere If anybody knows where to find a most popular tags hack, I would be forever grateful. I've searched and searched to no avail.
check this plugin: < And/ or see this codex: <
stackexchange-wordpress
{ "answer_score": 1, "question_score": 0, "tags": "tags, hacks" }
Notify commenters about new replies Is there a plugin to notify commenters of one post to receive emails about new comments made on that post? Only commenters who entered emails will be notified.
check this plugin out: <
stackexchange-wordpress
{ "answer_score": 2, "question_score": 3, "tags": "plugins, comments, email" }
Customizing Wordpress the_title with add_filter I'm trying to create a custom wordpress title for a posts made under a custom post. Basically, its a version changelog for an application. I would like to only input the version number in the title field, and the output has to be standardized with a string accordingly. My custom post type is 'custom_version' and the title output that I'm looking for is "Application has been updated to version ". I've understood that this can be achieved using add_filter and I've tried playing with this code for days now, but I'm not really a PHP Pro so help is much appreciated :) Here's the code: add_filter('the_title', 'new_title'); function new_title($title) { global $post, $post_ID; $title['custom_version'] = 'Application has been updated to v'.$title; return $title; }
The issue is that you are mixing up the `$title` variables. `$title` is the parameter passed to the `new_title` function, but then you use it as an array: `$title['custom_version']`. Try this: add_filter('the_title', 'new_title', 10, 2); function new_title($title, $id) { if('custom_version' == get_post_type($id)) $title = 'Application has been updated to v'.$title; return $title; } I'd also highly recommend prefixing your function with a unique prefix because you may run into another plugin/theme using a function called `new_title`, which will reek havoc!
stackexchange-wordpress
{ "answer_score": 10, "question_score": 3, "tags": "filters" }
Between functions.php (theme), widgets, and plugins, which is loaded first? Customer asks if a specific carousel plugin he uses can be widgetized. That means I should create a widget inside functions.php which calls the plugin's function. That means that the plugin's code has to be loaded first so that the function be available to WordPress when the functions.php file is loaded, right? Would that work?
The plugins are loaded right before theme (yes, I've been looking for excuse to use this): !enter image description here However it is wrong to think about either as point of code execution. For most cases everything should be hooked and executed no earlier than `init` hook. According to Codex widget registration with `register_widget()` should be hooked to `widget_init`. Because of that order of load doesn't matter for this case, you will have everything loaded by the time widget needs it in any case.
stackexchange-wordpress
{ "answer_score": 219, "question_score": 94, "tags": "plugins, functions, theme development, widgets" }
Implementing a tricky wordpress menu (nested categories + thumbnails) I'm trying to make a layered wordpress menu, out of categories. Here's how it's going to look: !enter image description here I have no clue how to develop this, can't do it with `get_posts` (not sortable by parent/children), or `wp_list_categories` (can't pull thumbnails). Also, I have to assign thumbnails to categories somehow. Is there an easy way to implement something like this with wordpress?
although @roikles offers a way to do it, I don't think it is very flexible as you will have to go back in the code when you want to add a new category. Another way of doing it can be to add the image of the subcategory as the description of the subcategory. To be able to do so, you will first need to allow XHTML in category descriptions. Add this line to your `functions.php`: remove_filter( 'pre_term_description', 'wp_filter_kses' ); Then you can echo that description with `wp_list_categories`
stackexchange-wordpress
{ "answer_score": 1, "question_score": 1, "tags": "categories, php, menus, thumbnails" }
Using an "IF" statement based on the existence of custom field I wish to use a function which is run only when a specific custom field is available. Something like: if (custom_field_x_exists("name_of_the_custom_field")) : <Do some things>; endif; How might it be done?
I think this should help if ( get_post_meta( $post->ID, 'name_of_the_custom_field', true ) ) : // Do something endif;
stackexchange-wordpress
{ "answer_score": 1, "question_score": 0, "tags": "php, custom field" }
What's an easy way of sorting custom post types manually? I'm using the bbpress plugin. It has a custom post type called **forums**. I used to sort posts by changing its publishing date. But you can't do that with this custom post type. Any suggestions?
i used this code to create custom post template for specific post type define(SINGLE_PATH, TEMPLATEPATH.'/single'); function product_single_page_template($product) { global $wp_query, $post; $type = get_post_type(); if ($type==true) if(file_exists(SINGLE_PATH . '-type-' . $type . '.php')) return SINGLE_PATH . '-type-' . $type . '.php'; return $product; } add_filter('single_template', 'product_single_page_template'); you can do the same with categories or for non single pages just as well.
stackexchange-wordpress
{ "answer_score": 1, "question_score": 0, "tags": "custom post types, sort" }
Stats for a wp powered intranet I'm currently building a simple intranet powered by WordPress. I need to show the stats (most read articles, user logins, etc..) to the administrator, but I can't use google analytics as the install is on a VPN without internet access. Do you know any reliable plugin to record and show stats on a local install of WordPress?
I would recommend installing Piwik on your intranet using one of their plugins, though it will work just fine as a stand alone. < <
stackexchange-wordpress
{ "answer_score": 2, "question_score": 1, "tags": "plugin recommendation, local installation, statistics" }
How to list the categories by custom taxonomy created? I have created a custom post type named 'projects' with link custom taxonomy named 'projects'. I have added the five different project categories with this project taxonomy with two level of hierarchy custom post type ui. I tried to find function to get these five categories with taxonomy name 'projects' but i did not get the solution. Can anyone help me out how to get the list of these categories created with taxonomy named 'projects'. Any help will be appreciated. Thanks in advance
You will want to use `get_terms`. The following code show you how to access the terms. Please see the Codex page for get_terms for more information about the args that you can send to the function. I also show all of the data that is returned in the array of objects. // Set your args $args = array( 'hide_empty' => 0 // Show terms that are not associated with any posts ); // Get the terms $projects = get_terms('projects', $args); // Loop through and use terms foreach($projects as $project) { echo 'Term ID ' . $project->term_id; echo 'Name: ' . $project->name; echo 'Slug: ' . $project->slug; echo 'Term Group ' . $project->term_group; echo 'Term Taxonomy ID: ' . $project->term_taxonomy_id; echo 'Taxonomy: ' . $project->taxonomy; echo 'Description ' . $project->description; echo 'Parent: ' . $project->parent; echo 'Count: ' . $project->count; }
stackexchange-wordpress
{ "answer_score": 0, "question_score": 0, "tags": "plugins, custom post types, custom taxonomy" }
Page URL not working due to physical directory I have a page named < and it worked fine. I have now added a physical "whitepapers" directory and has since broken my permalink for the page. I realize that it has something to do with content negotiation after reading this post but the fix did not work.
For those still looking for an answer, have a look at WP Page and Subdirectory with same name Basicalli I will have to rename the folder on my server.
stackexchange-wordpress
{ "answer_score": 0, "question_score": 0, "tags": "permalinks, directory" }
Wordpress: Permalinks link to old names I'm trying to activate permalinks on my Wordpress installation. When I activate them my menu links point to page names that have changed sometime ago which result in a 404. I don't really understand how I can configure this. When I edit the menu in the menu settings the names are the current ones. I use qtranslate. Can this be the source of the problem?
I found it. The box to edit the title had been invisible. I made it visible with the according checkbox in the options bar on the top.
stackexchange-wordpress
{ "answer_score": 0, "question_score": 0, "tags": "permalinks" }
Counting the number of posts (custom post type) Query problems I'm trying to count the number of total posts of a custom post type "jobs". My query just returns "0" when I know there are posts. I don't think it is checking that the post type has posts, but I'm clueless as to why... any ideas? <?php $jobs = new WP_Query(array( 'post_type' => 'jobs' ));?> <?php if ($jobs->have_posts()) { $count_posts = wp_count_posts()->publish; if ( $count_posts == "1" ) { echo "<h2>There is currently one vacancy...</h2>"; } else { echo "<h2>There are currently $count_posts vacancies...</h2>"; } } else { ?> <h2>There are currently no vacancies.</h2> <?php } ?>
The `wp_count_posts` function has parameter `$type` for post type to count, you should use this parameter if you want to get number of jobs like so: $count_posts = wp_count_posts( 'jobs' )->publish;
stackexchange-wordpress
{ "answer_score": 54, "question_score": 17, "tags": "custom post types" }
Setting Custom Sort Order of Posts within a Category I've got this category setup that includes several posts. By design it's not a blog, but a staff listing. Currently all of the staff members have their own posts with the category. I'd like to be able to sort the order they are displayed in in their parent category. How do I go about doing this in the most user friendly manner? My client may want to change this sorting order in the future, especially when staff members leave or new ones get hired. Any and all help will be greatly appreciated. < To expand on this: In the link I've provided you'll be taken to a category page I made called /faculty/. In this category page I have several posts listed. Wordpress automatically lists them in the order they were created. With the most recently created post being listed first. I want to list them in my own custom order. How do I do this?
Now that I have a better understanding of the issue, I would recommend using custom fields to sort your posts. You can have a custom field (e.g., "order") and use it to indicate the order of your posts. You then need to use a custom query to order these posts when they are displayed. You can use a custom query like the following: $args = array( 'meta_key' => 'order', 'orderby' => 'meta_value', 'order' => 'ASC' ); $custom_query = new WP_Query(); $custom_query->query($args); if($custom_query->have_posts()) { while($custom_query->have_posts()) { $custom_query->the_post(); // Do the loop stuff } } Please see the WP_Query class page for more information about all of the arguments that you can use to create custom queries.
stackexchange-wordpress
{ "answer_score": 8, "question_score": 6, "tags": "posts, categories, customization, sort" }
Is there any way of making post tags (or custom post type tags) pop up as suggestion as in StackExchange sites? In any SE site, there are suggestions that pop out when you are writing in the **Tag** field. Is there any way of doing something similar in Wordpress? (a simple vertical list is enough). (Maybe helped with jQuery).
It should do this by default if there are tags to suggest, but I think there's a little bit of a delay before the suggestions show. You can also choose from your most used tags, which some might find easier to use.
stackexchange-wordpress
{ "answer_score": 2, "question_score": 0, "tags": "tags" }
Best way to transfer Wordpress install to root of directory when I'm ready to launch? I'm currently designing a site for a client and I don't want anyone to be able to navigate to the homepage and see it. So currently the site is located in a subfolder of the main domain. Like so: < What steps do I need to take to move the site to simply < when we are ready to launch it? Or, is there a way to move it there right now, while I'm still developing it, and simply hide the homepage from the outside world while I can still see it? The only reason I decided to develop it in a subfolder like /beta/ was because I didn't know how to stop other people from seeing the homepage while still allowing myself to see it. What's the easiest, simplest answer here? Your help is greatly appreciated!
See Moving WordPress « WordPress Codex, or, keep all WP files (except index.php) in /beta/ and see Giving WordPress Its Own Directory « WordPress Codex. Use WordPress › Absolute Privacy « WordPress Plugins to make WP private until launch.
stackexchange-wordpress
{ "answer_score": 1, "question_score": 0, "tags": "directory" }
Javascript Helpers Are there any WordPress specific Javascript functions that could be used as helpers when writing custom code? I am thinking specifically of one that would pull back the base URL of your install, but any helper functions built into WordPress would be nice to know.
WordPress installs with a number of libraries/classes/plugins/etc that you can enqueue and use. For base url specifically, or any vars in general you need to access from javascript, use the api php functions, then pass it to your javascript via wp_localize_script.
stackexchange-wordpress
{ "answer_score": 6, "question_score": 2, "tags": "javascript" }
Where to save common libraries? I have a multiple-site WordPress install. I have decided to centralize as many of my libraries as possible into one spot, for obvious organizational reasons, and in order to reduce bloating. Many of those libraries can be used both in plugins and themes. My first idea is to create a ' ** _myLibs_** ' (or other name) directory inside **_wp-content_** where I would save all those libraries. Anybody has a better idea? Would there be any reasons NOT to do this?
I would recommend creating a plugin that holds all of your libraries. In the main plugin file, set a constant that defines the path to the plugin folder so you can easily include the files with your other plugins/themes.
stackexchange-wordpress
{ "answer_score": 2, "question_score": 2, "tags": "code, directory, library" }
Removing "HTTP://" From the_author_meta? By default WordPress prints http:// in front of URLS users add in their profile, which are called using the following code: <?php the_author_meta('user_url'); ?> Could somebody provide me the code to strip these URLS of "HTTP://" by default? (While still working as a link and not touching WP's backend... I assume this could be a function?)
Assuming that the author's id is `$author_id`, the following code should work. You can of course use this to create your own function. <?php $url = get_the_author_meta('user_url', $author_id); ?> <a href="<?php echo $url; ?>"><?php echo str_replace(' '', $url);?></a>
stackexchange-wordpress
{ "answer_score": 0, "question_score": 0, "tags": "author, user meta" }
Force WordPress to NOT display the manual excerpt I'm forced to use manual excerpts on a number of my posts to integrate them with a shortcode plugin. However, this is interfering with how they're being displayed on an archive page (using a page template). Is there a way to force WordPress to display an automated excerpt (ie, the first 80 words) on one page template only?
You can utilize the `wp_trim_excerpt` filter. In your callback function that filters the the excerpt text, you can test for the presence of a certain template; then, if that template is being used, you can go ahead and alter the excerpt in any way that you see fit. In order to determine which template is being used, see this clever solution: Get name of the current template file. Let me know if this helps or if you need more.
stackexchange-wordpress
{ "answer_score": 2, "question_score": 0, "tags": "templates, archives, page template, excerpt" }
Inserting custom fields into new-post.php without using the Custom Fields Template plugin? I know there are a few plugins (Custom Fields Template seems to be the most popular one) that lets me insert custom fields into the new-post.php template. But I'm wondering if I can add in a few fields without using a plugin -- just as a mock-up. Do I have to go into the core?
This article will get you there: <
stackexchange-wordpress
{ "answer_score": 0, "question_score": 0, "tags": "custom field" }
What does a security risk in a plugin look like? My server was hacked this weekend. By the Russians! Of the 50+ domains on my server, every single one had a hacked .htaccess file which was redirecting search results and a few other things to a russian site. I'm assuming that one of the many, many wordpress installs has a plugin with a security flaw. Two questions: 1. Is it possible for a security hole in one plugin to allow someone access to other sites on the same server? 2. What would a security flaw look like that might give someone access to the .htaccess file a directory or two above? It's possible that the issue was someone else, that Dreamhost (my host) has bigger issues. But, I'm exploring the option that it's my fault. Thoughts?
**Personal Opinion:** I had the same thing with (mt) mediatemple twice last year. They told me/us that it was a wordpress issue, but it wasn't. I heard the same from dreamhost last year. So: don't think about it too much, just remove the hack and blame your host (again). Anyway: You could read this thread. If your DB got "infected": There's also a link to the plugin I wrote to remove the inserted links from my database. Give it a try.
stackexchange-wordpress
{ "answer_score": 4, "question_score": 4, "tags": "plugins, htaccess, security" }
Post migration from one site to another site in a network I have a wordpress network site. I have many sites in my network. Lets say i have two subsites like wordpress.mysite.com,joomla.mysite.com. If the user post wordpress related topic in joomla site then i would like to migrate it from joomla to wordpress. Just like stackoverflow. Is there any good multisite plugin available for this feature?. Thanks
I couldn't find best solution for this question. If anyone have this question as mine then you may check this plugin. This is not the best one. But just a recommendation. < It actually duplicate the post. Thanks
stackexchange-wordpress
{ "answer_score": 0, "question_score": 0, "tags": "multisite, migration" }
My website is slow on the initial load I am creating my first website in wordpress, and I have noticed some strange behavior. The website is really slow on the initial load. When I open the website after some time of inactivity, let's say an hour, the site loads extremely slow, over 5 sec. After that the website is just fast. Even when I close the browser and open again the website stays fast. When I switch to another browser, I have the same problem. Initial load is slow, after that the page works as usual. Anyone know something I could do. I have disabled all plugins and still the same problem, any know what I can do. Profiling with firebug and Yslow is not really an option, because I can not get good results. I can only test this once every hour.
Maybe your PHP is running per CGI or FastCGI in a separate process that shuts down after a while of inactivity. Does it change if you register at an uptime monitoring service? A cache plugin like W3 Total Cache may help too.
stackexchange-wordpress
{ "answer_score": 0, "question_score": 0, "tags": "optimization" }
Thumbnail for categories / taxonomies plugin? I'm looking for a nice way to attach an image as a thumbnail to a category. No plugin that I found does this. I have a category loop and it would nice to display a category thumbnail, not just the name and description.
Use the plugin Taxonomy Images by @mfields.
stackexchange-wordpress
{ "answer_score": 1, "question_score": 0, "tags": "categories, thumbnails" }
Custom menu styling I'm trying to style a custom menu here so that I can let other people manage this site alongside myself. What I'm trying to do is remove the text for the top level links while leaving the `a` as a block so the links are clickable, however when I try and remove the text using `text-indent: -999em;` (which I know isn't the neatest way of doing it) it recurses down the menu and hides all the the other links. Can anyone suggest any neat ways of hiding the text?
I think you can use the text-indent for this level, but you must set the text-indent for all a -tags of the class sub-menu also set to 0, not -999px. Example: #menu-main-navigation .link-experience a { display: block; height: 63px; width: 167px; text-indent: -999px; } .sub-menu a { text-indent: 0px !important; }
stackexchange-wordpress
{ "answer_score": 1, "question_score": 0, "tags": "menus, css" }
wp_set_object_terms not working inside loop I have the following code $genres= array('action', 'comedy', 'horror'); foreach($genres as $genre){ $ret = wp_set_object_terms( $postId, $genre, 'genres'); } But this code associates only horror as the genre. When I checked the DB too, I don't have a record for action and comedy. How do I associate all the three with my genre? Thanks in advance.
You can pass an array of terms to `wp_set_object_terms`, there is no need for the for each: $genres= array('action', 'comedy', 'horror'); $ret = wp_set_object_terms( $postId, $genres, 'genres');
stackexchange-wordpress
{ "answer_score": 3, "question_score": 0, "tags": "terms" }
overwrite a plugin function in functions.php need to customise a plugin function but would rather not edit the plugin itself so updates wont remove the custom changes. function iss in a class called _UserAccessManager_ and the function is; public function showGroupMembership($link, $postId) { $uamAccessHandler = &$this->getAccessHandler(); $groups = $uamAccessHandler->getUserGroupsForObject('post', $postId); if (count($groups) > 0) { $link .= ' | '.TXT_UAM_ASSIGNED_GROUPS.': '; foreach ($groups as $group) { $link .= $group->getGroupName().', '; } $link = rtrim($link, ', '); } return $link; } is this possible? OR can i affect it with a filter? Any help appreciated! Dc.
I'm afraid you cannot alter the output of this function unless you directly modify the plugin code. The plugin author hasn't given you any filter to use. So what can you do about it? 1. Continue to alter the plugin file and update each time the plugin updates. 2. Ask the plugin author nicely to add a filter to this function. 3. Make a fork of the plugin.
stackexchange-wordpress
{ "answer_score": 0, "question_score": 0, "tags": "plugins, functions, pluggable" }
Isn't the way posts are displayed very unefficient? I'm pretty much a WP newbie, and I've noticed that in a lot of themes, there is the exact same code for displaying posts in three different places (single.php, archive.php, index.php etc) This just bugs me. It doesn't seem right to me, a programmer always trying to code as efficiently as possible. What is the best way to generalize the layout for posts, preferably as a WordPress integrated/native function?
you could move the loop content into its own file and share that between the different template files using get_template_part()
stackexchange-wordpress
{ "answer_score": 2, "question_score": 0, "tags": "posts, functions, design" }
Help with adding conditional title tags to header.php From an SEO perspective, i'm trying to add conditional title tags to my WP theme such that it echos a piece of text based on various categories. Assuming that my category id's are 1, 2, 3, 4 Then i'd like to add Title 1 if category id = 1, title 2 if category id = 2 and so on. Could someone assist in the correct php syntax to implement this. Thanks.
See codex page for category conditional tags - < You can use them like so: <title> <?php if ( is_category( '1' ) ) echo 'This is the news category'; ?> </title>
stackexchange-wordpress
{ "answer_score": 0, "question_score": 0, "tags": "conditional tags" }
Why doesn't my page know it's a page (won't return true for is_page())? I have a page with the slug `blog`. Mysite.com/blog correctly renders from the template file page-blog.php. However, it does not execute footer code from my theme that's conditioned on `is_page('blog')`, nor does it have an "Edit Page" link in the Admin bar. I also have a custom post type called `blog`, but this page doesn't execute code for `is_post_type_archive('blog')` either. In the admin bar, there is no "Edit Category" link or "Edit [Anything else]". This is the info the WP Debug plugin gives me when I load the page: Request: blog Query String: pagename=blog Matched Rewrite Rule: (blog)(/[0-9]+)?/?$ Matched Rewrite Query: pagename=blog&page= What could be the problem?
The problem was due to a secondary loop in the page—before this loop, the page knows it's a page; but after the loop (and in the footer, where the Admin Bar and my code would be rendered), the page thought it was the last post of the secondary loop. Neither wp_reset_query() nor wp_reset_postdata() worked; I am guessing this has to do with the fact that I use $wp_query as the name of the secondary loop (so that I could use the loop.php template file to display the posts). Here's the code that worked: $temp_query = clone $wp_query; $wp_query = new WP_Query( 'post_type=publication&posts_per_page=5' ); get_template_part( 'loop' ); /* get_template_part( 'loop' ) only seems to work if the query is in $wp_query */ $wp_query = clone $temp_query; ?> Here's the link in the codex that the clone $wp_query technique comes from: <
stackexchange-wordpress
{ "answer_score": 0, "question_score": 0, "tags": "permalinks, wp query, pages" }
Why do some core functions get wp_ while others do not? What's the rule? Is there some guideline or rationale behind why some WP code functions are prefixed with `wp_` ? eg: `wp_insert_post()` vs. `update_post_meta()`
This makes not that impressive answer, but - **none**. `get_` is suffix usually means function returns something, `the_` that function echoes something. `wp_` doesn't carry technical meaning and inconsistency in naming is from many developers participating and lack of movement to unify (moving forward is considered more important than major cleanups of older stuff to make it neat).
stackexchange-wordpress
{ "answer_score": 8, "question_score": 15, "tags": "core" }
You do not have sufficient permissions to access this page After long time am here,I have one question. I Installed my wordpress in localhost and i moved to live,while i forgot the admin password,so i reset it by phpmyadmin(using md5).now i try to login by using with correct password it's redirect to This page and shows **You do not have sufficient permissions to access this page.** please anyone help me to solve this problem.
Occasionally I've seen issues doing a manual reset of the password if salts have changed, or if there was an issue with the account before the reset. Some things to try: * Are you sure you reset the password for the main admin account, usually ID #1? Trivial, I know, but has happened to me in the past. * Try using the Emergency Password Reset Script, as it works a little better than a manual reset. * Try changing the salts in wp-config.php and reset the password again, see if it clears out some cookie issues you may be having. Most likely your problem can be traced to cookie issues if it is accepting the password but not letting you in. Clear all your cookies out as well.
stackexchange-wordpress
{ "answer_score": 3, "question_score": 2, "tags": "redirect, login, permissions" }
Dynamic page outside Wordpress I have some data that I'm pulling from an XML source and would like to display it in Wordpress. One solution would be to take the static markup that my theme generates and spaghetti-code my page with some PHP that grabs the data from the XML and prints it in the page. Easy enough, but now every time I make a change to the theme I have to re-apply it to this page. Is there a more elegant solution that would allow me to inherit the whole site look n' feel and just append my data to it? Thanks
I would make a plugin out of the code that you are using to pull the XML. I've done this before for a client that was using a calendaring system that was a set of PHP files. I wrapped the calls to the calendar files in a plugin, and just called what I needed to from there. This preserved the look and feel of the site without extra work there, and used WordPress's native capabilities. It's fairly easy to take an existing set of code and wrap it as a plugin, and then you can use the methods of that plugin in your theme files. You could for example make a page to house the data, make a page-specific theme file that outputs (or not) the content of that page, and also use the theme file to run the methods for pulling in the XML data via your plugin. _Resources for writing (or wrapping code into) a plugin:_ * < * < * < * <
stackexchange-wordpress
{ "answer_score": 1, "question_score": 1, "tags": "custom post types, php" }
Writing a link cloaking plugin I do not want to use any existing plugin. For WordPress-less projects, I would specify a PHP file in `href` <a href="FileOnMySite.php">Click here</a> `FileOnMySite.php` will be like header('Location: But I'll definitely get `header already sent` in WordPress. * Is it possible to avoid `header already sent`? * Any other cloaking method that you know will work best with WordPress? Thanks!
I don't see why the same method can't still work in a WordPress site. If you specifically specify a file to link to that is a valid PHP file, available on your server, then it will still hit that file _instead_ of hitting WordPress. If you are having issues with this working, make sure you don't have any rewrite rules interfering in your .htaccess file.
stackexchange-wordpress
{ "answer_score": 1, "question_score": 0, "tags": "php, redirect" }
Get excerpt using get_the_excerpt outside a loop I have a code that call `get_the_title()` and it works, but `get_the_excerpt()` return empty. How can i make it work? This code is inside a plugin called "WP Facebook Open Graph protocol". Here's the part i want to change: if (is_singular('post')) { if (has_excerpt($post->ID)) { echo "\t<meta property='og:description' content='".esc_attr(strip_tags(get_the_excerpt($post->ID)))."' />\n"; }else{ echo "\t<meta property='og:description' content='". [?] ."' />\n"; } }else{ echo "\t<meta property='og:description' content='".get_bloginfo('description')."' />\n"; } Here, `has_excerpt` always fail, and `get_the_excerpt($post->ID)` don't work anymore (deprecated). So, how can i display the excerpt there? ps: I'm using "Advanced Excerpt" plugin as well
got it using `my_excerpt($post->post_content, get_the_excerpt())` and using the `my_excerpt()` function from Using wp_trim_excerpt to get the_excerpt() outside the loop
stackexchange-wordpress
{ "answer_score": 5, "question_score": 32, "tags": "loop, excerpt" }
WordPress appends the_content filtered text inside last paragraph tag of content (rather than after it) Using WordPress version 3.2.1 I've noticed that when I use this filter: add_action('the_content', 'myFunction', 0); The content editor places the content written from "myFunction" **within** the last paragraph tag of the content. How can I force the WP to append the code **after** the last tag? For example, if my content is... <p>This is a paragraph</p> And the "myFunction" routine appends "And this is some extra text" to the_content, the end result in the browser becomes: <p>This is a paragraphAnd this is some extra text</p> Although I want it to be: <p>This is a paragraph</p>And this is some extra text
Your filter is being applied before `wpautop`, the filter which wraps all of the paragraphs in WordPress content with `<p>` tags. A value of zero for priority means that your filter will be applied **first** , before all other formatting filters. Try applying your filter later - with a priority higher than 10, the default, which is where `wpautop` is applied. So, add your function like this: add_filter( 'the_content', 'myFunction', 11 );
stackexchange-wordpress
{ "answer_score": 3, "question_score": 0, "tags": "the content" }
Hooks to run after a core upgrade? Are there any hooks for running plugin code after a core upgrade? Specifically, I'm running into issues that a users wp-admin column choice in the 'Screen Options' are modified after an upgrade - I believe if they choose "auto". After doing an svn sw I lost my "publish" box from the post/pages page. This is causing some major issues in my wp-admin skin.
Check the filter `update_feedback`, he works after the update and you can use for all stuff after an update. An example plugin can you find in this trunk.
stackexchange-wordpress
{ "answer_score": 1, "question_score": 0, "tags": "plugins, hooks, upgrade" }
Giving Multiple Authors Access to a Plugin's WP.org Repo A plugin I've released has a collaborator. So I put them into the readme.txt file and they show up on the plugin page and all that. Does doing this automagically give them access to the SVN repository for the plugin? Or is there some other process to go through to get them access? Or is only one user allowed per repo? Thanks!
As long as you use a valid WordPress.org username in the `Contributors:` tag in `readme.txt`, then yes: once the `readme.txt` is parsed by Extend/SVN, then the specified username _automagically_ has SVN-commit access to the Plugin. Note: I know that it works for the **`Contribuors:`** tag, as I am such a contributor on a couple Plugins. If you're using a **`Collaborators:`** tag, I am unsure of how such a tag gets parsed. ## EDIT And I mis-spoke somewhat. @Otto reminds me that committers must also be added, via the `plugins\plugin-name\advanced` page. So, props Otto; I had completely forgotten about that part! So, there's really no _automagic_. Go to `wordpress.org/plugins/plugin-name/advanced`, look for the **Committers** heading, add a WPORG username to the text field, and click "Add Committer".
stackexchange-wordpress
{ "answer_score": 14, "question_score": 12, "tags": "plugins, plugin development" }
get_posts assigned to a specific custom taxonomy term, and not the term's children Say I have the following taxonomy terms: Term 1 Term 1.1 Term 1.2 Term 2 Term 2.1 How can I get only posts that are assigned to Term 1 and not include those that are assigned to Term 1.1 or Term 1.2? For example: $pages = get_posts(array( 'post_type' => 'page', 'numberposts' => -1, 'tax_query' => array( array( 'taxonomy' => 'taxonomy-name', 'field' => 'id', 'terms' => 1 // Where term_id of Term 1 is "1". ) ) ); is also giving me posts that have Terms 1.1 and 1.2 assigned. Thanks.
In looking at the WP_Tax_Query class in /wp-includes/taxonomy.php, I found that there is a 'include_children' option which defaults to true. I modified my original get_posts() call with the following, and it works great: $pages = get_posts(array( 'post_type' => 'page', 'numberposts' => -1, 'tax_query' => array( array( 'taxonomy' => 'taxonomy-name', 'field' => 'term_id', 'terms' => 1, /// Where term_id of Term 1 is "1". 'include_children' => false ) ) )); List of more query parameters: <
stackexchange-wordpress
{ "answer_score": 60, "question_score": 26, "tags": "custom taxonomy, terms, get posts, hierarchical" }
Linking text within textarea of custom meta box I'm using 'Meta Box Script for WordPress' to create custom meta boxes and everything is working great...except the following: We have a textarea that we want to act, basically as another WP the_content (It's for hidden content that is only shown once a link to show hidden content is clicked). My end-users want to be able to put something like the following in the box: `This is some pretty <a href="#">linked text</a>.` I'm using the following code in my template to show the custom meta box content: `<?php echo get_post_meta(get_the_ID(), 'oc_code', true); ?>` The content it shows is exactly like this (I'm guessing it's not parsing, if that's the correct phrase, the URL): `This is some pretty <a href="#">linked text</a>.` What can I do to show a clickable href within the template without adding more custom fields/meta boxes? I was looking at esc_attr, esc_url, etc. but don't know that that is the solution. TIA!
I finally found the answer to this and am posting it here in case someone else needs the answer. Just put the following in your theme file. `<?php` `global $post;` `$variable_name = get_post_meta($post->ID, 'custom_metaBox', true);` `echo html_entity_decode( $variable_name );` `?>` Change the variable name and custom_metaBox to your specific values and voila, functioning HTML code.
stackexchange-wordpress
{ "answer_score": 1, "question_score": 1, "tags": "php, functions, metabox" }
By registering always make uppercase the first letter of the login When a New User to register on my site ... I would like that in your login, the first letter always be capitalized. ( uppercase letter ) Forcibly. Does anyone have any idea how to do this?
You can possibly add a filter to `sanitize_user` and return `ucfirst($username);`, I haven't tried it though to verify if it will work.
stackexchange-wordpress
{ "answer_score": 0, "question_score": 1, "tags": "login, user registration" }
Explode() expects a string I currently am getting this error: Warning: explode() expects parameter 2 to be string, object given in D:\...\portfolio.php on line 12 Here is my portofolio.php: <?php $current = get_the_category(); $current_id= $current[0] ->cat_ID; $categs_list = get_category_parents($current_id); $pieces = explode("/", $categs_list); //this is line 12. $category_name = strtolower($pieces[0]); $categs = get_cat_id($category_name); ?> Any Ideas? PHP is not my forte.
Let's start from the top: 1. `$current = get_the_category();` This returns an **array of objects** , one object for each category. 2. `$current_id= $current[0] ->cat_ID;` This returns an **object** , the first object in the previous array 3. `$categs_list = get_category_parents($current_id);` This returns a **string** , but _only if the current category has parents_ ; otherwise, it returns whatever was passed to it: which was an **object** (See where the problem is yet?) 4. `$pieces = explode("/", $categs_list);` This expects a **string** , but is returning an error, because it is being provided an **object**. **So, Conclusion:** You are calling this code in a Post that is in a category that **doesn't have any parents**. You need to write some fallback code to account for this occurrence.
stackexchange-wordpress
{ "answer_score": 1, "question_score": 0, "tags": "categories, php" }
next gen gallery thumbnail problem Does anyone know why nextgen gallery doesn't support thumbnails with png transparency??? I'm working on this project < And as you can see the slideshow work the image properly, however the thumbnails have a black background. I'd really appreciated any kind of help :)!
since the site has a white background, a quick workaround could be to save the pngs as jpeg with white background? this thread mentions a possible solution: * wordpress dot org/support/topic/plugin-nextgen-gallery-problems-with-png-transparency-thumbnails?replies=9 this has an unpdated solution: * wordpress dot org/support/topic/plugin-nextgen-gallery-png-thumbnails-with-transparancy-problem-1?replies=5 and this thread suggests saving as 24bit png's rather than 8bit * wordpress dot org/support/topic/nextgen-gallery-transparent-images-showing-black-background-with-resize?replies=8#post-1921440 ps cant post all links as dont have enough rep :-( if an admin can amend i'd be grateful
stackexchange-wordpress
{ "answer_score": 0, "question_score": 0, "tags": "plugin nextgen gallery" }
Homepage slider not using correct images I am currently in the process of starting my first blog. Currently, I am stumped. I have a homepage slider that refuses to work with me. The documentation for the theme I am currently using is located here. The problem I'm having is I can't figure out how or what the slider decides to use as an image and then the caption in the slider and how to add more to the slider. I would like it to be a the larger picture 970x360 or something like that with the caption beneath it with 3 or more pages to slide through, not have the description overlayed on it. I've gone into the theme option and messed around to no avail. I'm am lost as to where to go from here. For the visuals on the issues please see my blog.
I was able to solve the problem by hard coding. The documentation was to vague and not properly detailed for me to figure out how to use the settings. Here is the code: <!-- BEGIN SLIDER --> <div id="slider"> <a href=" class="alignnone size-full wp-image-254" title="Android Apps" src=" alt="" width="960" height="370" /></a> <a href=" class="alignnone size-full wp-image-255" title="Tutorials" src=" alt="" width="960" height="370" /></a> <a href=" class="alignnone size-full wp-image-256" title="Ideas" src=" alt="" width="960" height="370" /></a> </div> <div style="width:960px; margin:0 auto; background:url( 0 0 no-repeat; height:50px;"></div> <!-- END SLIDER -->
stackexchange-wordpress
{ "answer_score": 0, "question_score": 0, "tags": "theme development" }
wordpress multisite, how to keep user on subdomain throughout registration process? I am running wp subdomain multisite in combination with domain mapping. This means I can create a new subdomain site xyz.site.com and map the domain name 'xyz.com' to that site. The problem I have is someone clicks 'register' on the subdomain mapped site 'xyz.com' and they are sent to site.com to register. This is VERY confusing to many people and I'm getting tired of the complaints. How do I setup wp multisite, so that if a person wants to register on a subdomain site, that they do not leave that site at any point? _I use multisite to host multiple client sites, all which have their own domain names. I simply 'map' the domain name to their subdomain site. This means that users who come to one clients site to register, are being sent to the primary site to register, which is just plain wrong and confusing_
What @petermolnar suggested also redirects your users to the main site if they want to register (I've tested this but feel free to make use of it. It's good practice). What you need is a registration/login/edit-profile plugin for the front end: < It's shortcode based so all you have to do is redirect your users to the register page where you have [wppb_register] shortcode. Create register/login/edit-profile pages for each site you need and that's it.
stackexchange-wordpress
{ "answer_score": 3, "question_score": 7, "tags": "multisite, users, user registration" }
Why doesn't the "Remember Me" checkbox work for me on a live website? Only works on a local server environment If I check "Remember Me", and then log out, my login and password are **not** remembered. I've tested this on many WordPress sites running WP 3.2.1 on a server here in NZ and also on a completely different server hosted in the US. It doesn't appear to be a problem with just my browser, as quite a few people have tested this for me. Although I have tried clearing all cookies, cache etc. It **does** however work locally with a MAMP setup on OS X. Is there something I need to install on the server to get this working? I presume it's using session cookies? Any ideas?
Check your browser settings. You can change the settings for size and time to keep the cookies.
stackexchange-wordpress
{ "answer_score": 0, "question_score": 0, "tags": "login, cookies" }
How to remove "Read on" content in the_excerpt? I know the_content has the handy dandy $strip_teaser argument that lets you set whether there is "continue reading" text. No such luck for the_excerpt... I would like to just get rid of it. I had previously tried to just shorten it to Read on but that didn't seem to work either. function beernews_auto_excerpt_more( $more ) { return ' &hellip;' . __( 'Read on <span class="meta-nav">&rarr;</span>', 'twentyeleven' ) . '</a>'; } add_filter( 'excerpt_more', 'beernews_auto_excerpt_more' ); Theme is Twenty Eleven.
If you're using the Twenty Eleven theme I think you need to remove that theme's filter before you can define your own: remove_filter( 'excerpt_more', 'twentyeleven_auto_excerpt_more' ); _edit_ building from t-p try this: add_action( 'after_setup_theme', 'my_child_theme_setup' ); function my_child_theme_setup() { remove_filter( 'excerpt_more', 'twentyten_auto_excerpt_more' ); } In case you are using twentyeleven, use "twentyeleven_auto_excerpt_more" instead of 'twentyten_auto_excerpt_more'
stackexchange-wordpress
{ "answer_score": 2, "question_score": 0, "tags": "excerpt" }
WordPress in a sub directory but not images I have followed this tutorial from WordPress and managed to get everything to work. I have installed WordPress in a subfolder called `/wordpress`. The problem that the images I uploaded show the `/wordpress` directory name in the URL. Can that be removed without moving the uploads folder?
Go to _Settings > Media_. Enter the option _Full URL path to files_ according to the file structure on you server.
stackexchange-wordpress
{ "answer_score": 0, "question_score": 1, "tags": "directory, uploads" }
how to add the same Widget twice to a sidebar? I have a sidebar and would like to fill it like this: [Text] [Some other Widget] [Text] but I can add the Text widget only once to the Sidebar. What can I do to be able to add it more than once?
It should be as simple as dragging another text widget from the active widgets into the sidebar and copying the desired text in again. Unless you are having complications?
stackexchange-wordpress
{ "answer_score": 2, "question_score": 0, "tags": "widgets, sidebar" }
Creating / Editing a post from within site template I am developing a website that will allow multiple users to author short posts (Kind of like a job board) and I want to know how they can author or edit these posts from within the site template (Ie; without having to enter the dashboard). Any advice or points in the right direction would be great
Try the Font-End Editor. Or you can try some of these. 8 WordPress Plugins that Enable Posting and Editing From the Front-End I have never used any of these plugins, so I cannot say as to how well they will perform.
stackexchange-wordpress
{ "answer_score": 0, "question_score": 0, "tags": "posts, templates, dashboard" }
The_content display a different content from a previous loop I have custom template for my homepage. If i just put the_content(); to this template, nothing else, then it will display my text i entered in my admin panel in the editor. But if i have a different loop in my template, its display the content from an other post. <?php query_posts( array( 'post_type' => array( 'movies' ) )); if (have_posts()) : while (have_posts()) : the_post(); ?> asd <?php endwhile; endif; ?> <?php if ( have_posts() ) while ( have_posts() ) : the_post(); ?> <?php the_content(); ?> <?php endwhile; ?> So the the_content(); part in the end is displaying the content from the previous loop. What should i do to fix this?
Try rewinding the Loop, via `rewind_posts()`, between the two loops? <?php if (have_posts()) : while (have_posts()) : the_post(); ?> asd <?php endwhile; endif; ?> <?php rewind_posts(); // REWIND THE LOOP! ?> <?php if ( have_posts() ) while ( have_posts() ) : the_post(); ?> <?php the_content(); ?> <?php endwhile; ?>
stackexchange-wordpress
{ "answer_score": 0, "question_score": 0, "tags": "query posts, loop, the content" }
get_query_var() and permalinks I have a permalink structure that looks like this, %category%/%postname% I have a category.php template coded up and and trying to pull of the post of a certain category, so for example my URL may look like this, /category/category1 I want all posts that are in category1 to be return however, when using the following code I get null returned, `get_query_var('cat')` I assume that this code is looking for URL that looks like this, ?cat=category1 So how do I make it work with permalinks?
WordPress rewrites rules invisibly translate pretty permalinks to the non-pretty format internally, and set the appropriate variables and load the requested page, you don't need to do anything in your template to load posts from a category on a category page. The `cat` query var specifically will be set to the _ID_ of the requested category, not the name. That said, this: $my_category = get_query_var('cat'); echo $my_category; _should_ print the selected category ID on a category page. If it's not, we'd have to see your code to help you further. Also, have a look at the `$wp_query` global to see all query vars set on a particular page: global $wp_query print_r($wp_query);
stackexchange-wordpress
{ "answer_score": 5, "question_score": 1, "tags": "theme development, permalinks, templates, categories" }
Where is Featured Image code stored in WP? Well, I'm looking for source code of these two small containers (PHP backend, HTML frontend & JS used to attach the image): !Featured Image I want to build a theme option based on Featured Image code, but I'm not able to find it. I'm pretty sure it is somewhere in wp-admin directory, but I've spent loong time there and found nothing. Any clues?
Markup of that metabox is generated by `_wp_post_thumbnail_html()` function, contained in `wp-admin/includes/post.php`.
stackexchange-wordpress
{ "answer_score": 0, "question_score": 2, "tags": "uploads, wp filesystem" }