INSTRUCTION
stringlengths
11
999
RESPONSE
stringlengths
0
999
SOURCE
stringlengths
16
38
METADATA
dict
Wordpress author details plugin/widget Does anyone know any wordpress plugin to display the author's profile & image **similar** to the image attached !Authors Details
here are a few: * Author Bio Widget * Just Another Author Information Widget * User Bio Widget
stackexchange-wordpress
{ "answer_score": 3, "question_score": 1, "tags": "plugins, widgets" }
How can I get this request to use the Custom Post Type page template instead? I read the answer for this post which says you can do something like this: When viewing $wp_query everything seems to be working fine. That is, I'm getting 'car' post types that have the 'red' term assigned. However, the request uses the 'color' custom taxonomy template. (In my case this is taxonomy.php.) How can I get this request to use the 'archive-car.php' custom post type template instead?
Switch the taxonomy.php just like you would the single.php to support specific post custom templates. This is untested code, so it may not work - but, first get the post type $post_type = get_query_var('post_type'); So if $post_type contains post_type = 'car' then include archive-car.php like this: if ( $post_type = 'car' ) get_template_part('archive-car'); elseif ( $post_type = 'boat' ) get_template_part('archive-boat'); elseif ( $post_type = 'bike' ) get_template_part('archive-bike'); else get_template_part('regular-taxonomy'); An better alternative would be if you could establish a template redirect like in this answer, but I don't know if that's even possible. If possible, you'd redirect the taxonomy template based on the value of $post_type. How to quickly switch custom post type singular template?
stackexchange-wordpress
{ "answer_score": 0, "question_score": 1, "tags": "custom post types, custom taxonomy, templates, archives" }
edit posts through front-end It's possible to insert posts by users through the front-end by using plugins such as gravity forms or by using wp_insert_post. However, how would one handle the editing of those posts? This has to be in a safe/foolproof/secure way for users.
**WP User Frontend** and **Post From Site** plugins (among others) allow users to create and edit posts from the front-end. I am sure you can find a lot more — try this.
stackexchange-wordpress
{ "answer_score": 1, "question_score": 2, "tags": "editor, front end" }
wordpress sanitize array? I have a custom post form that sends data to a page which uses wp_insert_post to create a post. I can easily sanitize most data, but I have some troubles with my tags, I retrieve in an array: $tags = $_POST['tags']; Before using these tags as tags_input, how can I successfully sanitize all names? Thanks!
If anyone is interested, I solved it like this: $tags = $_POST['tags']; if (count($tags) > 5){ echo 'Niet meer dan 5 tags'; $stop = true; } if (is_array($tags)) { foreach ($tags as &$tag) { $tag = esc_attr($tag); } unset($tag ); } else { $tags = esc_attr($tags); }
stackexchange-wordpress
{ "answer_score": 3, "question_score": 16, "tags": "wp insert post, sanitization" }
Add title="" to A PHP Code I am using a code to call WP thumbnails and want to add a title="" tag. I would like the title to call the_title... how do I do so? I want to assign the title tribute to the image, not the link. My code: <?php if ( has_post_thumbnail() ) { the_post_thumbnail( 'thmb-archive' ); } ?>
Use the arguments available for `the_post_thumbnail(`) function as written in the codex. **Edit** : just did a test with this and it worked for me: $post_title = the_title( '', '', false);//get the title $attr = array('title' => $post_title);//set the parameter the_post_thumbnail('full', $attr);//call the function
stackexchange-wordpress
{ "answer_score": 2, "question_score": 0, "tags": "php" }
Has anyone used the wordpress plugin w3-total-cache on a Dreamhost VPS successfully? I was encouraged by Dreamhost to go with FCGI, XCache and w3 total cache. But I'm not sure what the optimal settings are, especially re: the Object and Database cache. Any suggestions? Also, I can't get this error message to go away: `Recently an error occurred while creating the CSS / JS minify cache` Nor can I get log files to show up...
> Recently an error occurred while creating the CSS / JS minify cache... Frederick Townes, the developer of W3 Total Cache, himself said that the notifications "functionality really gives too many false positives right now and should be disabled." That was 4 months ago, and still holds true today. I have this very same error showing up on some of my setups, but the rest are fine, and all this happens on the very same server. So, I'm afraid, this IS a false positive.
stackexchange-wordpress
{ "answer_score": 1, "question_score": 1, "tags": "hosting, server, plugin w3 total cache, optimization" }
How to force unlink on attached/inserted images? When users insert an image into the content, WordPress automatically wraps the image in a hyperlink that, when clicked, creates an "attachment" page showing only the image inside the theme. Can I insert a code in my theme that tells WP not to create this link?
When you insert an image it becomes an attachment, whether you link to that page or not. You can simply select 'none' in the link url field when the image is inserted, it's one of the options in the media panel.
stackexchange-wordpress
{ "answer_score": 0, "question_score": 0, "tags": "theme development, attachments" }
Adding custom class names to anchor in wp_list_pages I've the following navigation: (example) <ul id="mainNav"> <li><a href="#" class="watishet">Wat is het</a></li> <li><a href="#" class="hoewerkthet">Hoe werkt het?</a></li> <li><a href="#" class="resultaten">Resultaten?</a></li> <li><a href="#" class="onconavigator">OncoNavigator?</a></li> <li><a href="#" class="ziekenhuizen">Ziekenhuizen?</a></li> </ul> Can I add custom classes to a anchor element inside `Wp_list_pages`? because the current `wp_list_page` doesn't use a class attribute inside a anchor element. I want to add a unique class to each anchor element. For final result, I want to make a tab based horizontal dropdown menu. I looked for couple of WordPress dropdown menu plugins but there wasn't anything out there that fulfill my wishes.
Use the Wordpress Menu system, which allows you to set custom classes (Make sure you open up "Screen Options" and check the "CSS Classes" check box to see the settings)
stackexchange-wordpress
{ "answer_score": 0, "question_score": 0, "tags": "wp list pages" }
bbPress plugin - How do I add a forum description? This might be a total dummy question, but I have no idea where to enter the forum description with bbpress. I see it on plenty of other bbPress-powered forums, and the plugin is inserting `<div class="bbp-forum-description"></div>` into my table of entries, but when I create or edit a forum, I don't see a field to enter this information. Is this normal or is something strange going on with my bbPress forum?
Are you using the standalone, or the plugin? I'm not sure if there is a difference honestly, I've never touched the standalone. Anyway, I have the plugin going From my admin panel I have the option of adding/editing forums/topics/replies Clicking on Add New for forum brings up a standard WP post screen The title is the name of the forum, the post body area is the description. Is that not what you get?
stackexchange-wordpress
{ "answer_score": 0, "question_score": 0, "tags": "bbpress" }
How is WP_Query parsed to determine which template to request? I noticed that when I changed the WP_Query to ask for a certain category, the page served was `category.php`. So I'm guessing there's a block of code somewhere that decides which template to serve based on keys in the query. Where is it?
The template loader determines which template to load for a given view, there's a filter available to change this though, `template_include` as seen on the source page linked. Moved from comment to answer.
stackexchange-wordpress
{ "answer_score": 1, "question_score": 1, "tags": "wp query, page template" }
WordPress Comment posting problem I am getting trouble with WordPress comment posting. As per my WP setting there is no approval needed to display the comments under blog after posting. Most of the comments posted display immediately. But some of them do not display and need aproval from the admin / Author.
You need to check all of the following options under `Dashboard -> Settings -> Discussion`: **Before a comment appears** * Before a comment appears An administrator must always approve the comment * Comment author must have a previously approved comment **Comment Moderation** * Hold a comment in the queue if it contains ___ or more links. (A common characteristic of comment spam is a large number of hyperlinks.) * When a comment contains any of these words in its content, name, URL, e-mail, or IP, it will be held in the moderation queue. One word or IP per line. It will match inside words, so “press” will match “WordPress”. Also: do you have any comment-moderation or spam-prevention Plugins active?
stackexchange-wordpress
{ "answer_score": 0, "question_score": 1, "tags": "posts, comments" }
saving meta/custom field to tag In my custom post type what I am trying to do is say I have select drop down option called party_ad. The value of the options are obtained via an RSS feed. echo '<select name="ad_Tags" id="ad_Tags">'; foreach ($rs['items'] as $item) { echo '<option value="'.$item[title].'" '. selected( $adTags, $item[title]).'>'.$item[title].'</option>'; } echo '</select>'; I can save these data with no problems - however, what I want to be able to save the selected option as a tag to the custom post. I thought about doing it front end, ie if an option is selected then it adds the value to the post tag box, ideally though, I'd like to really do this server side.
you can use wp_insert_term() to create the tag and then wp_set_object_terms() to set it as the custom post tag: //get the tag $tag = $_POST['ad_Tags']; //create the tag $term_id= wp_insert_term( $tag, // the term 'post_tag', // the taxonomy array('description'=> 'term description','slug' => 'term-slug') ); //set the tag wp_set_object_terms( $post_id, $term_id, 'post_tag' );
stackexchange-wordpress
{ "answer_score": 2, "question_score": 0, "tags": "custom taxonomy, custom field, tags" }
Remove top admin bar whenever admin or any other user logs in a top bar menu ads up. Now I made login for everybody, so I do not want this bar. First I added `display:none` to `admin-bar.css`, but the main problem is that wordpress is still adding a white line on the top with: html { margin-top: 28px !important; } How to remove this as this is causing some design flaws.
< Has an article about it. But basically /* Disable the Admin Bar. */ add_filter( 'show_admin_bar', '__return_false' ); or also //REMOVE ADMIN BAR remove_action('init', 'wp_admin_bar_init'); I believe in your functions.php will disable it. Probably a better way than just hiding it thriough css THe reason you still get the gap with the menu hidden is because WP adds this css as well html { margin-top: 28px !important; } * html body { margin-top: 28px !important; } So a margin is added up top.... you could negate that css in yours, but just disabling the bar is probably better if that's what you want to do
stackexchange-wordpress
{ "answer_score": 12, "question_score": 5, "tags": "css, admin bar" }
How to hide wordpress default description box? I'm using custom fields in my wordpress default post area. So i don't want wordpress default description box. I mean i dont want this field. !enter image description here Instead of description box i want excerpt box there. Please help me. Thanks
you can use simple one liner with remove_post_type_support() : remove_post_type_support( 'post', 'editor' );
stackexchange-wordpress
{ "answer_score": 3, "question_score": 1, "tags": "wp admin, admin, excerpt, visual editor" }
Bulk Custom Menu and Wp-Ecommerce I have to add a lot of items in wordpress menu (lot of 2nd level items) is there any bulk menu item creation method available to do it ? is there any way to add wp-ecommerce categories in wordpress custome menu
Goto > Appearance -> Menus You can see all categories listed here including wp-ecommerce categories. Just create a new menu for your wp-ecommerce categories. Lets call it "ecomcategories". You can call this menu in your theme using this code. <?php wp_nav_menu( array('menu' => 'ecomcategories' )); ?> You can just drag and drop for sub menus. You can create unlimited menus and submenus.
stackexchange-wordpress
{ "answer_score": 1, "question_score": 1, "tags": "menus, bulk, plugin wp e commerce" }
Simplest way to add a second html editor to the post/page admin? What's the simplest way to add a second HTML editor to the post/page admin and show the content in a template? What I need is something like a custom field that supports html, but I don't need the options to name the field. And I don't need a visual editor like tinyMCE; just html will do. What I'm thinking of is simply a small text-editor box that sits under the main visual/html editor and shows the resulting html in a template via `<?php if ( function_exists('my_extra_editor_content') ) ...` with the text/html in a styleable div. Plugins like < and < offer too much in terms of functions and choices.
I use Bill Erickson's custom meta boxes or plugin like Secondary HTML Content (probably the easiest solution)
stackexchange-wordpress
{ "answer_score": 3, "question_score": 4, "tags": "page template, editor, html" }
List page for custom post type? I have created a custom post type in wordpress and have 90% of the functionality working correctly, but I am having a bit of trouble trying to create a custom listing page template. Currently it is using the default index.php page to bring out all the posts and I have tried to override this by creating a page-post-type.php page but didn't seem to work. What would be the best method for creating a custom post type listing page? Cheers, Jamie.
I think you want to create archive page for custom post type, create `archive-{post_type}.php` and it'll display you custom post type content. Also see codex: <
stackexchange-wordpress
{ "answer_score": 6, "question_score": 5, "tags": "custom post types, php" }
Create a month by month archive of pages (not posts) Is it possible to create a month by month archive of pages? I know it can be done with posts but I want to do it with pages. I want it to take the date the page was published so if the page was published in August then it would create a link called "August" which in turn when clicked will show all the pages within August. Is that possible? Or is there a better way I can categorise my pages to show them month by month? UPDATE: I use this plugin - wordpress.org/extend/plugins/advanced-custom-fields. Is there any way I could do it with pages? Is there any fields I could add to a page that could help me hack together an archive?
You could probably hack something together, but you should probably understand that, in WordPress, a basic assumption (and operating principle) is that _static Pages are not chronological_. IMHO, a better approach would be to store the content as _Blog Posts_ , and then to use Categories (or perhaps, a _custom taxonomy_ ) to identify that content, and to display it chronologically. If you have a taxonomy (core or custom) that identifies this content, you can even filter your primary Loop query, so that this content does not output with your "normal" Blog Posts.
stackexchange-wordpress
{ "answer_score": 2, "question_score": 1, "tags": "archives" }
Is there a way to figure out which action/filter invoked a function? I'd like a lightweight way to figure out what is invoking a certain action in an effort to provide logic for certain scenarios where I can't help to avoid a function invocation (for example, a new comment firing `edit_post`). Is there a way to figure out which action/filter invoked a function?
Sure, just use `current_filter()`.
stackexchange-wordpress
{ "answer_score": 4, "question_score": 0, "tags": "plugins, filters, actions" }
PHP or JS for header image rotator? I'm working on a site that is using this PHP script to load a random header image every time it reloads. I would like to use Javascript instead to allow the browser to cache images and improve load times and was wondering if there's any benefit to using the PHP script over some JS script for this scenario.
Using PHP sends less code to the end user. (a single img tag instead of all the javascript logic). If you enable browser caching settings correctly (try W3 Total Cache), once the end user has "seen" all the images, those will all be in their cache, so on the "long tail" JavaScript vs. PHP solution is equivalent.
stackexchange-wordpress
{ "answer_score": 0, "question_score": 0, "tags": "javascript, images, headers" }
wp_redirect not working when going to www version of site The following function works perfectly when logged-in visitors go to < taking them to the site homepage. When logged-in visitors go to < however, they're incorrectly redirected to < Does anyone know what's causing this? I have tried switching my site settings to use < as the WordPress and Site Address URLs, but that simply reverses the issue so it incorrectly redirects when a logged-in user goes to < // REDIRECT USERS TO SPLASH PAGE IF THEY'RE NOT LOGGED IN add_action ('template_redirect','mkm_restrict_access',1); function mkm_restrict_access() { $url = site_url('/splashpage/'); if (is_page('splashpage') || is_page('login')) { //do nothing } elseif (!is_user_logged_in()) { wp_redirect( $url ); exit; } } Thank you for your help!
Figured it out, though this is the lamest solution ever: I hooked into wp_footer instead of template_redirect. If anyone has a better solution or place to hook in I'd love to hear about it - thanks! EDIT: That wasn't the fix I thought it was. Turned out I was writing the function poorly, and did need to be using template_redirect. See Cannot get redirect working
stackexchange-wordpress
{ "answer_score": 0, "question_score": 0, "tags": "wp redirect" }
wp enqueue inline script due to dependancies Is there a way to use wp_enqueue_script() for inline scripts? I'm doing this because my inline script depends on another script and i would like the flexibility of inserting it after it's loaded. Also, It's an inline script because i'm passing php variables into the javascript (like theme path, etc) Thanks in advance.
Well, you have wp_localize_script(), but that's only for passing data. Otherwise, you can do this: function print_my_inline_script() { if ( wp_script_is( 'some-script-handle', 'done' ) ) { ?> <script type="text/javascript"> // js code goes here </script> <?php } } add_action( 'wp_footer', 'print_my_inline_script' ); The idea is that you shouldn't rely on your inline script being printed _exactly_ after the script it depends on, but later.
stackexchange-wordpress
{ "answer_score": 36, "question_score": 40, "tags": "wp enqueue script" }
Is there a way to check which template file is being loaded, if it is not a page template file? I don't see any way of testing which template file is being loaded, if the template file is not a page template. Otherwise I would use is_page_template(). For instance, I am using a home.php template file to pull in the content from multiple pages(don't ask), how would I check that home.php is the template file being used when viewing the sites root url?
Just type in some text like "Debug" into the non-Php area of home.php (the part not surrouded by ) and see if it appears. If so, you know that home.php is being used.
stackexchange-wordpress
{ "answer_score": 2, "question_score": 1, "tags": "templates, conditional tags" }
Querying multiple values from a single key Bainternet assisted me earler with the relation AND parameter. What I need to do now is determine how to query multiple vales from a single key. If I try to specify two arrays with the **same key** the query fails. Is there a way to use an array in the value?Something similar to. 'value' => array( 'Install Manual', 'User Manual' ), I've searched quite a bit with no results. This is where I'm at so far. $documents = array( 'post_type' => 'documents', 'meta_query' => array( 'relation' => 'AND', array( 'key' => 'document-type', 'value' => array( 'Install Manual', 'User Manual' ), ), array( 'key' => 'document-status', 'value' => 'current', ) ) ); query_posts( $documents ); get_template_part( 'loop', 'documents' ); wp_reset_query();
Just add `'compare' => 'IN'`: 'key' => 'document-type', 'value' => array( 'Install Manual', 'User Manual' ), 'compare' => 'IN'
stackexchange-wordpress
{ "answer_score": 2, "question_score": 0, "tags": "custom post types, query posts, array, meta query" }
Plugin that will let me specify a number of image sizes? I've designed a grid-based portfolio theme for a photographer; for each portfolio item, I need six different images, all of which have a fixed size. However, no two sizes are alike. Is there a WordPress plugin that will easily allow me to specify a number of different image sizes and choose easily between them when uploading photos? Thanks!
Have you looked at add_image_size() ? It allows you to create new custom thumbnail sizes for uploaded images. If you need to create new thumbnails for previously uploaded images, use my Regenerate Thumbnails plugin.
stackexchange-wordpress
{ "answer_score": 2, "question_score": 0, "tags": "plugins, images" }
Can you create a local wordpress network / multisite install on a mac with subdomains? Is it possible to create a local wordpress network install on a mac (10.6) using mamp with subdomains? I have tried following some instructions I came across while googling, but apache seems to get hosed when I create virtual hosts. I came across another set of instructions that said only subdirectories will work on a local install. Does anyone know which one of these is the case and have you come across a good set of instructions for how to do it? Thanks,
This tutorial was just published at DevPress by Patrick Carey: < It should help you. It has been written for Windows but you should be able to translate it into "Mac"
stackexchange-wordpress
{ "answer_score": 1, "question_score": 1, "tags": "multisite, localhost, local installation, mac" }
How can I restrict changing the max nested comment levels option to super admins? I have an older theme that I've modified to support threaded comments. I would like the individual admins in my multisite install to be able to choose whether threaded comments are enabled. However, I'd like to restrict the ability to choose the maximum number of levels to super admins. Looking at the capabilities, it seems that all capabilities for the settings screen are grouped together as one capability. Is it possible to restrict just this single option so that it is forced to be the same static value across the entire blog network?
There is only one hook for threaded comments depth - `thread_comments_depth_max` and it sets max value for depth ( default is 10 ), you can use this filter and set max depth fox non-Super Admins number that you want. if ( ! current_user_can( 'manage_network' ) ) { mamaduka_thread_comments_depth_max( $maxdeep ){ return 5; // or any number you want } add_filter( 'thread_comments_depth_max', 'mamaduka_thread_comments_depth_max' );
stackexchange-wordpress
{ "answer_score": 1, "question_score": 0, "tags": "multisite, comments, capabilities" }
Redirect Restricted Page to 404 Is there a way to show a 404 page if the current logged in user does not have the right clearance to view the page? I am looking for a PHP method, something like if( !current_user_can('administrator') ) { show_404(); exit(); } I have thought about using a redirect, but I would like to keep the url the same.
I was able to display a 404 error by using the following code in my header. <?php global $wp_query; $wp_query->set_404(); status_header( 404 ); get_template_part( 404 ); exit(); ?> To break it down: `$wp_query->set_404()`: tells the wp_query this is a 404, this changes the title `status_header()`: sends a HTTP 404 header `get_template_part()`: displays the 404 template
stackexchange-wordpress
{ "answer_score": 73, "question_score": 30, "tags": "redirect, 404 error" }
Is it possible to sign in with user_email in Wordpress? is it possible to sign in with **user_email** instead of **user_login** , please ? Thanks.
Here's how we do it: $user = get_user_by('email', $email); if (wp_check_password($password, $user->user_pass, $user->ID)) { // Login successfull, redirect if needed wp_set_auth_cookie($user->ID); } Assuming of course that you got the $email and the $password variables from a POST request or something :)
stackexchange-wordpress
{ "answer_score": 5, "question_score": 5, "tags": "login, forms, users" }
Looking for a simple e-commerce plugin I looking for a simple Wordpress e-commerce plugin which will just associate a downloadable product to a post (here a custom post type) and handle the payment with Paypal and the download page. There are a lot of different plugin but they always provide a complex catalog, create a lot of useless page and don't provide a simple way to add in my post a simple "buy now" button which go directly to payment. Are you aware of a plugin which meets these needs?
You may want to consider Cart66. I bought a single site license a few weeks back as I was looking for something along a similar line to you. It doesn't force a bunch of bespoke templates on you, instead, you have to create each product through a custom post (which is what you are doing anyway). However the big benefit of this is that you have near total control over how your product pages look. Cart66 comes in two flavours - free (Cart66 Lite) or if you want more features and support you can try one of the site license options. So far I've found it to be very straightforward and more flexible than a lot of the competition. Hope this helps
stackexchange-wordpress
{ "answer_score": 0, "question_score": 0, "tags": "plugin recommendation, e commerce" }
Wordpress time queries When we setup the timezone in wordpress settings page. Does it changes the server time? If I call `time();` does it returns unix time according to timezone setup in the settings page? I have checked this page here How to get WordPress Time Zone setting? So, if i need to show suppose the current time of a neighborhood site what modification i have to do with the output of `time();` function? The php `time();` returns the time in the server. So is that depends on where my host belongs? Thanks in advance!
WordPress tries to set PHP environment to UTC timezone. Usually it is more reliable to use time zone-aware WP functions, such as `current_time()`, rather than vanilla PHP functionality.
stackexchange-wordpress
{ "answer_score": 1, "question_score": 0, "tags": "php, timezones" }
Using $themename Variables Is it a bad idea to set your themename and shortname as variables to be used in the various functions of a theme? Example: $themename = mytheme; $shortname = mth; /** * Get our wp_nav_menu() fallback, wp_page_menu(), to show a home link. */ function toolbox_page_menu_args($args) { // some code } add_filter( 'wp_page_menu_args', $themename . '_page_menu_args' );
You can do it easier and without polluting the global namespace: `get_option('template');` gives you the (parent) themes name. If you want the child themes name, use `get_current_theme();`. You could also use a constant across your theme files: `define( 'YOUR_PREFIX-THEME_NAME', get_current_theme() );`
stackexchange-wordpress
{ "answer_score": 1, "question_score": 1, "tags": "functions, variables" }
Can't login after my site was moved to a new server I'm working on a site which is not attached to a domain name yet, so I access to it through an ugly URL like old_server.something.myprovider.co.uk/.../.../ My provider moved me to a new server so I now have to type : new_server.something.myprovider.co.uk/.../.../ Problem is, when trying to access wp-admin, WordPress performs some sort of redirection to the old address and of course it doesn't work anymore. So I can't access the login page. Is there a way to change the server URL in WordPress without accessing the dashboard ?
Yes cou can change it by accessing the database of your wordpress. It's located in the `wp_options` table of your wp' database. You'll have to change two values; the **`siteurl`** (line 1) and the **`home`** (line 37). You can access it through the admin panel of your host and/or sometimes directly by typing in your browser the `DB_HOST` value you entered for the installation of the blog, now written in your `wp_config.php` file at the root of your site. Then just use the login and password also written in this file. This should do it. EDIT: i recommend the use of this kind of plugin to clean completely the database to change all your < to <
stackexchange-wordpress
{ "answer_score": 4, "question_score": 3, "tags": "urls, server" }
Is there a WordPress form plugin that can easily be configured for Google Analytics goals? I don't want to have to make use of a destination url, so ideally I would like to be able to add the onclick="_gaq.push(['_trackPageview', '/G1/whatever']);" event to the submit button on the form.
This seems to be a valid answer: Use Contact Form 7. In the "Additional Settings" box enter the following: `on_sent_ok:"_gaq.push(['_trackPageview', '/G1/whatever']);"` Where `/G1/whatever` is the Goal URL you set on your Google Analytics options page.
stackexchange-wordpress
{ "answer_score": 1, "question_score": 0, "tags": "forms, google analytics" }
How to make that all posts with a category belong also to another I'd like to make that all my posts in the category A belong also to category B (so after that they would belong both to A and B), is there any plugin or MySQL query that could allow me to do that easily?
You can bulk edit posts in the admin. I have never tried more than 500 or so but you can display 999 per page. To have more than the default 20 click screen options. Click posts-->filter by Category A Click Edit---> select all posts ( clicking top square next to "title")-->Apply Click Category B and Update.
stackexchange-wordpress
{ "answer_score": 0, "question_score": 0, "tags": "categories, mysql" }
How to create a cumulative posts and members count I need to show my users cumulative posts and members registered count by date. It has to be displayed in an array format like this **for posts** array(array(2011,08,02), 500) array(array(2011,08,03), 520) array(array(2011,08,04), 540) array(array(2011,08,05), 560) array(array(2011,08,06), 580) the same case for members iam using wordpress.com stats to for statistics, i cant figure out how to do this, could anyone help me...
Here is a very crude script I've knocked up to get what you are after: <?php require('wp-blog-header.php'); $posts = get_posts('numberposts=-1&order=ASC'); $posts_times = array(); foreach ($posts as $post) { $post_time = strtotime($post->post_date); $offset = $post_time % (60*60*24); $post_time -= $offset; $posts_times[$post_time]++; } $keys = array_keys($posts_times); $running_count = 0; $end_data = array(); for($i = $keys[0]; $i <= $keys[(count($keys)-1)]; $i += (60*60*24)) { $running_count += $posts_times[$i]; $end_data[] = array( array(date("Y", $i), date("m", $i), date("d", $i)), $running_count ); } echo "<pre>"; print_r($end_data); ?>
stackexchange-wordpress
{ "answer_score": 0, "question_score": -1, "tags": "posts, array, statistics, registered" }
how to get tax percentage in wp-ecommerce I need to be able to get the tax percentage for the cart in wp-ecommerce. I have tried using: $wpsc_cart->tax_percentage but it does not return a value. Has something changed in the newer versions of wp-ecommerce?
`$wpsc_cart->tax_percentage` contains the tax percentage for me using the latest version 3.8.6. make sure you have enabled tax and added a tax rate under settings > store > taxes.
stackexchange-wordpress
{ "answer_score": 0, "question_score": 0, "tags": "plugin wp e commerce" }
I want to display author gravatar on posts. How to do this? I just want to add author gravatar near the name of the author. I know that I have to add something in the single.php file, but what to add? Thanks!
If you're in the Loop: `echo get_avatar( get_the_author_meta('ID') );`
stackexchange-wordpress
{ "answer_score": 4, "question_score": 3, "tags": "gravatar" }
Display custom field value as a hyperlink Using the following code in order to display custom field value, how can I automatically make it into a hyperlink? <?php $custom_fields = get_post_custom($post_id); //Current post id $my_custom_field = $custom_fields['website']; //key name foreach ( $my_custom_field as $key => $value ) echo $key . " => " . $value . "<br />"; ?> Presently if website value is set to < then it would display < instead i'd like for it to display as Click Here where it hyperlinks instead.
<?php $custom_fields = get_post_custom($post_id); //Current post id $my_custom_field = $custom_fields['website']; //key name foreach ( $my_custom_field as $key => $value ) echo $key . " => <a href='" . $value . "'>Click Here</a><br />"; ?>
stackexchange-wordpress
{ "answer_score": 3, "question_score": 0, "tags": "custom field" }
Display two custom values from a post I'm using the following code to display a custom value. The custom value being 'website' <?php $custom_fields = get_post_custom($post_id); //Current post id $my_custom_field = $custom_fields['website']; //key name foreach ( $my_custom_field as $key => $value ) echo $key . " => <a href='" . $value . "'>Click Here</a><br />"; ?> However, before the 'Click here' i'd like to include another custom value, thumb. So the output would be: Value of custom field thumb Value of custom field website Thanks.
How about: $thumb = get_post_meta( $post_id, 'thumb', true ); $url = get_post_meta( $post_id, 'website', true); echo "<a href='$url'><img src='$thumb' /></a>"; The `get_post_meta()` function is ideal when you know ahead-of-time the names of the fields you want to retrieve. Setting the third parameter to `true` tells it that you want to return a single value, and not an array of values (it's possible to set multiple values using the same meta key, and get an array of values back).
stackexchange-wordpress
{ "answer_score": 2, "question_score": 1, "tags": "custom field" }
Are there functions for file paths, instead of just urls Is there any equivalent to functions like `plugins_url()` and `content_url()` that give you either the relative paths or the file path. For instance, instead of > < I want: > /Users/username/Sites/wordpress-3.2/wp-content I know that I can build this path using the `ABSPATH` constant, but I'm specifically interested in learning if there are built in functions to handle this. In the meantime, I'll probably just write a function to swap the url for the abspath. EDIT: Here's the simple function that I wrote to handle this: function get_file_path($url) { return str_replace(site_url(), ABSPATH, $url); } Seems to do the trick, but I'd much rather use built in functions if available.
There aren't any for plugins, but you can (and should) use WP_CONTENT_DIR, instead of ABSPATH. For themes you have locate_template().
stackexchange-wordpress
{ "answer_score": 1, "question_score": 1, "tags": "plugins url" }
Using add_action before add_filter on a plugin? I'm writing a plugin and having a problem. I have `add_action('publish_post', 'sender');` and I want this function to run first before the add_filter function, although it won't. Is there a way to do this? I've tried moving the add_filter below add_action but that doesn't work. Also pasting the add_filter one into the add_action function doesn't work. Thanks for the help. Edit: For example, if this would work it would be great. if (add_action('publish_post', 'sender')) { add_filter('wp_insert_post_data','changePost','99',2); } But it doesn't and somehow still runs the add_filter function first.
It doesn't matter the order in which you call `add_action()` and `add_filter()`. What matters is the order in which the corresponding `do_action()` and `apply_filters()` are called. So, if `apply_filters('wp_insert_post_data')` is run before `do_action('save_post')`, tough luck. You'll have to think of another way to achieve the desired result.
stackexchange-wordpress
{ "answer_score": 3, "question_score": 0, "tags": "plugins, actions, filters" }
How can I duplicate "Add Custom Field" with just JavaScript? I frequently need to add several Name-Value pairs to the Custom Fields of a post. At present I add these one by one, by entering the Name and Value and clicking Add Custom Field. I'd like to speed this up by entering several pairs into a single box (textarea, prompt, whatever), and have some JavaScript parse them and add them as though I had entered them manually. (Why JavaScript? Because I don't have access to edit any PHP or install any new plugins. I'm doing this browser-side, with Greasemonkey.) As far as I'm aware, the Add Custom Field button submits the Name-Value pair with AJAX, but I'm not familiar enough with jQuery or WordPress to find the exact code that does this so that I can copy it. Any pointers would be much appreciated. Thanks!
Quick search shows that related part of form is generated by `meta_form()` function. Start from there I guess. Also note that you will need to retrieve from source and submit nonce that protects that form. I am not sure if submitting single field invalidates the nonce there, but that also might be the case.
stackexchange-wordpress
{ "answer_score": 0, "question_score": 0, "tags": "custom field, javascript" }
Moving variables from one page to another How can I link to another WordPress page but move variables to it as well (preferably not through the address bar)? For instance, I have on one page a list of shops in which a user should be able to click on a shop, which would then open the shop page with the correct data. So the shop's id needs to move from the shops list page to the shop page.
you could `POST` the shop id to the target page. otherwise- cookie, session. or just fetch it on the list page via ajax. **edit -** a simple post request via a form: in your source page: <form action="b.php" method="post"> <input type="hidden" name="id" value="42" /> <input type="submit" /> </form> in the target page b.php: <?php if( isset($_POST['id']) ): echo $_POST['id']; endif;
stackexchange-wordpress
{ "answer_score": 1, "question_score": 2, "tags": "redirect, pages, variables" }
Using wp_mail() - verify that email was sent? When using `wp_mail()`, is there any way to verify that the email was sent correctly?
As you have probably found, for `wp_mail()`: > A true return value does not automatically mean that the user received the email successfully. A possible workaround is to add an email address that you have access to in the recipients list, and if the one email address receives the mail you can be reasonably (although not 100%) certain that the message was sent.
stackexchange-wordpress
{ "answer_score": 3, "question_score": 4, "tags": "wp mail" }
Install theme on multiple domains i'm hosting several sites. they all have the same base theme that i need to install. I want to develop this theme and have them updated on all the sites simultaneously. I have the following folder structure /theme/ \ mytheme /domain/ \ foo.com \ foobar.com \ foosite.com Would there be any issue with symlinking each site with my theme into each site's `wp-config/theme/` folder? Not interested in multisite. Had to developed sites seperately.
That will work fine - just make sure they all have read and write access to that shared folder. The symlink command should be: ln -s StackOverflow question: Can two different WordPress blogs on the same server use a common theme folder?
stackexchange-wordpress
{ "answer_score": 2, "question_score": 2, "tags": "directory" }
Best way to get user id for get_users function? I'm trying to make a table of users by role type. What is the best-practices method of getting the user id? My goal is to print each users first & last names, username and email. What I have now: $get_admins = array( 'blog_id' => $GLOBALS['blog_id'], 'role' => 'administrator', ); $blogusers = get_users($get_admins); foreach ($blogusers as $user) { $userid = get_userdata($bloguser->user_id); $user_info = get_userdata($userid); echo '<tr>'; echo '<td>'. $user_info->user_firstname .'</td>'; echo '<td>'. $user_info->last_name .'</td>'; echo '<td>'. $user->user_login .'</td>'; echo '<td>'. $user->user_email .'</td>'; echo '</tr>'; } note: In my example above getting the user id does not work. Codex reference: get_users()
Your code doesn't work because you're using `$bloguser` instead of `$user`. And there's no point in calling get_userdata() since get_users() already returns user objects: foreach ($blogusers as $user) { echo '<tr>'; echo '<td>'. $user->first_name .'</td>'; echo '<td>'. $user->last_name .'</td>'; echo '<td>'. $user->user_login .'</td>'; echo '<td>'. $user->user_email .'</td>'; echo '</tr>'; }
stackexchange-wordpress
{ "answer_score": 2, "question_score": 0, "tags": "users" }
Hosting plugin Google Code with auto update? I've been developing a WordPress plugin for a friend who needs something completely out-of-the-box, at least what WordPress is cornerned. Now, I could use the WordPress plugin repository to host this, but I've already hosted this project on Google Code and was wondering if there was any fancy code which would make WordPress check for updates from that repository. I feel this plugin isn't really for the general WordPress crowd and don't want to clutter the directory. So I was wondering if this was possible. Thanks! Davey
Yes, this is possible take a look at WPML to see how its done, also there is an an entire chapter in Professional WordPress Plugin Development to show you how its done and here is the code that goes with it
stackexchange-wordpress
{ "answer_score": 3, "question_score": 2, "tags": "plugins, directory" }
display only the title of the post into a certain category My site works with phrases and texts In one category, the users send statements and debate about it. In another category, are sent statements and debate about them. I would like to show only the title of the post into a certain category, since they are not phrases and content needs, just the title. in another category, the pots are usually shown, with title and content. as might be the code in single.php if you are in category X displays content and title Y if the category content is not displayed, only the title
resolved, link : codex.wordpress.org/Category_Templates
stackexchange-wordpress
{ "answer_score": 0, "question_score": 0, "tags": "posts, title" }
Why is my content missing from homepage? On my website < all the posts and everything on my home page are missing. Can you anybody tell me how to fix this? Thanks! (If it helps, I'm using Wordpress 3.2.1.)
I cannot see any missing content. Are you sure you weren't just having server issues at the time of posting this? Did you check it in other browsers? Having said that, this is not a real question and I have voted to close.
stackexchange-wordpress
{ "answer_score": 0, "question_score": 0, "tags": "posts" }
How to remove screen options and help links in the admin area? I would like to remove screen options and help links in my admin area. How to remove that thing?. This is what i want to be removed. !enter image description here Thanks.
There are several plugins that can do that: 1. Adminimize, you can remove it even on role base 2. Admin Trim Menu
stackexchange-wordpress
{ "answer_score": 3, "question_score": 9, "tags": "wp admin, admin, screen options" }
query for filtering published posts? i need to filter count based on a date and post_status = 'publish', how to write a query to filter, as far as now i have filtered based on date, what is the query need to filter based published post. > $table1 = $wpdb->prefix.'posts'; $sql = 'SELECT COUNT(ID) AS count FROM '.$users_table1.' WHERE DATE(post_date) < "'.date('Y-m-d',time()).'"'; $result = $wpdb->get_var($sql); iam stuck with this, do anyone know this?
You can add this to the WHERE clause, just after your filter by post_date: AND post_status = "publish"
stackexchange-wordpress
{ "answer_score": 1, "question_score": 0, "tags": "posts, query posts, mysql, wpdb" }
Password Protected page not asking for a password I have set a page to be password protected in the admin, but for some reason WP is not asking for the password when viewing the page. It definitely isn't a plugin as I have confirmed the behaviour with the plugin folder renamed. I have been testing it in Chrome w/incognito. The page is using a custom template, which may be the problem? No other templates I have looked at though seem to display any password logic.
The answer to this question was simply that the built-in password protection does not apply if you are using a custom template that doesn't include `the_loop()`. Lesson learnt.
stackexchange-wordpress
{ "answer_score": 2, "question_score": 1, "tags": "password, bug" }
Can I enable/disable/hide plugins on a per-site basis in multisite? I'd like to be able to enable/disable plugins on a per-site basis in multisite, similar to the way that themes are per-site configurable. Is this currently possible? (For instance, I don't particularly want people seeing the Domain Mapping plugin but want them to be able to enable Gravity Forms.)
### Multisite Plugin Manager > The essential plugin for every multisite install! Manage plugin access permissions across your entire multisite network.
stackexchange-wordpress
{ "answer_score": 5, "question_score": 3, "tags": "plugins, multisite" }
Importing users? From another wordpress site Is there a way to import users from another wordpress site? Both sites are new. I just don't want to go through the trouble of adding the same users profile information and password.
I think you have two options (third if you find any plugins). 1. I think if you export data from one WP, the users are also copied. The drawback is that you have to import all the content as well. 2. The second option is to export the users from MySQL using PHPMyAdmin. Just export the user table. If you want to include privilidges as well, you have to export wp_usermeta as well.
stackexchange-wordpress
{ "answer_score": 3, "question_score": 4, "tags": "users, import" }
How can i create page through plugin I am developing WordPress plugin.This plugin has own login system.Which means users can register into the system. Then they can login. if the user login, i want to redirect them to their own profile page.This page should not be accessible while user is in logout or plugin is in inactive.So how can i create page through plugin. Thanks
If the page needs to be added and available on the front end, you can use wp_insert_post() to create the page, the use a conditional to only display it if the user is logged in: `if(is_user_logged_in()) { // display content }`
stackexchange-wordpress
{ "answer_score": 4, "question_score": 0, "tags": "plugins, plugin development" }
Set user after wp_create_user? I have a form that creates a new user by using: wp_create_user() This works, but after this I want to auto log in the user. I tried using: $creds = array(); $creds['user_login'] = 'username'; $creds['user_password'] = 'password'; $creds['remember'] = true; $user = wp_signon( $creds, false ); if ( is_wp_error($user) ) { $msg = $user->get_error_message(); die($msg); } else { $output_form = true; } But this creates a "headers already sent" error message because it's not at the top of the page. Is there a way to auto log in the user after I have created the user?
Here is a function I wrote that hooks into the gravity forms create user form but it can be added to whatever action hook your wp_create_user function is attached to. function my_auto_login( $user_id ) { wp_set_auth_cookie( $user_id, false, is_ssl() ); wp_redirect( admin_url( 'profile.php' ) ); exit; } The important part is `wp_set_auth_cookie`. This has to fire after the user is the best (only?) way to auto login a user without filling out the login form.
stackexchange-wordpress
{ "answer_score": 3, "question_score": 3, "tags": "users" }
Is 'name' a reserved word in URL's? I'm creating some custom templates and I keep running in to a problem where I get'Page not found'. After a bit of debugging, I discovered that I only get this if my URL contains `www.mysite.com/custom_page/?name=donkey_boy`. If I use `www.mysite.com/custom_page/?full_name=donkey_boy`, the page loads as it should. Does that mean that `name` is a reserved word?
I guess this'll solve your query... WordPress Reserved Terms. Just search for 'name', it's there.
stackexchange-wordpress
{ "answer_score": 5, "question_score": 2, "tags": "urls" }
Printing out Category and all Category Children on category.php A new site i'm making is going to use extensive use of the categories, so here's what i'm trying to accomplish: Main Category Name (Link) List of Sub Categories (All Links) When i'm on a sub-category page I want it to look like the Main Category page just with the sub-categories highlited. Is that possible?
That's damn simple, see here: < . The sample downhere should work: $kids = get_categories(array('child_of'=>get_query_var('cat')));
stackexchange-wordpress
{ "answer_score": 0, "question_score": 0, "tags": "categories" }
Change login error messages took a look at the questions but I couldn`t find a similar one. I need to change the custom error messages that are displayed when user tries to login with a wrong username or password. Like, change this: " **ERROR** : The password you entered for the username **%1$s** is incorrect. Lost your password?" to this "Wrong information" (just an example) I tried to use the "add_filter" but I`m not familiar with it, so, any help will be appreciated! Thanks
you can do that using `login_errors` filter hook and here is how: add_filter('login_errors','login_error_message'); function login_error_message($error){ //check if that's the error you are looking for $pos = strpos($error, 'incorrect'); if (is_int($pos)) { //its the right error so you can overwrite it $error = "Wrong information"; } return $error; } ## update: i just tested the code and it works fine just pasted the code in my theme's functions.php file without changing anything with the .po file !enter image description here
stackexchange-wordpress
{ "answer_score": 23, "question_score": 21, "tags": "errors" }
Having admin on different host breaks attached images Sometimes it's nice to have admin on a different host (admin.mysite.com) then the actual site (www.mysite.com). If admin.mysite.com is not publicly accessible, then images attached to posts on admin.mysite.com will not be accessible on www.mysite.com since the url to the attached image is absolute and contains the domain (admin.mysite.com). Is there any way to fix this? The nicest way would be if the url to an attached media would be relative and not absolute.
I found another way of doing this. I added the following to functions.php: function yoursite_get_relative_attachment_path($path) { $paths = (object)parse_url($path); return $paths->path; } function yoursite_wp_handle_upload($info) { $info['url'] = yoursite_get_relative_attachment_path($info['url']); return $info; } add_filter('wp_handle_upload', 'yoursite_wp_handle_upload'); function yoursite_wp_get_attachment_url($url) { return yoursite_get_relative_attachment_path($url); } add_filter('wp_get_attachment_url', 'yoursite_wp_get_attachment_url'); This way wordpress stores the relative URL in the db. For more detailed instructions see the blog where I learned about this.
stackexchange-wordpress
{ "answer_score": 1, "question_score": 2, "tags": "admin" }
Show recent posts starting at a specific number archive Is there an argument to define how many posts ago will be displayed in "recent" posts. Could I add something to this and define a specific number of posts ago to start the loop? $args = array( 'numberposts' => '5' ); $recent_posts = wp_get_recent_posts( $args ); So for example I have a page of archives with their excerpts for the last 5 posts. In the sidebar I would like to show other posts from that category, starting with 6 posts ago.
`wp_get_recent_posts` basically uses `WP_Query`, so you can use the `offset` parameter. So something like, $args = array( 'numberposts' => '5', 'offset' => 5 ); Reference: <
stackexchange-wordpress
{ "answer_score": 2, "question_score": 0, "tags": "php, loop, recent posts" }
How does one go about converting custom post type to post format? I have a blog which uses custom post type 'aside' for aside posts. Now that wordpress has custom post formats, I want to use the 'aside' post format instead. Is there a way to convert post typess to post formats? I'm looking for code/tool similar to wordpress's in-built tool which lets one convert from categories to tags.
There are a couple of plugins available that will allow you to do this. < or < should get the job done for you.
stackexchange-wordpress
{ "answer_score": 1, "question_score": 0, "tags": "custom post types, theme development, post formats" }
Display last comments on home page Is there a way to select and display the last X approved comments regardless of which posts or categories they belong to ? I just want to show on my home page the last comments added on my site, but I can't find anywhere how to do that.
A slightly more complete and less abrupt answer. <?php $args = array( 'status' => 'approve', 'number' => '5' ); $comments = get_comments($args); foreach($comments as $comment) : // display any of the following indexes as you'd like var_dump($comment); endforeach; ?>
stackexchange-wordpress
{ "answer_score": 1, "question_score": 0, "tags": "comments, homepage" }
Error establishing a database connection error on a site that was working fine previously A site that was working fine previously is now getting an error, Error establishing a database connection I have dealt with this error while creating new wordpress sites(when there was something wrong with the `config` file). This time, the error occurred when the user upload a file to `public_html` folder. Can anyone suggest me **what would have gone wrong** and **how to fix it**? Thanks in advance.
Did you checked your wp-config.php file? Is database name or password is changed? wp-config.php file is located on the root directory you installed wordpress. Open the file and you will see database password, username etc that wordpress use to connect your database. Check the username, passwords are correct. /** The name of the database for WordPress */ define('DB_NAME', 'your_database_name'); /** MySQL database username */ define('DB_USER', 'your_database_username'); /** MySQL database password */ define('DB_PASSWORD', 'your database password');
stackexchange-wordpress
{ "answer_score": 2, "question_score": 0, "tags": "errors" }
How to save an array with one metakey in postmeta? I have an array saved in postmata, each array key become a metakey. I want to change the code to save the whole array with one metakey. How to do that? Thanks! $poddata = Array( 'pod_id' => $this->pod_id, 'url' => $this->url, 'name' => $this->name, 'description' => $this->description, 'service' => $this->service, 'status' =>$this->status, 'price' => $this->price ); foreach ( $poddata as $k => $v ){ if ( get_post_meta( $this->id, $k ) == '' ) add_post_meta( $this->id, $meta_box, $v, true ); elseif ( $v != get_post_meta( $this->id, $k, true ) ) update_post_meta( $this->id, $k, $v ); elseif ( $v == '' ) delete_post_meta( $this->id, $k, get_post_meta( $this->id, $k, true ) ); }
You don't need to loop through the values. Just use `update_post_meta($post_ID, {key}, {array of vals})`, it should do! <?php $poddata = Array( 'pod_id' => $this->pod_id, 'url' => $this->url, 'name' => $this->name, 'description' => $this->description, 'service' => $this->service, 'status' =>$this->status, 'price' => $this->price ); //Update inserts a new entry if it doesn't exist, updates otherwise update_post_meta($post_ID, 'poddata', $poddata); ?> Thats it! When you fetch it for usage, do the following: $poddata = get_post_meta($post_ID, 'poddata'); $poddata is the array of values.
stackexchange-wordpress
{ "answer_score": 32, "question_score": 20, "tags": "post meta" }
Is there a function to list all uploaded images? How can I add one? Is there a PHP function that will return an array of all of my uploaded images? Or, failing that, how bout just my uploaded files? The end goal is to display a slideshow on my homepage: have it rotate through each image, one at a time. Almost like an animated gif, in an infinite loop/cycle.
uploaded files are stored as attachment post type in WordPress. Use get_posts() and query for all attachments: $args = array( 'post_type' => 'attachment', 'numberposts' => -1, 'post_status' => null, 'post_parent' => null ); $all_attachments = get_posts( $args ); EDIT - you can also set `post_mime_type` in get_posts to get all of type 'image/jpeg' for example.
stackexchange-wordpress
{ "answer_score": 2, "question_score": 0, "tags": "plugins, php, jquery, uploads, slideshow" }
Facebook Share Thumbnail From the past few weeks I am noticing that when I share my posts on facebook, the thumbnail is not coming, I am keeping a featured image for my posts, but when I share it on facebook it shares the link without thumbnail, I tried using several code which I found on google, but none of them works. I am using twenty eleven theme with latest WP Anyone who can help me?
You need to add Open Graph meta tags to your `<head>`. See `og:image` below... <meta property="og:title" content="35% of LinkedIn Users Check The Site Daily" /> <meta property="og:type" content="article" /> <meta property="og:url" content=" /> <meta property="og:image" content=" /> <meta property="og:site_name" content="The Realtime Report" /> <meta property="og:description" content="Now the No.2 ranked social networking site - as of June 2011 - LinkedIn has a highly engaged, profession-focused audience, according to new research from Lab42. Based on a survey of LinkedIn users in July 2011, the data reveals that 32% of users check the site several times a week, and more than a third - 35% - check the site daily." />
stackexchange-wordpress
{ "answer_score": 2, "question_score": 1, "tags": "posts, facebook" }
How to change order of menu items How can I change the ordering of menu items -- for example to make 'Wordfruit Copywriters' appear before 'How can you sell more of your product?' here: < Thanks, Richard
Go to appearance -> menus section. Here you can create menus, add menu items and drag them around to place it to your desired place. Alternatively, you can set up the menu order of a page. Just click edit page and you will see the menu order it should be under **Page attribute** section.
stackexchange-wordpress
{ "answer_score": 9, "question_score": 5, "tags": "menus" }
Setting a url for a page Is there a way to set a url for a page, as per the following example: I want to change this url: < To: < Is this possible? (I clicked Permalink Settings and specified 'copy-critiques' as Category Base, but this didn't do the trick...) Thanks, Richard
you can set the permalinks to `%postname%`, however this would change the permalinks for the whole site; and you can set the individual page permalink, which is normally derived from the page title, when you edit the page. btw: pages don't have a category base.
stackexchange-wordpress
{ "answer_score": 2, "question_score": 1, "tags": "urls" }
Changing the homepage Is it possible to change the Home page so it's not a blog, but a page? And also is it possible to change the name of the homepage? If yes, how is this done? Thanks, Richard
To change the **site Front Page** to be a _static Page_ : * Go to `Dashboard -> Settings -> Reading` * Change **Front page displays** from _Your latest posts_ to _A static page_ * In the dropdown beneath this option, select the static Page to use as your Front Page. * If you want to display your blog Posts somewhere, select a static Page to use to display them. To change the **title** of your Front Page: * The Front Page will assume the _Page Title_ of whatever static Page you selected above.
stackexchange-wordpress
{ "answer_score": 1, "question_score": 2, "tags": "homepage" }
Do all themes accommodate all features? Do different themes accommodate different features, or can all themes accommodate any feature? I.e. do I need to bear in mind what features I'll need when I choose a theme, or are themes only how things are laid out visually? Also, is it possible to change the image in the default theme 'Twenty Eleven'? Thanks, Richard
No, not all Themes accommodate all features; but to answer that question more precisely, you'll need to be more specific about what you consider to be "features". Things that are generally considered _Theme_ features are fairly well-represented by the list of filter tags for WORG repository-hosted Themes. You'll notice that these things generally deal with _presentation_ of content. Things dealing with _creation_ or _management_ of content are generally considered _Plugin_ territory, and generally speaking, any Theme _should_ accommodate such Plugins. (Your second question is unrelated, and should be asked in a separate question.)
stackexchange-wordpress
{ "answer_score": 1, "question_score": 0, "tags": "themes" }
Theme change only in CSS and a few images We created a theme that has a lot of changes in it. Now we want to enable that theme on our site in different colors, and a few images different: !enter image description here What we're doing is duplicating the theme, and then making a few changes in the CSS, and change a few images. But it seems an overkill - to copy the all the theme files just to make so few changes. Moreover, if we ever have to change something functional in the theme, we'll have to go through all the duplications and apply it. Is there a way to give users the option of changing colors & images, without duplicating the theme?
We ended up using child themes, mainly because the site manager wanted to get a preview of the color change that would occur when changing CSS, and that was done best by the theme switching page, but also because it was easier...
stackexchange-wordpress
{ "answer_score": 0, "question_score": 1, "tags": "theme development" }
Is it possible to change the image in the default theme 'Twenty Eleven'? Is it possible to change the image in the default theme 'Twenty Eleven'? If yes, how is this done?
Just replace the default header image, under images/headers/path.jpg in your theme folder.
stackexchange-wordpress
{ "answer_score": 3, "question_score": 0, "tags": "theme twenty eleven" }
Adding a list of social media links I want to add a list of my social media pages. What ways are there to do this? Are there widgets designed for this?
There are a couple of ways to do this. You can do as Chris Carson suggested and manually add them as a text menu. You can also make a text widget and use icons with links to the various services. If you're looking for something a little more robust, there's also a couple plugins and related services, such as AddThis, that do the icon and linking work for you and also let you track hit counts and such if you sign up for their free services.
stackexchange-wordpress
{ "answer_score": 1, "question_score": 0, "tags": "facebook" }
In theme Twenty Eleven, do the default images rotate randomly? In theme Twenty Eleven, do the default images rotate randomly, or with some sequence? As far as I can see, I think it's random, but there might be some pattern/sequence that I didn't notice.
the header image is picked at random; see this line in /wp-includes/theme.php line 1476: `$random_image = array_rand( $headers );` out of interest: why are you asking, and what difference would it make?
stackexchange-wordpress
{ "answer_score": 1, "question_score": 0, "tags": "theme twenty eleven" }
How can I have two content titles? I'm facing a design, that has two titles. I have no clue how can I two titles in wordpress. In a nutshell: Creating a page, there you can set the title. How can I have two titles there? Or similar effect? !enter image description here
Strictly speaking title is column in posts database table so it is not easy (or makes sense) to add one more title. But it is trivial to emulate by using custom field to store additional title (or anything else).
stackexchange-wordpress
{ "answer_score": 3, "question_score": 1, "tags": "pages" }
How to dynamically change theme's slogan from admin? how can achieve this functionality. That I can change the themes "slogan" from admin and I don't have to go edit the themes source files. I think that there is some theme options functionality. But how to use it and maybe somebody can point me to the correct path. Added screenshot to clarify what I mean under slogan: !enter image description here
In wordpress that's a tagline.. maybe a plugin like this < can help you.
stackexchange-wordpress
{ "answer_score": 2, "question_score": 0, "tags": "themes, options" }
I can't access my admin page after changing main url I have change the main URL of my wordpress theme. I accessed `Admin area => Settings => and change my URL from : www.sampleURL.com to www.sampleURL.com/?page_id=2` and now every time I enter `www.sampleURL.com/wp-admin` i get directed to `www.sampleURL.com/?page_id=2` Please help!
Not sure why you would want to make that change, but if worst comes to worst, you can change it back via the database. Assuming you can access your MySQL database directly, simple navigate to the wp_options table and change the value of `siteurl` and/or `home` to your desired values. EDIT: Alternatively, if you can access your code, in the theme's functions.php file, add the following code. update_option( 'siteurl', ' ); update_option( 'home', ' ); Obviously, swap < with your URL. Then refresh the home page of your site a couple times. Once everything is back to normal, remove this code.
stackexchange-wordpress
{ "answer_score": 4, "question_score": 2, "tags": "wp admin" }
Check if jquery library exist How to check if jQuery library exist in head tags? <head> <script type="javascript/text" src=" </head> and if not exist how do I load in head tags the jquery library, I'm doing a plugins and I want to load my plugins script in jQuery and also do able to check if jQuery library exist so my jQuery script will run
scripts and styles should never be embedded directly in themes or templates because of potential conflicts between plugins and themes. To use jQuery in a plugin or theme it should be enqueued with wp enqueue script. This will make sure it's added only once, and any scripts that define it as a dependency will load after.
stackexchange-wordpress
{ "answer_score": 7, "question_score": 4, "tags": "jquery" }
Prevent duplicate pages from being added Im using this code to prevent duplicate post from being added but i also need to prevent duplicate pages too. Can Someone please help? function clearDuplicatePosts(){ global $wpdb; $prefix = $wpdb->prefix; $wpdb->query("DELETE bad_rows . * FROM ".$prefix."posts AS bad_rows INNER JOIN ( SELECT ".$prefix."posts.post_title, MIN( ".$prefix."posts.ID ) AS min_id FROM ".$prefix."posts GROUP BY post_title HAVING COUNT( * ) >1 ) AS good_rows ON ( good_rows.post_title = bad_rows.post_title AND good_rows.min_id <> bad_rows.ID )"); } add_action('publish_post', 'clearDuplicatePosts');
you can use the same function simply hook it to the `publish_page` hook or any custom post type for that matter `publish_{post type name}` so just add : add_action('publish_page', 'clearDuplicatePosts');
stackexchange-wordpress
{ "answer_score": 1, "question_score": 0, "tags": "posts, multisite, pages, query, duplicates" }
Making a parent directory writable by the server Uploading an image to add to a page, I got a message saying: Unable to create directory... Is its parent directory writable by the server? Assuming the issue is that the parent directory needs to be made writable by the server, how do I make the parent directory writable by the server? Thanks, Richard
Here is how to change your folder permissions. * Login to your ftp * Make your wp-content folder 755 (In most FTP programs, this involves right-clicking -> "Permissions"). 755 is owner: read, write and execute permissions; group: read and execute permissions; others: read and execute permissions. * Inside wp-content create a new folder called "uploads", make it 755 (if not working, try 777 for testing, but never make a live site 777) * Inside the control admin panel, go to settings>miscellaneous and on the first line enter "wp-content/uploads" as where your uploads will go to. If this does not work you will have to log in to your server via SSH and make sure the ownership of the web folders are set to the webserver user (using the chown command)
stackexchange-wordpress
{ "answer_score": 0, "question_score": 0, "tags": "images, server, uploads" }
open graph image being overwritten by gravatar logo? example page; < some reason the gravatar image is overwriting the posts featured image thumb (100x100). Nnot sure how its doing it! How can i get rid of it? <meta property="og:title" content="Jenny Abbot" /> <meta property="og:description" content="C-Art — Cumbria Artist Open Studios, Jenny Abbot Artist Index PaintingC-Art"/> <meta property="og:url" content=" <meta property="og:image" content=" <meta property="og:type" content="article"/> <meta property="og:site_name" content="C-Art"/> best, dc.
I can't see a Facebook share button on the page you are talking about, but I ran this through Facebook Lint and it appears that your Open Graph meta tags are working correctly.
stackexchange-wordpress
{ "answer_score": 1, "question_score": 0, "tags": "facebook, sharing, open graph" }
Not being allowed to use some terms in Add New Site in Wordpress The following words are reserved for use by WordPress functions and cannot be used as blog names: page, comments, blog, files, feed This is the error message that I'm getting. I wanted to use /blog as a sub-site in the network. What I require is that my site has the following structure: Home (only contains links to the other parts) Part 1 Part 2 Blog Would using permalinks solve my problem? I want all my blogs to appear in only the 'Blog' part of the site and nowhere else. Another follow-up query is that, since I'm working on this site on my localhost, I'm using sub-folders. But when I eventually transfer the site on a web host, I want to use sub-domains. I'm mentioning this as I fear that any solution to the above problem can influence this.
< /blog cannot be used as a new site name. It is relied on heavily by WP for the main site. Everything added to it automatically has /blog as part of the permalink from my understanding You can check out this discussion < to see if it helps you out, gives some further options. The main issue with the /blog is to prevent collisions. I'm not sure of the repercussions of not using it, when using subdomains I'm not sure if you can easily switch from subfolders to subdomains..... I would think that would cause some issues. I think when you transfer over, the existing subsites are not switched.... so if you set it up one way, and try to change, there may be some headaches
stackexchange-wordpress
{ "answer_score": 0, "question_score": 0, "tags": "multisite, blog, subdomains" }
How to determine if custom menu is active? My theme registers custom menus with this function: function nav_menus() { if ( function_exists( 'register_nav_menus' ) ) { register_nav_menus( array('main-menu' => __( 'Main Menu' ), 'sub-menu' => __( 'Sub Menu' )) ); } } I need to place code into my sidebar, that checks to see if the "main-menu" is active - for example, has a menu assigned to the "Main Menu" theme location. Anyone know how to test for this?
You can use the function `has_nav_menu('main-menu')`. See the WordPress Codex here.
stackexchange-wordpress
{ "answer_score": 10, "question_score": 4, "tags": "theme development, menus" }
How to add Color Picker in Theme Options for the following? I have a landscaping09 theme. This is what I want: A theme options page with the following options: ->Theme color background change (with colorpicker) or url of the image ->General Navbar color background change (with colorpicker) or url of the image ->Header color background change (with colorpicker) or url of the image ->Set up header height ->Navbar color background change (with colorpicker) or url of the image ->Navbar hover color background change (with colorpicker) or url of the image ->Footer color background change (with colorpicker) or url of the image ->additional css code box please let me know how to do it or any plugin will do these things? please help me.
Your not going to get an answer to this, there is no magic wand you can use to change what your asking without working it out yourself, or at the very least supplying some actual code with your question. To change the CSS in a back-end option page you can use the Options API, < or write a custom CSS file and include it in your header. As Mark already mentioned there is a color picker that comes with WordPress that you can use to fill in your custom field options with color values.
stackexchange-wordpress
{ "answer_score": 3, "question_score": 5, "tags": "theme development, plugin recommendation, theme options, child theme, color picker" }
How do I pass WordPress's get_bloginfo('siteurl') to Jquery? I'm guessing this is a really dumb question, but I'm far more familiar with PHP/WordPress and I'm just getting started with jQuery so I'm not even sure what to search on. Is there a way to pass the output of echo get_blogifo('siteurl') To jQuery? I'm trying to get this to work: $('a.getstarted').attr('href', '<?php echo get_bloginfo('siteurl'); ?>/payroll-deduction-authorization/?plan=basic'); Thanks in advance for your help!
Use wp_localize_script() to pass variables to the front end so that you can pick them by javascript. Use it like this: wp_enqueue_script( 'some_handle' ); $data = array( 'some_string' => __( 'Some string to translate' ) ); wp_localize_script( 'some_handle', 'object_name', $data ); And pick it up like `object_name.some_string` in javascript code.
stackexchange-wordpress
{ "answer_score": 6, "question_score": 1, "tags": "jquery" }
auto generated robots.txt problem I have a site visibility in privacy settings set to allow search engines to see my site but for some reason when i go to the auto generated robots.txt file it shows User-agent: * Disallow: switching site visibility merely adds/removes a trailing slash ie "Disallow: /" i have 2 related plugins "all in one seo tools" and "google xml sitemaps" but i disabled both of these to no avail any ideas anyone .... i know how to override this with a manual sitemap but i'm trying to find out whether this is WordPress intended behavior and if so why
Disallow with no trailing slash is the same as "allow all" - see here \- nice find!
stackexchange-wordpress
{ "answer_score": 1, "question_score": 0, "tags": "wp admin, seo, robots.txt, privacy" }
How to move post process to background We have a large wp install that is freezing up whenever an editor hits "publish". It seems that the culprit is the pinging processes that run, such as re-building the sitemap, etc. Is it possible to move most of these processes to the background so that the site doesn't hold up until the processes are complete?
Pinging and similar is all done in the background already. If you have a plugin rebuilding a sitemap or something, then consider using a different plugin which doesn't have the same rebuilding time issue.
stackexchange-wordpress
{ "answer_score": 1, "question_score": 0, "tags": "publish, wp cron" }
Error after editing functions.php I was making minor changes to `functions.php` file but just as I made the changes I got an error, I used `FileZilla` and undo the function I added but now I am getting the following error, > Fatal error: Call to undefined function add_action() in /home/content/93/7877293/html/wordpress/wp-includes/functions.php on line 51 I am sure that the file is now in its original condition. Can anyone help me by suggesting me how to deal with it? Thanks in advance.
You're not supposed to edit `wp-includes/functions.php` but `wp-content/themes/your-theme/functions.php`.
stackexchange-wordpress
{ "answer_score": 2, "question_score": 0, "tags": "functions" }
Limit amount of results returned How can I limit the amount of results returned? $images = $wpdb->get_col(" SELECT ID FROM $wpdb->posts WHERE post_type = 'attachment' AND ID in ($meta) ORDER BY menu_order ASC ");
$images = $wpdb->get_col(" SELECT ID FROM $wpdb->posts WHERE post_type = 'attachment' AND ID in ($meta) ORDER BY menu_order ASC LIMIT 5 "); Like @Kaiser suggested you can specify a range (5th to 20th results, a total of 15 results are returned at max) like this: $images = $wpdb->get_col(" SELECT ID FROM $wpdb->posts WHERE post_type = 'attachment' AND ID in ($meta) ORDER BY menu_order ASC LIMIT 5,20 ");
stackexchange-wordpress
{ "answer_score": 2, "question_score": 2, "tags": "posts, attachments" }
How do you change the visual editor's background color? I have a Wordpress site in which the background color is black and the text is white. The site is fine, but it's a pain trying to edit content in the visual editor as the background is white (same color as the text). I end up having to tell users to use the HTML view or write up the content in black color text and then at the end just select all the text and flip it to white (in which case many of them freak out and think their text is now deleted!) **How do I change the background color of the editor to black (or any other color) so that the content can be readable if the text color is to be white?**
similar to the answer by GavinR, using the wordpress `add_editor_style()` function; (as implemented in Twenty Ten and Twenty Eleven) in functions.php of your theme, add: add_editor_style(); then create an editor-style.css in your theme folder: .mceContentBody.wp-editor { background-color: #000; color: #fff; }
stackexchange-wordpress
{ "answer_score": 6, "question_score": 11, "tags": "visual editor" }
Turn Off Auto Update for Single Plugin I have a plugin that I know I never want to update. I am aware that this is NOT best practice, but in this case it must be done. Is there any way to stop WordPress from prompting me to auto-update a particular plugin (but still alert as normal for all other plugins).
T31os's answer was right: Increase the version number inside the plugin's main file.. eg. 99.9 ... and also make that same change inside the readme file for good measure(though i don't think that's actually required).. – t31os
stackexchange-wordpress
{ "answer_score": 10, "question_score": 12, "tags": "plugins" }
Link to full size image or attachment page in photo theme My site is using WooThemes Statua theme. I'm trying to get my resized slider images to link to their respective full size images (or attachment pages). I asked a similar question on the WooThemes support forums (members login required) and the code they provided links the images to the resized 960px Large image size instead of the Full size images. Here's an example page on my site, using the single.php template, and its code. How can I get the slider images to link to the full size originals or attachment pages?
$image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), "full" ); echo '<a href="' . $image[0] . '">Link to Full Size</a>';
stackexchange-wordpress
{ "answer_score": 3, "question_score": 1, "tags": "images, attachments, media" }
How to add thumbnails to posts? I am using the latest version of WordPress with the Twenty Ten theme. How can I add thumbnails to each of my posts? A step-by-step guide would be helpful in this regard.
FWIW, as a workaround, Twenty Eleven has this built in.
stackexchange-wordpress
{ "answer_score": 0, "question_score": 0, "tags": "post thumbnails" }
query with custom field I figured out with my jquery slider. Need to help (: my query is: <?php $the_query = new WP_Query('showposts=10&orderby=post_date&order=desc'); while ($the_query->have_posts()) : $the_query->the_post(); ?> <?php $imaj = get_post_meta($post->ID, 'manset', true); ?> <?php the_permalink()?> <img src="<?php echo $imaj; ?>" alt="" /> <?php endwhile;?> <?php wp_reset_query(); ?> with this query, **the query** print all posts. But i would like to display just if the post has "manset" custom field in it. how can i do that ( sorry about my bad english )
A quick google search would have directed you to this page: <
stackexchange-wordpress
{ "answer_score": 4, "question_score": -2, "tags": "post meta" }
Is there any wordpress plugin available to auto share comments? I'm trying to achieve like this. See the image. !enter image description here Is there any good free or premium plugin available to add this feature? I know there are some plugins out there like janrain,gigya. But those plugins have limits in free version. Their fee also high. So i don't like their plugin. Any other good plugin available? Thanks
Try the JetPack Plugin from WordPress.com <
stackexchange-wordpress
{ "answer_score": 0, "question_score": 0, "tags": "plugin recommendation, comments" }
Group Posts By Custom Meta Value: Date I have a post with a custom meta value which is populated via a jQuery datepicker and it gets stored in the following format: yyyy/mm/dd - is there a way I can group all posts from the same day together easily? I'm not using Wordpress's publish date, as I need to have future posts published. I know using the function 'the_date()' will by default in Wordpress only show the date once per x amount of posts, giving the appearance they're grouped. Is there anything that does something similar with a custom meta date value?
The only built in way ( using a function) is to use `WP Query` and the custom field parameters, specifically `meta_query` and `compare`. < An example to get you started: $query = new WP_Query( array( 'meta_key' => 'your_date', 'meta_compare' => '=' ) ); Alternatively, the custom field functions in Wordpress do not have many parameters, they are basically for adding and retrieving data, which you can then use with native PHP, for instance you can return the custom field as an array using something like: $meta_date_array = get_post_meta($post_id, $key, false); ksort($meta_date_array); and use PHP's `ksort`to sort the order.
stackexchange-wordpress
{ "answer_score": 1, "question_score": 0, "tags": "custom field, post meta, date" }
Plugins to clone wordpress site and move to another url Are there any possible plugins that could clone an entire Wordpress site and install it in another location? I build sites on one url, then to show the client and move it to another url to show it. At the moment copying the files and database and re-uploading everything and changing urls is a bit of a nightmare! UPDATE: I want them to run off two different databases.
< I tried duplicator and it worked out great. A 25min process condensed down into 5mins, really simple to use and has now worked several times for several sites, great plugin!!
stackexchange-wordpress
{ "answer_score": 2, "question_score": 3, "tags": "migration, installation, clone site" }
Menu_slug used for creating options page I am following this page on designing options menus: < What is the significance of the **menu_slug** ? I ask because when I change this value, the options page changes to > You do not have sufficient permissions to access this page. If I change it back to what it was, it's fine. **\---EDIT---15/8/2011** This is the code I was changing: function highlighter_menu_() { add_options_page('Highlighter pen options', 'Highlighter Pen', 'manage_options', 'my-unique-identifier', 'highlighter_plugin_options'); } and changed it to function highlighter_menu_() { add_options_page('Highlighter pen options', 'Highlighter Pen', 'manage_options', 'a-unique-identifier', 'highlighter_plugin_options'); }
I have found the issue. I was making changes to the plug-in code and transferring it directly (via ftp). I forgot to **deactivate** and **activate** the plug-in. Doh!
stackexchange-wordpress
{ "answer_score": 0, "question_score": 0, "tags": "plugin development, admin menu, options" }