question
stringlengths
0
34.8k
answer
stringlengths
0
28.3k
title
stringlengths
7
150
forum_tag
stringclasses
12 values
Under "Personal Options" on user profile page, there are: (1) disable visual editor (2) admin color scheme (3) keyboard shortcuts (4) show admin bar I can remove admin color scheme using remove_action, but not the rest. Is there a way to remove them all at once? Or one by one using remove_action or style or js?
I think this is the kind of thing you had in mind. <code> add_action( 'admin_print_styles-profile.php', 'remove_profile_fields' ); add_action( 'admin_print_styles-user-edit.php', 'remove_profile_fields' ); function remove_profile_fields( $hook ) { ?&gt; &lt;style type="text/css"&gt; form#your-profile p+h3, form#your-pr...
How to remove all the items under "Personal Options" on user profile page?
wordpress
I want to remove the below text links in Edit Post screen: All (8) | Published (5) | Draft (1) | Pending (2) | Trash (2) After searching, i found that this can be done by this code here , but sadly it only works with 'post' type. I'm failed to make it works with my custom post type: <code> add_action( 'views_edit-post'...
Further down on the page you linked to is this comment: Similar views can be edited by hooking into 'views_' . $screen-> id where $screen is the global $current_screen (or get_current_screen()). Draft, Pending, Mine and Sticky could all be removed in a similar manner. When you're editing a post, you're on the "edit-pos...
Remove All, Published and Trashed Post Views in Custom Post Type
wordpress
I'm trying to make a script that uploads a file to a specific folder in the wordpress installation. Basically I want to upload to /uploads. However, in order to do this I need to know the server path for the WordPress installation. How can I get this?
Use wp_upload_dir() for path to uploads, and use get_bloginfo() to get paths to the WP location
WordPress upload file - get path to WordPress installation
wordpress
I'd like to be able to have a workflow that works like so: Create a post and assign it a password Have a single-field form on the home page User enters password on home page, and is sent to the corresponding post Does anyone know if this is possible?
Thanks to Tom's help, here's what I ended up with. This uses the built in functionality for password-protecting a post, so a visitor only has to enter a password on the home page, then they are taken to the post and are able to directly view the post content without re-entering the password. On home page: <code> &lt;fo...
Is it possible to direct users to a certain post based on a password entered on the home page?
wordpress
Is there any reason for getting this error? I tested a couple of installations so far. Any suggestion?
It's WordPress 3.1 function - so you're probably testing it on older versions.
Fatal error: Call to undefined function get_users()
wordpress
Our site is quite high traffic and we use both nginx and w3 total cache to handle the load. We've previously been using wp-postviews to count the page views, but it seems to be locking the postmeta table now, and often doesnt count views at all. It's unreliable at best. Can anyone suggest a way for us to count page vie...
It really depends what you need to view counts for - if it's just for seeing traffic stats, then use Google Analytics or any number of javascript tracker based analytics tools. If you need integration of page view counts and the ability to do things like order post by views, then you can either spend some time optimisi...
Counting pageviews on high-traffic cached sites
wordpress
New to WP. I soon realized there are some files that need to be writable by the web server, otherwise various operations fail. Moreover, the lists seem to be different for different tasks. Not sure I'm in love with the concept, but okay, I'll work with it. The trouble is, I can't figure out a simple way to determine wh...
The short answer is that you're correct... You don't want the web server (or web user) accounts to have full write access to your WordPress installation. Your user account , however, will need write permissions for the entire application because many of the WordPress features (such as automatic updates among others) re...
List of files/folders writable by the web server?
wordpress
I have a custom post type for 'Teams' set up using the code below. However, the fields for 'Latest Discussion' and 'Next Fixture' isn't showing up in the dashboard. I went over the code numerous times and can't find anything wrong with it. I was hoping someone here could help me figure it out. <code> // Register Teams ...
The fourth argument for <code> add_meta_box() </code> is the context, which in this case would be <code> teams </code> , not <code> latest discussion </code> or <code> next fixture </code> as you have here. Also, since you want these metaboxes to show on the new and edit screens for your CPT only, it's easiest to regis...
Custom Post Type fields not showing in dashboard
wordpress
I am creating a plugin in which I will need to display content on a page. I have seen plugins that allow an administrator to put something like [display-content] in the visual editor which displays the plugin content to a website visitor. How is this done?
With the Shortcode API .
Plugin to Display Content on Page
wordpress
I use this in functions.php to change "howdy" to "Logged in as...." But now under 3.1 I get "Logged in as Your Profile" rather than "Logged in as <code> &lt;current user&gt; </code> " What needs to be changed so that "user" below (commented below as <code> //get current user?) </code> returns the current user in 3.1? <...
Why fiddle around with jQuery when you could just run a filter on <code> gettext </code> to specifically target that text? Perhaps you simply don't know you can do that, so here's how.. <code> add_filter( 'gettext', 'change_howdy_text', 10, 2 ); function change_howdy_text( $translation, $original ) { if( 'Howdy, %1$s' ...
Get current logged in user under 3.1, re: remove "Howdy"
wordpress
I'm using wp_list_categories to give me a list of links to categories (no surprise there) Is it possible to get Wordpress to link to the first post of a given category instead of calling the taxonomy template which displays links to all posts in that category?
Ended up resolving it by using this in the taxonomy template instead... <code> &lt;?php /* Redirect To First Child */ if (have_posts()) { while (have_posts()) { the_post(); $pagekids = get_pages("child_of=".$post-&gt;ID."&amp;sort_column=menu_order"); $firstchild = $pagekids[0]; wp_redirect(get_permalink($firstchild-&g...
wp_list_categories link to first post of category instead of calling taxonomy template
wordpress
What happens, when I click <code> Save Changes </code> on a option page, which was created by <code> add_menu_page() </code> ? Where is the submitted data stored before the database transmission? A <code> print_r($_REQUEST) </code> returns only the two <code> $_GET </code> parameters <code> page </code> and <code> sett...
I've finally found my fault. The "problem" with <code> Zend_View </code> and <code> Zend_Form </code> is, that you have to check and save the submitted settings by yourself. But if you register a sanitize hook with <code> register_setting() </code> , WordPress will indeed not return any <code> $_POST </code> array and ...
Where is the submitted $_POST array stored after an option page submission?
wordpress
I added the following code which allows categories on my 'Page' post type. <code> add_action('init', 'edit_page_type'); function edit_page_type() { register_taxonomy_for_object_type('category', 'page'); } </code> Now i realize the permalinks dont exactly match... How can i rewrite the page permalinks to act like the po...
Can you not just use Posts thats was they're designed for. You don't really categorise pages you structure them so they have parents and so on.
Page permalink rewrite
wordpress
I've created a custom post, <code> events </code> , and saved the meta data <code> event_year </code> to each event. I'm trying to get a year's event archive. When I go the the following URL, the <code> meta_key </code> and <code> meta_value </code> are not set for some reason, and thus the event archive is unfiltered....
That's because 'meta_key' and 'meta_value' are not public query vars. In other words, you can't use them in URLs directly, nor should you. Instead, register a specific query var, like so: <code> function register_my_qv() { global $wp; $wp-&gt;add_query_var( 'my_qv' ); } add_action( 'init', 'register_my_qv' ); </code> T...
I can't set meta_key in my custom post type query
wordpress
<code> foreach((get_the_category()) as $cat) { if (!($cat-&gt;cat_name=='Featured')) echo $cat-&gt;cat_name . ' '; } </code> this is what has been recommended in the forums but its not working for me. I need to split off the echo piece like the following to show an image. <code> &lt;li&gt;&lt;img src="&lt;?php bloginfo...
Try this: <code> foreach((get_the_category()) as $cat) { if ($cat-&gt;cat_name != 'Featured') { echo '&lt;li&gt;&lt;img src="' . get_bloginfo('template_url') . '/images/cats/' . $category-&gt;slug . '-icon.png"/&gt;' . $category-&gt;cat_name . '&lt;/li&gt;'; } } </code>
using get_the_category to get all post categories except one
wordpress
I am looking for a way to make it so multiple authors/moderators within wordpress get notified when there is a new comment waiting approval. I'm thinking of switching over to Disqus for this type of thing, but was wondering if it's possible without swapping out the commenting interface.
I have used the plugin Comment Notifier. http://wordpress.org/extend/plugins/comments-notifier/ And it works adequately.
Multiple Comment Moderators and Notifications
wordpress
I just moved a site (by exporting &amp; importing all posts &amp; pages, and copying theme files over), and on the new site the various page and post templates are unavailable for selection on post and page edit screens. The files did have Windows line endings, which I fixed, but that did not eliminate the problem. Any...
Sounds like it could be an issue with the database and serialization of the plugin options. I've had problems before with plugin settings etc when moving a site using the xml export. The category templates plugin writes a lot of options to the db and they could be corrupted. As a test try creating a php file and puttin...
Template files missing after moving site
wordpress
I've got jwplayer installed in wordpress and have it showing in a single.php page... the way I have it I need to get a custom field in the javascript and I;m having no luck echoing it in there. I know you cant straight up run PHP in a javascript function, hence I'm here asking noob questions :) <code> &lt;script type='...
Have a read through this article: Adding Scripts Properly to WordPress Part 2 – JavaScript Localization What you are doing here is passing your PHP values to the WordPress JS localization system. This then allows your JS code to get access to those variables you have passed.
PHP echo inside javascript
wordpress
I need to export the last two week's worth of blog posts from one site into another site, including all meta data and post author info. Is there a good SQL statement to do this, or a plugin that will help me accomplish this?
The native import/export tool can do most of this, though I don't think it will grab all the author profile information (not sure on that - I know it doesn't bring over passwords, but it might bring the rest). In the WP admin panel go to Tools > Export and walk through the various option screens. Best of luck!
How to export 2 week's worth of posts
wordpress
In several theme templates I have code to retrieve the category name and slug for the present post or category page. It is outside the loop. Here is the repeated code: <code> global $post; $categories = get_the_category($post-&gt;ID); if ( $categories ) { foreach ($categories as $category) { $dw_category_slug = $catego...
You don't need to hook the <code> dw_get_category() </code> function. Simply do it like this: <code> function dw_get_category() { global $post; $categories = get_the_category($post-&gt;ID); if ( $categories ) { foreach ($categories as $category) { $dw_category_slug = $category-&gt;slug; $dw_category_name = $category-&g...
create function to call category name and slug
wordpress
I'm trying to make Yoast's Custom RSS feeds post display in an add_feed function. Just putting Yoast's snippet inside add_feed results in: ERROR: feedname is not a valid feed template. I have tried two rewrite functions, but to no avail. What could I be missing? Yoast's function untouched: <code> &lt;?php /* Template N...
You have <code> add_feed('feedname', 'my_feed'); </code> but no my_feed function to actually generate the feed output. Create a my_feed function and have it call the template to generate the feed output. Like this: <code> function my_feed() { include 'path-to-that-template-file.php'; } add_feed('feedname','my_feed'); <...
Yoast custom feed template as add_feed function?
wordpress
I want my post-links to look like /%post_id62%_%postname%/ where %post_id62% is the post ID in base62 encoding (e.g. http://example.com/y9Rlf_test/ ) and my shortlinks to consist of /%post_id62% only (e.g. http://example.com/y9Rlf ). This is what i've got so far (in my <code> functions.php </code> ) which obviously doe...
You only made a mistake in the final step, when you convert the base62-encoded ID back to a decimal ID. You should not do this by changing the rewrite rules, as they are only patterns, not actual rules per post. What you want is take an incoming URL, let WordPress parse it using the rewrite rules, but then before it is...
custom permalink/shortlink with base62 encoded post ID
wordpress
I'd like to force a user to a specific page upon login based on their role using <code> if ( current_user_can('contributor') ) </code> and the main login function <code> function wp_loginout($redirect = '', $echo = true) { if ( ! is_user_logged_in() ) $link = '&lt;a href="' . esc_url( wp_login_url(get_permalink()) ) . ...
filter <code> login_redirect </code> : <code> function my_login_redirect_contributors() { if ( current_user_can('contributor') ){ return 'url-to-redirect-to'; } } add_filter('login_redirect', 'my_login_redirect_contributors'); </code>
How do I redirect upon login a specific user based on role?
wordpress
I have a custom post type set up on a subsite in a multisite network which the code is in a plugin to activate it only for the subsite. I have some code that inserts a post using code but I belive it is trying to insert it into the main site. it is simply a php page with require( $_SERVER['DOCUMENT_ROOT'] . '/wp-load.p...
You probably need to switch your context to the subsite in which the posts need to be created. Have a look at the switch_to_blog() and restore_current() functions in wp-includes/ms-blogs.php See http://phpxref.ftwr.co.uk/wordpress/wp-includes/ms-blogs.php.source.html#l437
Insert post into subsite using code
wordpress
I'm pretty new to WordPress and i'm trying to customise my theme to send an email to myself when a upgrade is required. I'd rather not use a plugin as this means I have to install it for each wordpress site. The code below is based from the update notifier plugin. <code> add_action('check_updates_daily', 'check_updates...
I forked the above plugin you mentioned as WP Updates Notifier Maybe you want to look at that instead? If you want to include it in your theme all you do is copy the plugin file and place in your theme functions file instead. If you need further help modifying this plugin leave a comment and I'll see what I can do.
Email user on wordpress upgrade
wordpress
Why I can't add tags since Wordpress 3.2 ?! Ajax doesn't seem to work... I gonna be crazy. Any help please ?
I believe this to be an issue with a jQuery conflict. Since version 3.2 of WP jQuery has been updates. There might be other plugins you are using that doesn't play nice with the new jQuery version which is then triggering a JS error, thus stopping the tag/AJAX functionality from working. Try disabling all your plugins ...
Tags in Wordpress 3.2
wordpress
I know this is a vague question, please just spend time on it if you are in the mood, I don't need to be flamed for not being more precise. I'm having a problem with a theme I'm developing, for some reason it breaks the export function of WordPress. I'm not asking for anyone to solve my problems here, but after having ...
The basic idea for debug here is that theme apparently influences something it totally should not. Either something is done in a wrong way or in a wrong place. Check that theme is not running any functionality directly in <code> functions.php </code> . Check that all of theme's functionality runs on appropriate hooks. ...
my theme breaks WP export
wordpress
How can I remove the width and height attributes from the post_thumbnail when inserting with <code> &lt;?php the_post_thumbnail(); ?&gt; </code> ? <code> &lt;img width="800" height="533" src="http://domain.com/wp-content/uploads/2011/02/image.jpg" class="attachment-post-thumbnail wp-post-image" /&gt; </code>
Related: stackexchange-url ("Filter to remove image dimension attributes?") There's a filter on <code> post_thumbnail_html </code> which receives as its argument the full html element representing the post thumbnail image before it's echoed to the page. You can filter out the dimensions with a bit of regex: <code> add_...
How do you remove hard coded thumbnail image dimensions?
wordpress
I have a question. I made a simply ajax function. When I'm logged in, it works perfectly. When I'm logged out, it returns me -1 (since Wordpress 3.1) Why ? I don't understand. Precisely, it returns -1 and my entire HTML code. (lol) I'm gonna be crazy again. PHP (in functions.php) <code> function say_coucou(){ check_aja...
Found It! I had done a redirect, so my ajax function status was 302... I deleted the redirect and it worked ! Thanks guys.
Ajax function returns -1
wordpress
I am using the below function to update the post meta from the front end. How can I add add best a textarea that updates <code> the_content() </code> using <code> wp_update_post() </code> ? <code> if ( isset( $_POST['albums'] ) &amp;&amp; wp_verify_nonce($_POST['albums'],'update_albums_postmeta') ) { //if nonce check s...
It depends on where you're using this. Is global $post giving you the specific post that you want to update? Your Wordpress update post code looks right to me, but is the if-statement valid, and is $post-> ID yielding the correct int?
wp_update_post() example... how to update the_content in a textarea?
wordpress
I use the Chat plugin , but I found a bug when using it with the Twenty Eleven theme in WordPress 3.2. If you scroll, the chat window goes behind the header image. I used this plugin with no problems up to WordPress 3.1.4, and it works find in 3.2 - except for this problem. I guess the <code> z-index </code> is the rea...
It is indeed a <code> z-index </code> problem. The <code> #branding </code> element has a <code> z-index </code> of 2, in other themes (like Twenty Ten, the default in 3.0 and 3.1), it was not set. A simple solution is to set the <code> z-index </code> of <code> #chat-block-site </code> to something higher. <code> #cha...
Chat window hiding behind Twenty Eleven header
wordpress
Is there an easy way (a plugin maybe?) to export and then import into a different WordPress installation all links in the blogroll including descriptions and categories? I know you can export links by going to /wp-links-opml.php, but I believe doing it this way you loose the link descriptions. When importing, I'd like ...
You can export/import the wp_links database table using PhpMyAdmin or similar database tool. Just make sure in the file that exports you change the database name at the top of the file to the name of the database in your destination wordpress site. Note that importing the table will remove any links that you currently ...
Blogroll import/export with categories and descriptions
wordpress
In the parent theme, the following is at the bottom of the functions.php file. <code> require_once(TEMPLATEPATH . '/admin/admin-menu.php'); </code> In the child theme's function.php , this code will include the child admin panel. <code> require_once(STYLESHEETPATH . '/admin/admin-menu.php'); </code> As you can see, I s...
For cases where you want to require/include PHP files, but still allow child themes to replace those PHP files outright, then you should use the locate_template function. Example: Parent does this: <code> locate_template( 'admin/file.php', true ); </code> This finds the admin/file.php file in either the child or the pa...
How do I remove a require_once admin panel from the parent theme from the child theme functions.php?
wordpress
I am trying to find a way to get the current page number of an article that has been splitted into several pages with the use of: <code> &lt;!-- nextpage --&gt; </code> There is an example that can be found here: http://codex.wordpress.org/Conditional_Tags#Testing_for_paginated_Pages But this doesn't work for me – it a...
For multi-page posts: The <code> $page </code> global variable returns the current page of a multi-page post. The <code> $numpages </code> global variable returns the total number of pages in a multi-page post. For paginated archive index pages: The <code> $paged </code> global variable returns the current page number ...
Get current page number of splitted article
wordpress
I have a new site and I'm using bbpress beta-3 with it, I've created custom login/register/lost-password pages with the custom templates supplied with bbpress and I can't seem to find the filter/hook/action that "hijacks" the calls to <code> wp-login.php </code> . My biggest problem is with the <code> lost-password </c...
not sure i really follow you either, BUT what about filtering the wp_lostpassword_url from wp-includes/general-template.php <code> function wp_lostpassword_url( $redirect = '' ) { $args = array( 'action' =&gt; 'lostpassword' ); if ( !empty($redirect) ) { $args['redirect_to'] = $redirect; } $lostpassword_url = add_query...
how to redirect to a custom password retrieval page
wordpress
After updating to Wordpress 3.2, the show/hide functionality of the event authoring area on "The Events Calendar" is backwards - when the "All Day Event?" checkbox is checked, the time boxes appear. When it is unchecked, the time boxes disappear. This is opposite behavior of what should happen. I suspect it's a Jquery ...
I discovered the answer: The new version of Wordpress using version 1.6 of JQuery. In the file events-meta-box.php, change anywhere where it says: <code> .attr('checked') == true </code> to: <code> .prop("checked", true) </code> There should be three locations where you fix it.
"The Events Calendar" Issues in WP 3.2
wordpress
I'm creating a wordpress theme that I aim to sell at some point. Now, I've discovered that some of the wordpress.org plugins would be great for things that I want to do. They already hold much of the functionality I aim to achieve, so I thought of using them directly (they are under GPL I suppose). I would probably nee...
Let me make a recommendation: do not bundle plugins with your theme! On first glance, yes this is a very easy way to add default functionality with your theme, but there are a slew of reasons not to include the plugins this way: Updates : If the plugin is freely available from WordPress.org already, then so are automat...
Add Plugins to Wordpress Theme
wordpress
I have defined a walker in function.php to display comments in a certain way. I use the following code: <code> function speld_comment($comment, $args, $depth) { $GLOBALS['comment'] = $comment; ?&gt; &lt;?php global $comment_count; $comment_count++; ?&gt; &lt;!-- &lt;?php echo $comment_count; ?&gt; --&gt; &lt;li &lt;?ph...
Just use the $depth arg: <code> if ( $depth ) { // it's a child comment } else { // it's a parent comment } </code>
Displaying comments with a walker: how to distinguish between parent and child comments
wordpress
I want to generate slug for some strings without going through WordPress slug generation flow. Therefore, I want to know which functions it calls to get a neat slug. I tried sanitize_title() but it leaves %c2 %a0 in result.
You are almost there. The function you need is sanitize_title_with_dashes( $title )
Is sanitize_title enough to generate post slugs?
wordpress
I know that Google +1 is quite new (at time of writing), but I wondered if there were any plugins that support these. By "Social Interaction tracking on Google Analytics" I mean - that use this code - http://code.google.com/apis/analytics/docs/tracking/gaTrackingSocial.html?utm_source=helpCenter&amp;utm_medium=helpCent...
In the end I went with the plugin from addthis.com which can be customised to work with +1.
Are there any plugins yet that support Facebook Like, Google +1 and allow Social Interaction tracking on Google Analytics
wordpress
I got a set of meta boxes containing different form fields. All of them are build inside a set of classes. Now I have the problem that I have to hook the construction of the fields early enough to hook the needed scripts &amp; styles. Everything is fine - I can display them, styles &amp; scripts appear &amp; work, savi...
Once you're in the function that actually prints the html for the metabox, the global $post object should always be set the to current post. Is there a specific reason that you need to know the post_id during init?
$_GET & $post_ID
wordpress
Currently, to call comments I am simply using: <code> &lt;?php wp_list_comments(); ?&gt; </code> in comments.php. This is calling up gravatars, which I would like to be able to set the size of. How can I set the size of gravatars in my comments.
Quite simple, actually: <code> wp_list_comments( 'avatar_size=80' ); </code> Just change <code> avatar_size=80 </code> to whatever is appropriate. Here's a bit more information on customizing Gravatars in WordPress .
Gravatar Size Via Theme Functions?
wordpress
I am using the Yoko theme and would like to show the most recent full post in category 1 on the home page. I am a Wordpress newbie, but my approach was going to be to provide my own index.php in a child theme. The parent theme has relevant code that looks like this: <code> &lt;?php /* Start the Loop */ ?&gt; &lt;?php w...
You can alter query_posts - see http://codex.wordpress.org/The_Loop - but maybe the best thing to do is use a page template with a new query. WP will default to home.php instead of index.php if one exists, so you can leave index.php alone for other page to use. See http://codex.wordpress.org/Class_Reference/WP_Query Sa...
How to show full post on home page
wordpress
Is there a way to use WordPress Multisite to collaborate all subsites into the main site? My thought is to have all the subsites to be departments of an organization and the main site be the front page for the organization. Navigation would be created automagically: one for the main site, then a separate navigation tha...
It's definitely possible. And there are a few plugins to help make it easier Diamon Multisite Widgets Bloglist, recent posts and comments from the whole network. Wordpress MU Sitewide Tags A central area where all the posts on a WordPress MU or WordPress MS site can be collected. This plugin creates a new blog on your ...
Different use for WordPress Multisite
wordpress
I am involved with several WordPress support websites including this one (recently). I seem to get the question "Can WordPress be used as a CMS/Membership Website?". I haven't needed to set one up, so I always refer them to suggestion from other forums. I've decided that it's only a matter of time until I will be requi...
You could use a combination of the Members plugin to manage user roles (ie employee types or levels) along with the Custom Post Type UI plugin to manage various post types. With the Custom Post Type UI you could create posts types. Then you could allow or deny rights for various operations on each type of post separate...
WordPress as a CMS Membership website
wordpress
I have a custom meta box that is supposed to accept HTML, but the text I'm trying to input contains both double and single quotes (and ampersands), and it's messing up the saved data - each time I reload the post, the data is duplicated with an extra single quote (and angle bracket) inserted at the end. I'm guessing it...
If I'm allowed to answer my own question here: I found a way to stop the conversion of my html entities back to characters by using <code> &lt;?php esc_textarea( $text ) ?&gt; </code> , as detailed by the codex here: http://codex.wordpress.org/Function_Reference/esc_textarea . Not sure if this is the right way of doing...
How do I stop HTML entities in a custom meta box from being un-htmlentitied?
wordpress
How do I change my index.php to display only the desired categories posts in the main page ? I tought that changing this would workout but instead it just print nothing: <code> query_posts( array( 'post_type' =&gt; array( 'post', $include_reviews, $include_screenshots, $include_videos ), 'paged' =&gt; $paged ) ); </cod...
Your syntax is wrong, change: <code> query_posts( array( 'post_type' =&gt; array( 'post', $include_reviews, $include_screenshots, $include_videos ), 'paged' =&gt; $paged ) ); </code> to: <code> query_posts( array( 'tax_query' =&gt; array( array( 'taxonomy' =&gt; 'category', 'field' =&gt; 'slug', 'terms' =&gt; array( $i...
Change from all posts to specific categories post on main page?
wordpress
I'm using this class http://www.deluxeblogtips.com/p/meta-box-script-for-wordpress.html to create custom meta-box in which it contains some WYSIWYG editors. It works fine until I upgraded my WP to 3.2. The WYSIWYG editors are now have white text background and all tinyMCE buttons are gone! I guess they've changed quite...
as per here , add this to your functions.php <code> add_action("admin_head","myplugin_load_tiny_mce"); function myplugin_load_tiny_mce() { wp_tiny_mce( false ); // true gives you a stripped down version of the editor } </code>
WordPress 3.2 - Problem with WYSIWYG editors in a custom post type?
wordpress
Is it possible to add a link category on plugin activation? What I mean is the Links section, as you know by default it has the Blogroll link category. I want to add a new link category when my plugin is activated, is there a quick and easy way to do this? What is the best method to use? Thanks.
Link category is a simple taxonomy just like categories , named: <code> link_category </code> so to add one you can use <code> wp_insert_term() </code> eg: <code> wp_insert_term( 'My link category', // the term 'link_category', // the taxonomy array( 'description'=&gt; 'this is a description.', 'slug' =&gt; 'my-link-ca...
Add Link Category on Activation?
wordpress
I am using twenty-eleven theme for my site, I just saw that in single posts page, .i.e single.php, the sidebar is absent, which means no widgets in single.php page How do I bring it back
Write before <code> &lt;?php get_footer(); ?&gt; </code> <code> &lt;?php get_sidebar(); ?&gt; </code> or <code> &lt;?php get_sidebar( $your_custom_sidebar ); ?&gt; </code>
twenty eleven single.php
wordpress
I'm creating a custom taxonomy whose terms must remain fixed by all users. Once I've set up the starting set of terms, I want them to be immutable. I also don't want to clutter up the Admin UI with additional links and metaboxes where they're not needed. However, setting <code> public =&gt; 'false' </code> , or <code> ...
You talking categories (hierarchical) or tags? You just need a hidden taxonomy + custom widget. If it's categories, it easier to do, if tags... depends if the number of items is decent. And you can hide them from public view only for non-Administrators. That way you can manage them easily while the others can't touch t...
Read-only taxonomy (user can assign term but can't create or edit existing terms)
wordpress
In the <code> functions.php </code> of my plugin I've added the following code: <code> function relativePathForUploads( $fileinfo ) { global $blog_id; $path = get_blog_option($blog_id,'siteurl'); $fileinfo['url'] = str_replace($path,'',$fileinfo['url']); return $fileinfo; } add_filter('wp_handle_upload', 'relativePathF...
I think that function is only available in multi-user mode. Try: <code> if(is_multisite()){ $path = get_blog_option($blog_id,'siteurl'); }else{ $path = get_option('siteurl');` } </code>
Call to undefined function get_blog_option()
wordpress
I would like to accomplish something like this: <code> &lt;?php $custom_posts = new WP_Query(); ?&gt; &lt;?php $custom_posts-&gt;query('category_name=Business OR category_name=Technology OR category_name= Lifestyle'); ?&gt; &lt;?php while ($custom_posts-&gt;have_posts()) : $custom_posts-&gt;the_post(); ?&gt; &lt;div cl...
If you have the category ID you can use the <code> category__in </code> parameter eg: <code> &lt;?php $custom_posts-&gt;query(array('category__in' =&gt;array(1,2,3))); ?&gt; </code>
How to add an "or" instead of and "and" (&) in a Wordpress query?
wordpress
There are different PHP logging frameworks out there e.g. Log4php, KLogger. I want to choose one based on its experience with WordPress. Please suggest me one.
I would suggest to go with KLogger more specifically a fork of it which is simple and clean, and i have a few sites logging using this simple class with no problems or complains.
PHP logging framework to be used with WordPress
wordpress
I am using the brand new twenty eleven theme, my home page is set to show latest posts, but it displays the entire posts, I want to only show the excerpts, not the entire content, Here is the index.php code <code> &lt;div id="content" role="main"&gt; &lt;?php if ( have_posts() ) : ?&gt; &lt;?php twentyeleven_content_na...
The template you're actually after is "content.php" You'll want to change this line: <code> &lt;?php if ( is_search() ) : // Only display Excerpts for Search ?&gt; &lt;div class="entry-summary"&gt; &lt;?php the_excerpt(); ?&gt; &lt;/div&gt;&lt;!-- .entry-summary --&gt; &lt;?php else : ?&gt; &lt;div class="entry-content...
Twenty Eleven home page show only excerpt
wordpress
My question pertains to where I should create an ajax function that I'd like to call from my page view. I am using a jQuery validator on a custom form that should check the inputted zipcode against my database of valid zipcodes. I just need to know where this function should exist. Normally when using a non wordpress s...
In WordPress the way of handling Ajax calls is a bit different the plain PHP but still very simple, all ajax calls should be to <code> wp-admin/admin-ajax.php </code> and you just define your own functions by hooks, Take a look at What's the preferred method of writing AJAX in WordPress
Creating custom AJAX requests
wordpress
I'm getting this when saving a post after editing: <code> Forbidden You don't have permission to access /wp-admin/post.php on this server. Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request. </code> All file permissions are 644 and directory permission are 755...
Sometimes hosting providers will implement mod_security (and not mention anything). Or else, mod_security was already on but a recent installation of a plugin or theme may have exposed this new problem for you. You can try these four things... Add the following to your .htaccess file (add to .htaccess, don't replace th...
permissions access error
wordpress
I'm starting a website (more complicated than a blog) and would appreciate advice on which framework to use. A person on my team uses wordpress and is enthusiastic about its possibilities, but a friend who works on rails is lobbying against it ("But it's for blogs!"). Both can help me get started so I'll probably chose...
Your friend is a diva. WordPress started as a blog platform, but now it has grown beyond that and is encroaching on becoming a mid-tier content management system out of the box. If you like it and it is easy for you, use it. It seems to match up with what you are trying to do. Articles are essentially blog posts anyway...
Can I use wordpress for a non-blog site?
wordpress
I'm trying to decontruct (and recreate) a serialized option value in wp_options called 'my_options' How would I build the array to recreate this option_value that currently exists for 'my_options'? update_option('my_options', ?) After the update, the wp-options table would hold this value for 'my_options': <code> a:3:{...
You can't use it as-is because it will get double-serialized. So as per comment you unserialize it first and it will get serialized back when saved into option. <code> $array = unserialize( $stuff ); update_option('my_options', $array); </code>
Decontruct serialized data array from wp_options
wordpress
How can i get a page ID from the Admin backend? I'm saving data into a metabox on a 'Page' post type, and I need to return that data on the page in another area. But $post-> ID obviously dose not work... What will work? Thanks
This is what I needed <code> $_REQUEST['post'] </code>
Get Page ID from Backend
wordpress
My theme has a custom.css file that I use to allow designer's to customize the it to their liking. However, when clicking on "Appearance > Editor", the style.css file is loaded there by default. Since I don't want custom edits done on this file, I'd like to minimize the chances that someone edits it by placing custom.c...
Unfortunately you can't control what files are loaded on that page... But you can disable the editor page and provide the user with theme options that allow him to include his own CSS. To deal with this I'm creating and activating a child theme automatically if possible: <code> if(!is_child_theme()){ require_once(ABSPA...
How to assign the default file at "Appearance > Editor"?
wordpress
Haven't worked much with XML so I'm hitting a bit of a wall: <code> function getapi() { $api_response = wp_remote_get( "http://example.com/getXML" ); $data = wp_remote_retrieve_body( $api_response ); $output = new SimpleXMLElement ($data ); return $output; } </code> Get or set the Transient <code> function transient() ...
According to this ticket: Cannot serialize object wrapping 3rd party library structs. Must serialize the xml (to a string) and store that to session and reload the xml when restoring from session When you are storing object in transient it gets serialized and not all objects are capable of that correctly. Store textual...
Storing an XML Response (Transient)?
wordpress
What is the best way to filter the posts being displayed? For example in my functions.php file I want to have something like <code> add_filter( $tag, 'filter_posts'); function filter_posts(){ if(is_home()){ //return custom post query that will be used in loop } } </code>
Actually, you're going about this the wrong way. Don't filter the posts in <code> functions.php </code> , instead, define custom loops and include them when needed . In a simplified example, let's say your theme only has <code> header.php </code> , <code> footer.php </code> , <code> sidebar.php </code> , and <code> ind...
Filter have_posts()/ the_post()
wordpress
I've just upgraded from 3.1.2 to 3.2, and now "featured image" is no longer listed at the bottom right of a post in admin. Has this feature of WP been removed? Can it be added back, or turned back on? My old posts still have their old featured image, but it cannot be added to new ones.
I had to restart my browser, and after logging back into admin featured image has reappeared. I made no changes to settings.
Featured Image missing in Wordpress 3.2 Admin
wordpress
I'm implementing a site that allows users to switch stylesheets (to show a high contrast version for people with vision impairments). The switcher essentially just changes the <code> &lt;link&gt; </code> ref to whichever stylesheet is appropriate. However, I've just realised that this will lead to problems when I switc...
Turns out the answer is fairly simple (at least for WP Supercache). Use either PHP or legacy caching (ie not mod_rewrite) Turn on late init (either from the UI - recommended, or by setting <code> $wp_super_cache_late_init = 1; </code> in <code> wp-content/wp-cache-config.php </code> Use the <code> &lt;!--dynamic-cached...
Stylesheet switching and caching
wordpress
writingyourwaytosuccess.com/blog Attempting to view a single post returns the following error: <code> Fatal error: Call to undefined function atmosphere_posted_on() in /home/content/46/7460046/html/wp-content/themes/atmosphere-2010/single.php on line 17 </code> Thanks!
Looks like you are using this theme: Atmosphere 2010 Looking through the theme files the function <code> atmosphere_posted_on </code> is used a couple times in loop.php and single.php. The <code> undefined function </code> error indicates that the function does not exist which leads me to believe that your functions.ph...
single.php error
wordpress
I'm getting a problem displaying tweets that include reply's (ie when you @username someone). It's showing the @ symbol but then cutting off the rest of the tweet. (Check out www.teamworksdesign.com in the bottom right hand corner) Can anyone help with this or suggest a good plugin? <code> &lt;?php function parseTweet(...
Hi Rob@:try with this plugin Tweet This .you can set your custom image also.:) or Try this code... Open the sidebar.php Locate the “twitter-feed” div <code> &lt;div class=”twitter-feed”&gt; &lt;h2&gt;What I’m up to…&lt;/h2&gt; &lt;ul id=”twitter_update_list”&gt;&lt;/ul&gt; &lt;script type=”text/javascript” src=”http://...
Displaying tweets problem with @username
wordpress
When the user clicks on the vote image, the image changes to the voted state. If the user clicks the image in the voted state again, a message pops up saying: You Had Already Rated This Post. Post ID #X I want it so that this message does not pop up and the 'voted' image stays as is. Below is what I believe to be the r...
Just comment out (or change) the following line: <code> // printf(__('You Had Already Rated This Post. Post ID #%s.', 'wp-postratings'), $post_id); </code> If you just want to not have the <code> $post_id </code> , change the line to the following: <code> _e('You Had Already Rated This Post. Post ID #%s.', 'wp-postrati...
How to remove message output for the WP-PostRatings Plugin?
wordpress
There are several plugins that handle the auto retrieval/display of photos from my personal facebook profile, but i'm looking for one that will work w/ my facebook group. the group is way more active than the actual website and it'd be a bonus for the website to pull more content from FB. have already looked at: Facebo...
take a look on Embed Facebook . Just paste the URL of a facebook album, photo, event, video, page, group, or note in a WordPress post/page, the plugin will embed it for you. For one more plugin is Facebook Photos .:)
Looking for Plugin that displays Facebook group's photos
wordpress
My hosting company infrom me that they do not allow loopback connections, which are required to run the following cron task on my server. I need to run a cron task for this plugin: http://tribulant.com/plugins/view/1/wordpress-newsletter-plugin <code> wget -O /dev/null "http://localhost/?wpmlmethod=docron&amp;auth=XXXX...
You could just try the alternate WP Cron method, which doesn't require loopbacks. Add <code> define('ALTERNATE_WP_CRON', true); </code> to your wp-config.php file.
WP CRON on shared hosting that does not allow loopback connections?
wordpress
Maybe it's just the site I'm running but has the 3.2 update removed the ability to select a page template in the page attributes when adding a new page? It's kinda essential unless anyone knows a way around it?
It seems as though it was a personal problem. A knew install solved the problem so it must've been clashing with some legacy data.
Wordpress 3.2 - removed ability to select a page template in the page attributes when adding a new page?
wordpress
I have a page that displays a list of all tags of my blog. Iuse this code which works fine: <code> &lt;?php $poststocount=get_tags($args); echo '&lt;h2&gt;Alphabetic Index of All '&lt;/h2&gt;'; ?&gt; &lt;?php $taxonomy = 'post_tag'; $tax_terms = get_terms($taxonomy); ?&gt; &lt;ul&gt; &lt;?php foreach ($tax_terms as $ta...
you could paginate your page by simply adding <code> /page/n </code> to the end of the URL, where <code> n </code> is the desired page number. creating your next/prev links will be a manual affair though. the page number will then be accessible via <code> get_query_var('paged') </code> . then use the <code> number </co...
How to paginate a list of tags
wordpress
I have a question. I just installed Wordpress 3.2. And ever since then, when I want to add a custom field, precisely when I clicked on "Add custom field", my page is refreshed. And no custom field is added. What is it ? Ajax bug ? Wordpress 3.2 ? Can you help me please ?
Try to re-install your wordpress, it might help you, and also try using different browser, to check the cache problem
Custom field bug in Wordpress 3.2
wordpress
So I originally designed the site without the www. I've since realized that it's going to cause more problems than necessary. I created a rewrite rule that converts to www. I then changed the domain in wp-config <code> define( 'DOMAIN_CURRENT_SITE', 'openeye.net' ); define( 'PATH_CURRENT_SITE', '/' ); define( 'SITE_ID_...
You don't need a rewrite rule in .htaccess to add www back in. Remove the rewrite rule, remove all the defines in wp-config and try to login. If that doesn't work, delete permalinks in .htaccess to force them back to default. After you're in, add the www in Dashboard> > Settings and save. Then reset permalinks.
Why am I unable to login after converting to www?
wordpress
I am working on backup-related plugin and from some research of existing plugins - they seem to favor using PHP's <code> mysql_* </code> functions, rather than <code> $wpdb </code> . Is <code> $wpdb </code> overhead considerable enough that it is unsuitable for such task as querying whole database tables?
There is a significant amount of memory usage if you use the $wpdb for queries that return very large result sets. $wpdb loads the entire results from any given query into memory. So if you're, say, selecting all the posts, then it'll try to load the whole thing into memory immediately. So for something like a backup p...
Does wpdb add considerable overhead on queries with large result sets?
wordpress
The Browse Happy interruption would only appear to logged-in admin users, correct? It won't show up on my public facing site? I can't really fire up IE6 very easily to find out.
Yes, it always was and still is only showing in the admin area.
Browse Happy in 3.2
wordpress
I want list the popular posts.popular post is defined by number of comments.If number of comment is high it will consider as popular. How can i do this !
You can easily sort by native post fields, so try something like this: <code> $posts = get_posts( array( 'numberposts' =&gt; 10, 'orderby' =&gt; 'comment_count', ) ); </code>
How to list most popular post
wordpress
Simply put, I need to hide all posts on the frontend if they are written by authors with a specific role. The role I have created is called 'Suspended'. I'm happy with putting a simple IF statement around the loop which prevents posts from a certain role ID from appearing. Preferably though it would be something I can ...
Use <code> WP_User_Query </code> to build a list of suspended authors` ids, then use that list with minuses for inversion as author parameter in query .
Hide posts from users with a specific role
wordpress
On a Wordpress based website, when I add text using wordpress visual editor or HTML source to a particular page - it gives "page not found error". I tried by adding some other text and its working fine. Then I typed all the text again and in between kept checking if it is giving any errors. Finally I am able to point t...
What form are your pretty permalinks taking, and what is the title of that page? I've had something similar happen and it had to do with the page title. Try flushing your permalinks (go to Settings > Permalinks and switch to a different default, save, then switch back again to what you were using). Though of course thi...
Wordpress "Page not found error" when I edit a page
wordpress
This morning I updated my wp, and after that few of the jquery of my site is not working. I am using woo themes premium newspaper theme. After the upgrade, the categories drop down menu(superfish menu) stopped working. I was using lightbox plugin for images, that stopped working. I deactivated all plugins and checked t...
The problem is with the theme. On the theme demo the superfish drop downs are not working and for some reason the theme is loading jquery 2 times version 1.3.1 from the theme directory and version 1.6.1 from the WordPress includes directory. Your site is actually loading jquery 3 times. I would contact the theme suppor...
WooThemes PremiumNews Theme jQuery Conflict with WordPress 3.2
wordpress
I am grabbing an image that is uploaded to that post working with this function: wp_get_attachment_image_src <code> &lt;?php $images = get_children( array( 'post_parent' =&gt; $post-&gt;ID, 'post_type' =&gt; 'attachment', 'post_mime_type' =&gt; 'image', 'orderby' =&gt; 'menu_order', 'order' =&gt; 'ASC', 'numberposts' =...
Looks like you may have just not had a loop setup, try this one <code> &lt;div class="two_images"&gt; &lt;?php global $post; $args = array( 'post_parent' =&gt; $post-&gt;ID, 'post_type' =&gt; 'attachment', 'post_mime_type' =&gt; 'image', 'orderby' =&gt; 'menu_order', 'order' =&gt; 'ASC', 'numberposts' =&gt; 2 ); $image...
How grab first two image attachments?
wordpress
Hi all I have this template page which get the page's post and then a list of posts from the category news. <code> &lt;?php /* * Template Name: News &amp; Info */ get_header(); ?&gt; &lt;div id="cLeft"&gt; &lt;?php if (function_exists('yoast_breadcrumb')) { yoast_breadcrumb('&lt;p id="breadcrumb"&gt;', '&lt;/p&gt;'); }...
It was correctly pointed out what the issue is, but I also want to explain it so you have better idea of mechanics: when you use <code> query_posts() </code> it writes down generated <code> WP_Query </code> object into global <code> $wp_query </code> variable; <code> have_posts() </code> and <code> the_post() </code> f...
Why this code causes infinite loop?
wordpress
I plan to use the category descriptions as outputted content into my posts for site user searches within my site, but I want to know when I make the site live to search engines will that presence of multiple category descriptions (duplicates) effect my seo in a negative way, i.e. getting blacklisted. So I will used the...
You won't get blacklisted. Small descriptive duplicate content on the same url tends to be a non-factor since it is very common, duplicate content over multiple urls, different parent urls, or large amounts of it can often become diluted, thus the use of canonical urls. ps. This question has nothing to do with WordPres...
Will multiple category descriptions effect my search engine optimization?
wordpress
I have a listing wordpress site and want to integrate geo data into the Wordpress MySQL Database for custom search functionality I want to utilize different aspects to create different things... City values will become taxonomies State values will become taxonomies Zip Code values will become taxonomies Latitude - will...
To answer your question... Yes, it's doable. But to give you some pointers into the right direction... I've known some folks who have had good success using the WordPress Importer plugin. You could conceivably export your geo data from your database (using whatever DB management tool you're comfortable with) to the imp...
Importing Geo data into wordpress database
wordpress
Anyone know any resources to help me install my widget when my plugin is activated?
By "install" your widget, I'm assuming you mean "automatically add the new widget to the sidebar for your user after the plugin gets 'activated'". (Because if you activate the plugin, which also contains a widget, your widget should be visible in the widgets area immediately, without any more work needed). Jordan Bosch...
Install widget on plugin activation
wordpress
I would love to be able to use spaces in usernames, but this does not seem possible. Is there a writeup in the codex or somewhere that explains what characters are allowed and why it was restricted to that set or is it just alphas only and suck it up? If I want users to use something other than a username with no space...
You can use spaces in usernames, no problem. Several users on wordpress.org have spaces in their usernames. Strict mode only allows these characters: <code> a-z0-9&lt;space&gt;_.\-@ </code> However WP doesn't default to strict mode. Now, multisite has different restrictions, and it may strip spaces there. This is becau...
Where can I find documentation on what characters are allowed in user names and why?
wordpress
I'm testing different layouts for my admin pages, and the easiest way I found to determine which layout to load is with URL parameters. One of those parameters is "fullscreen=1" which hides the admin menu, for instance. The problem is, whenever I save a post / custom post type by submitting a form, WordPress will redir...
I finally figured this one out. Turns out I was so focused on filters and actions that I forgot about the basics. In order to preserve any custom URL parameters after saving a post (via submitting the form) do the following: Filter your admin URL with a conditional that checks for the parameter you want to preserve (st...
Preserve custom URL parameter after saving post
wordpress
I am unable to see custom taxonomy box in the wordpress new menu system. I can see the post types but custom taxonomies are not available. I saw the screen options aswell custom taxonomies are not listed there. I am using more taxonomy plugin to create taxonomy.
Glad it was of use to you askkirati, I commented the code in order to make it easy to see where the plugin needs to be fixed, it really wasn't a big change and to be honest I don't know why it wasn't included.
Custom taxonomy not appearing in menu administration panel
wordpress
On my custom menus page, I'm getting a limit (e.g. the users cannot add more menu items). I have done some research and have found that my suhosin settings may not be allowing wordpress enough memory. What is the best way to fix the config so that my menus won't be limited?
I found the answer , so I'm posting it to help others out: In this file (depending on your server setup): <code> /etc/php5/apache2/conf.d </code> Change suhosin.ini on the following lines (remove the semicolons if applicable): <code> suhosin.post.max_vars = 5000 suhosin.request.max_vars = 5000 </code> The default 1000 ...
How to set up suhosin.ini for unlimited menus
wordpress
How to replace "wp-content/blogs.dir" with "media" for attachment permalinks in a multisite environment? This is how links look now: http://url.com/wp-content/blogs.dir/21/files/2011/06/650026_x640_21.jpg -or- http://subdomain.url.com/wp-content/blogs.dir/21/files/2011/06/650026_x640_21.jpg Ideally this is how the woul...
Actually ... the <code> blogs.dir </code> part isn't used except for internally. Let's say you have a network with two sites - <code> http://url.com </code> and <code> http://sub.url.com </code> . The files will be located in (respectively): <code> http://url.com/files/2011/06/... </code> <code> http://sub.url.com/file...
How to replace "wp-content/blogs.dir" with "media" for attachment permalinks?
wordpress
I'm creating my own wordpress theme. I've decided to use a different way to handle the theming and not use the standard get_header() and so functions. What i do is have a general main.php page that is loaded by every page like blog.php, index.php, page.php and more. This main page, will be then responsible for creating...
First, Why this is a bad idea WordPress already provides a rich templating API that allows for other plugins to hook in to your theme where needed. If a plugin needs to provide additional JavaScript or CSS, they tie in to <code> wp_head </code> . If they need to defer some JavaScript to the bottom of the page, they hoo...
Custom Wordpress File Inclusion
wordpress
This may be obvious to someone other than myself. I think I remember reading somewhere that an "image" is indeed a form of "post". I have a custom post type called "listing" I have a custom WP role of "client" When I'm logged in as the "client", and I launch the media popup, browse to an image, click "show" to open it ...
If I had to guess: because images are Attachments , and Attachments are a Post-Type . Thus, in order to edit an image, which is an attachment, which is a post, requires the <code> edit_post </code> capability. EDIT Don't you have your <code> capability </code> mapping array keys/values reversed? e.g. you have <code> 'e...
Why does my custom WP role need edit_posts to edit images?
wordpress
I wish to do something as simple as the_post_thumbnail('large') but I want the URL of the image only, not the HTML which goes with it. Is that possible ?
Use <code> get_post_thumbnail_id() </code> to retrieve ID, then <code> wp_get_attachment_image_src() </code> to retrieve array, that will have URL as first element.
Getting only the URL of the post thumbnail
wordpress
I have posted this on StackOverflow too, not sure if that's allowed - if not let me know and I'll remove one (I don't want to look like I'm spamming). Anyway.... I have a custom post type and have used the Verve Meta Boxes plugin to create some custom meta values for the post type. The meta box is called 'Subjects' and...
Take a look at the codex for a better understanding of queries of custom fields but it should look something like this: <code> $subjects_array = explode("_", $_GET["subjects"]); $args = array( 'post_status' =&gt; 'publish', 'post_type' =&gt; 'any', 'meta_query' =&gt; array( array( 'key' =&gt; 'field_name', 'value' =&gt...
WP_Query with checkbox meta_query
wordpress
i need a solid solution for checking if a post has pagination or not, regardless of the number of current page in the pagination, and even if the post is in the first page of the pagination. the check is inside the loop. thanks.
Just check for the global <code> $numpages </code> variable: <code> &lt;?php global $numpages; if ( is_singular() &amp;&amp; $numpages &gt; 1 ) { // This is a single post // and has more than one page; // Do something. } ?&gt; </code>
how to know if the post has pagination ( ) or not
wordpress
Title says it all, I pretty much just want to put a dropdown list on the front end that will list all the posts of custom post type 'agent', preferably in alphabetical order, and go to that post when user clicks on it.
try this: <code> //first get all agents $agents = new WP_Query(array('post_type' =&gt; 'agent', 'posts_per_page' =&gt; -1, 'order' =&gt; 'ASC', 'orderby' =&gt; 'title')); //then just print out the dropdown: if ($agents-&gt;have_posts()){ echo '&lt;select id="agent"&gt;'; while ($agents-&gt;have_posts()){ $agents-the_po...
Front End Dropdown Showing All Custom Post Type 'Agent'
wordpress
I'm trying to make some modifications to a wordpress multisite and i could use some help from someone more experienced. I want to restrict the acces to my blogs unless the user has an account. In detail : i have a series of blogs, each one with an admin/autor. If a user wants to read posts from a blog, he should first ...
Test if the current visitor is logged in and registered as user <code> // If the user's not registered &amp; logged in, abort if ( ! is_user_logged_in() ) return; </code> Test if the currently logged in user has a capability for the specific blog <code> $blog_id = ''; // You need to retrieve and set that here // If the...
User Signup in Multisite - Need Plugin or Advice
wordpress
(I am using a child theme of twenty-ten) For most of my pages I like to use the single column template. I noticed that (after I updated to 3.14) my single posts were using the default template (which has a sidebar for widgets). How do I get rid of this? I could style the sidebar away but is there a way to tell WP to ap...
You could duplicate the single-column template and rename it single.php.
How do I apply a template to my single posts?
wordpress
I'm trying to create an "admin only" meta box using WPAlchemy. The box for example may contain a "feature post" check box and other functionality. How can I show this meta box for only the admin, yet have it work properly? I'm currently using the following code below, but I receive a "Fatal error: Call to a member func...
try the following: <code> $custom_admin_mb = new WPAlchemy_MetaBox(array( 'id' =&gt; '_custom_admin_meta', 'title' =&gt; 'Admin only', 'template' =&gt; get_stylesheet_directory() . '/custom/admin_meta.php', 'output_filter' =&gt; 'my_output_filter', )); function my_output_filter() { if (current_user_can('administrator')...
Creating an "admin only" meta box with WPAlchemy. Getting a fatal error on front-end when using current_user_can
wordpress
I'm working on a simple addition to the widget options to allow the user to set the "context" in which widgets show be shown. Here's what I've got so far, with my questions in the comments... 1) Append the widget form to all widgets... <code> add_filter('in_widget_form', 'wse_widget_context_form'); function wse_widget_...
Just like you would from a widget() method: <code> function wse_widget_display_callback($instance) { $show_it = true; if(isset($instance['noHome']) &amp;&amp; $instance['noHome'] &amp;&amp; is_home()) $show_it = false; if(isset($instance['noPages']) &amp;&amp; $instance['noPages'] &amp;&amp; is_page()) $show_it = false...
Context aware widgets. My work in progress
wordpress