INSTRUCTION
stringlengths
11
999
RESPONSE
stringlengths
0
999
SOURCE
stringlengths
16
38
METADATA
dict
Pending Post review notification for contributors I've been looking around at this for solutions but strangely I can't seem to find one that appears decent - maybe I haven't looked hard enough. What I want is a notification on my dashboard when posts are pending review. I can't believe this doesn't seem to be core behaviour for WP. I so far can't seem to find any recent plugins for this, maybe it's a setting I haven't noticed on WP. Any help gratefully appreciated. Jonathon
Jonnny, I would highly recommend checking out Edit Flow. It does add a notification to the dashboard about Pending posts, as well as a host of other things. The plugin is aimed at organizing a whole team of content creators. It's well described at editflow.org.
stackexchange-wordpress
{ "answer_score": 1, "question_score": 1, "tags": "dashboard" }
How do I retrieve the slug of the current page? I am trying to retrieve the slug of the current WordPress page outside the loop. The title of the page returns with `wp_title ()`, but how can I get the slug? <li> <a href="/slug-of-current-page/"> <?php wp_title('', true); ?> </a> </li>
Use the global variable `$post`: <?php global $post; $post_slug = $post->post_name; ?>
stackexchange-wordpress
{ "answer_score": 214, "question_score": 137, "tags": "post meta, slug" }
How to add more fields to bbPress registration form How can I add one or more extra fields to the registration form in bbpress 2.0.2? I want to add a textarea where prospective users can write their reason for joining the forum.
Turns out that the WordPress login and bbPress logins are the same. So you can just find code to tweak the WordPress registration form, or indeed use a plugin, which is very simple:
stackexchange-wordpress
{ "answer_score": 0, "question_score": 1, "tags": "bbpress" }
Blackberry specific Mobile Redirect plugin? **Is there a Wordpress plugin out there, that redirects only Blackberry visitors to a very simple basic something of the site?** Currently I have a responsive website, a long vertical one with `smoothscroll.js` (Similar to the Nike one). It responds in iOS, Android, and iPad - and while it displays alright in BB (curve 2009), its very hard to read text. I have to support curve 2009 + BB. _Any suggestions?_
There isn't one that I know off, however if you wanted to write a script to solve your problem then: In Javascript: <script type="text/javascript"> var userBrowser = navigator.userAgent; var url = " if (userBrowser.indexOf("BlackBerry") >= 0) { if (userBrowser.indexOf("WebKit") >= 0) { window.location = url; } } </script> or alternatively you could be smart and try and create a plugin. In php, I'd imagine it would have something along the lines of: <?php $userBrowser = strtolower($_SERVER['HTTP_USER_AGENT']); $blackberry = strrpos($userBrowser, "blackberry"); $webkit = strrpos($userBrowser, "webkit"); $url = " if (!($pos_blackberry === false)) { if (!($pos_webkit === false)) { header("Location: " . $url); } } ?> Hope that helps
stackexchange-wordpress
{ "answer_score": 1, "question_score": 0, "tags": "plugin recommendation, mobile" }
BuddyPress Toolbar Is there a way to call the toolbar or adminbar as you would a menu? <?php wp_nav_menu( array( 'container' => false, 'menu_id' => 'nav', 'theme_location' => 'primary', 'fallback_cb' => 'bp_dtheme_main_nav' ) ); ?> I want to add the toolbar to a div within the header.php file. Currently the toolbar is being called in the footer.php and styled by the css to a fixed position in the body. Or perhaps is there a script I could run which would amend a div around the `<div id="wp-admin-bar">`? I am running the latest install of WordPress, 3.3.1 with BuddyPress as a plugin. Using a child-theme I created. I've noticed a few of the normal WordPress functions do not work well with the BuddyPress plugin.
There's actually an entire API for adding/removing items in the Toolbar. You're specifically looking for the `add_menu()` method.
stackexchange-wordpress
{ "answer_score": 1, "question_score": 1, "tags": "buddypress, admin bar" }
How to loop through each user id? The functions that I am aware of: WP_User and wp_get_current_user seem to only get the user object of the current user. As an administrator, if I want to display certain profile information in a table from each user, how can I loop through the ids? Can this be done with WP template tags or should I resort to SQL? Thanks in advance
How about using `get_users()`? You probably don't even need parameters for it, default behavior should be just what you're looking for.
stackexchange-wordpress
{ "answer_score": 8, "question_score": 4, "tags": "user roles, user meta, user registration" }
wp_redirect and current_user_can issues Put simply, I'm trying to redirect the user after clicking a 'Save Changes' button. The plugin uses custom capabilities, and so I want to check the current user has the correct capabilities before progressing with the save and redirect afterwards. However, bit of a dilemma. I have tried loading the function that carries out what is mentioned above using 'admin_init' and 'admin_menu'. Using 'admin_init', throws an undefined function error for the 'current_user_can' function, which makes sense since it hasn't been loaded yet (and is well documented in other help topics). The redirect works fine (using wp_safe_redirect). On the other hand, using 'admin_menu' allows the 'current_user_can' function to work, but the redirect doesn't. This is because the headers have already been sent. Is there a way to have both functions working in either actions 'admin_init' or 'admin_menu'? Thanks in advance.
You should be able to use `current_user_can` inside the `admin_init` hooked callback. See the Codex examples.
stackexchange-wordpress
{ "answer_score": 2, "question_score": 0, "tags": "redirect, capabilities, admin init" }
Restore original WP admin bar after BuddyPress install I want to re-enable the original WP admin bar after installing BuddyPress! `define( 'BP_DISABLE_ADMIN_BAR', true );` completely disables the admin bar - don't want that. This question tells us to check the BuddyPress Codex page, and I tried messing with those action hooks but didn't get any desired results. What's missing? How do we get that admin bar back?!
Since buddypress 1.5 you can use: define( 'BP_USE_WP_ADMIN_BAR', true ); I use it in bp-custom.php although it can go in _wp-config.php_
stackexchange-wordpress
{ "answer_score": 2, "question_score": 1, "tags": "admin, buddypress, admin bar" }
What is considered a default query for the request filter? As stated in one of the answers in this question and in the codex entry for the `request` filter, said filter gets called only in a default query, such as the main query used for a loop. My question is, what else is or isn't considered a default query? Would creating a new `WP_Query` object be considered such?
The "default" query is the one WordPress does itself, based on the URL and such, automatically. Any query you create manually, via a new WP_Query or by calling query_posts(), will not use the 'request' filter. There is only one "default" query, and you cannot trigger it via any code in the template.
stackexchange-wordpress
{ "answer_score": 2, "question_score": 1, "tags": "wp query, filters, query" }
Page (template) with only news of the type "gallery" Could anyone explain to me how to create a picture galleries page, using the built in Wordpress galleries (no plugins if possible)? Basically, I would like to create a page (template?) in which I loop over all the news of the type Gallery. I've seen some related questions, but without an answer. Could anyone be of service? Thanks in advance.
If 'gallery' is a taxonomy item (like a category) you could create a new page template (perhaps based on index.php) and then use the get_posts() function to return a list of posts in that category. That's the process. Do you need more detail? If 'gallery' is a post format that may be a quite different operation.
stackexchange-wordpress
{ "answer_score": 0, "question_score": 0, "tags": "page template, gallery, loop" }
How to obtain a reference to $table_prefix in $wpdb object I need to call the WordPress options table and pull some data. However, the table name may be different (typically wp_options) depending on whether the default table prefix was used on installation. How can I obtain a reference to the site's table prefix in order to properly access the site's options table via $wpdb? /** * WordPress Database Table prefix. * * You can have multiple installations in one database if you give each a unique * prefix. Only numbers, letters, and underscores please! */ $table_prefix = 'wp_';
global $wpdb; $prefix = $wpdb->prefix;
stackexchange-wordpress
{ "answer_score": 5, "question_score": 0, "tags": "wpdb" }
How do I write an inventory list plugin that creates dynamic details pages? I am working on a plugin that creates an inventory list page using an XML data file. For the sake of this example, let us say the inventory items are antique motorcycles or contemporary area rugs. User activates my plugin and adds a short code to a page in order to display the inventory on a page called "Inventory." I want to introduce a details page so when the end user wants to enlarge the thumbnail picture or read more details about a specific motorcycle, he can click from site.com/Inventory to site.com/Inventory/somethingelse/ to find that information on another page. What is the right way to code this? Some things I have considered are... * Create another page and another short code and then hide the page from the menus * Add rewrite rules to send these requests to a .php file in my plugin directory What do you think? Thanks for reading.
Create a custom post type `inventory`. You get a separate post editor, nice URLs for free. No need for a short code, because each post type has its own archive page. You may add custom meta data, taxonomies etc. Write an importer. Look at the WordPress importer, it uses XML too. This isn’t very hard, just make sure the post type and all additional meta data are already registered.
stackexchange-wordpress
{ "answer_score": 0, "question_score": 1, "tags": "plugins, pages" }
How do I retrieve menu items from one level only? The WordPress function wp_get_nav_menu_items returns my whole site's navigation nested and all. Now if i want to get the nav menu for one "level" of that nested navigation only, how do I do that?
Are you trying to display the posts from the top down a certain number of levels? If so, use wp_nav_menu. It has an argument "depth" built just for this and it works painelssly. wp_nav_menu(array('depth' => 2)); Also, <
stackexchange-wordpress
{ "answer_score": 4, "question_score": 3, "tags": "navigation" }
Get Wordpress current date/time In my plugin, I am trying to get the current date/time of the blog into the code but it seems to be returning a odd date/time. If i put a new post on the blog it does show the correct date/time so I am not sure what the issue is. Am I handling the code incorrectly? (Post Time: Published on: Feb 13, 2012 @ 22:45) ## PHP Code <? $t_time = get_the_time( __( 'Y/m/d g:i:s A' ) ); echo "<h1>BLOG TIME</h1>"; echo $t_time . "<br>"; echo "<br>"; echo "<h1>SERVER TIME</h1>"; echo date("Y/m/d g:i:s A"); ?> OUTPUT BLOG TIME 2011/05/20 10:28:16 PM SERVER TIME 2012/02/14 5:41:35 AM
There is a function in WordPress called `current_time();` which you pass either 'timestamp' or 'mysql' to and it returns a time. For more information: <
stackexchange-wordpress
{ "answer_score": 10, "question_score": 0, "tags": "date time" }
why to use query_posts() in custom page? Hi i am new in wordpress and want to know about `query_posts()` function. If there is index page or home page than there is no need this function to display post but if i made custom page than there this function must used to display. Why?
See When should you use WP_Query vs query_posts() vs get_posts()? For a custom post type or a simple page you don’t need `query_posts()`. Usually, you almost never need it, because it will replace the default query which leads to some counter-intuitive side effects. When in doubt use `get_posts()`.
stackexchange-wordpress
{ "answer_score": 2, "question_score": 0, "tags": "query posts" }
how to 301 redirect from a plugin folder Some how google indexed a directory inside one of the plugins I use. I cannot figure out how to set a 301 redirect from the indexed path to the home page. has anyone else seen or dealt with this? here is what google indexed. I have replace all personal information with generic. <
give an noindex in your robots.txt - `Disallow: /wp-content/plugins/` and dont access the wp-content/plugins folder; also you can add an 301 redirect in your WP install via Plugin or with an extra in the htaccess
stackexchange-wordpress
{ "answer_score": 2, "question_score": 0, "tags": "seo, redirect, noindex" }
Simple webshop-plugin? Im looking for a simple plugin to make a site from which i can make orders for products. The whole shop should be under an own "tab" in the menu. It should be possible to use nested categories. Each product have an "Add to cart" button, and a textfield to enter the quantity. When the user is finished, they fill out their name and address and such, and an email is sent to the store keeper with all of the information about added items and information about the buyer. Is there such a plugin?
Check out WooCommerce. Everything you're asking for it will handle.
stackexchange-wordpress
{ "answer_score": 1, "question_score": 0, "tags": "plugin recommendation, e commerce" }
Where is the query in wp-login.php I am making a login form in WordPress and i want to have a validation on it, so i tried to look at the wp-login.php to see how they validate things. But i did not find what i am looking for. I would like to know how they validate things or what input do they need to validate things. I tried to search the WordPress forums all i can find is plugin, plugin and more plugin. I don't want a plugin. I want to hard code it. So please help me. I want to know where you can find the part that searches for the user's username and password. Or if not, know what is needed for a successful login. example username or password or others. by the way here is the wp-login.php. Thanks
Look in `wp-includes/general-template.php` at the function `wp_login_form()`. Follow the functions called there. I’d say: just _use_ `wp_login_form()`. It does probably everything you need, and you can customize it.
stackexchange-wordpress
{ "answer_score": 1, "question_score": 0, "tags": "query, login" }
Remove the whole menu in the admin How can i remove the whole menu in the admin? I have this code: function remove_menu_items() { global $menu; end( $menu ); while ( prev($menu) ) { $value = explode( ' ', $menu[ key($menu) ][0] ); if ( $value[0] != NULL ? $value[0] : "" ) { unset( $menu[ key($menu) ] ); } } } add_action( 'admin_menu', 'remove_menu_items' ); This only removes the default menu items, any pages added to the menu by a plugin are still there. How can i remove the whole menu?
add_action('admin_head', 't5_hide_menu'); function t5_hide_menu() { $GLOBALS['menu'] = array(); ?> <style>#adminmenuback,#adminmenuwrap{display:none !important} #wpcontent, #footer{margin-left:0 !important}</style> <?php } Now I want to know: _why?_ :)
stackexchange-wordpress
{ "answer_score": 4, "question_score": 1, "tags": "admin, menus" }
Child Terms not Displaying on the Taxonomy Term Admin Screen I am experiencing an issue where terms with a parent are not being displayed in the category admin screen. The screen gives the total number of terms that should be there (i.e., 32), but only displays parent terms (i.e., 9). Interestingly, if run: var_dump( get_terms( 'category' ) ); all 32 terms are returned. Does anyone have an idea as to how I might be able to get those terms to display? Thanks!
The issue was that somehow the "category_children" value in "wp_options" was reset to a blank, serialized array. In certain contexts, WordPress uses this value to determine the parent child relationship. The value in my DB suggested no such relationships exist. The fix for the issue was to add/edit/delete a category as it updates this value.
stackexchange-wordpress
{ "answer_score": 4, "question_score": 3, "tags": "taxonomy" }
Navigation that Runs Above and Below Header Image Is there a way to have a navigation div(s) on the Twentyeleven theme or similar themes that runs over the header image and finishes below the header image? Basically so overflow runs below the image. Here's an example: Link to Website
@Sneek's comment is your best bet. Otherwise, if you're bent on splitting one menu, you have three choices: 1. Use PHP to intercept the menu code and split it up before it gets output. This would work great in many regards, but it wouldn't be knowledgeable as to where the "break" occurs, so you'd need to do it by some other factor like # of characters 2. Use javascript to dynamically split up the menu. Because you can find elements' widths, you could find the "break" and split it at that location exactly. 3. Use some crafty CSS to reposition the latter elements. It would be hard to make this flexible, and you would not be able to locate the "break" as with #1. Essentially, you could only handle specific elements.
stackexchange-wordpress
{ "answer_score": 1, "question_score": 0, "tags": "theme twenty eleven, menus" }
How to add the Author on my RSS Feed just done on my feed burner, I noticed however, that author is not being labeled in the RSS feed: < . How should I able to do that? any idea please.
It actually is working, though FeedBurner doesn't include it in the HTML page. When I add it to a feed reader, the authors show up. I'm not completely familiar with FeedBurner, perhaps there's a settings for that?
stackexchange-wordpress
{ "answer_score": 0, "question_score": 0, "tags": "rss, feed, feedburner" }
Using Postmash plugin in Wordpress 3.3.1 I want to be able to reorder posts and have them listed in this custom order from the category page. I've downloaded and activated the Postmash plugin but am having problems with installation. I've copied this text <?php $wp_query->set('orderby', 'menu_order'); $wp_query->set('order', 'ASC'); $wp_query->get_posts(); ?> into index.php as instructed, but I don't understand where I need to use this line of code <?php get_posts('orderby=menu_order&order=ASC'); ?> to reorder my posts on the category page. Assistance would be much appreciated! TIA.
Used this Postmash plugin instead. Works perfectly without modifications to templates.
stackexchange-wordpress
{ "answer_score": 0, "question_score": 0, "tags": "plugins, posts" }
Post Thumbnails on Sidebar Widgets How do I get my post thumbnails to show up on the recent post widget or a commenter's avatar to show up on the recent comments widget?
There is no ability in the default widget, you will need to use third-party plugins to acheive your goal. Here are some that I have found. < <
stackexchange-wordpress
{ "answer_score": 0, "question_score": 0, "tags": "widgets, post thumbnails, sidebar" }
Uploading PDF file and providing download links to them One of my clients has a number of documents in PDF format that he wishes to provide download links to on his site. One solution I have been toying with is to treat them similar to images and upload them through the media uploader provided with WP and then provide a named link to the file. I would like to know if the above method is a good way or is there a better way to do this. Moreover, from a maintainability point of view dumping PDF files with images is not exactly the best way to manage these files so it would be good to partition these files into a separate directory. I am also interested to know if there are any plugins available to do this. Thanks in advance. nav
the method you have described is valid , and technically you can use it without a problem. Other options you have are : 1.Upload via FTP to a "PDF" folder (or whatever name) and MANUALLY link the files. 1. Change the default "upload" folder only for the time you upload the pdf files (this method is not reccomanded and will work only on a more "static" site where pdf´s are uploaded only once or twice in bulk) 2. as for plugin - there is this one < which is a bit old but might help you. (I did not verify if works on current release) 3. write a custom function that will either A: change the upload dir ONLY for PDF (easy to write) or B: Let you choose plugin folder for EACH upload. Right now I am a bit pressed with time, but if you are interested in option 4 let me know .
stackexchange-wordpress
{ "answer_score": 1, "question_score": 0, "tags": "uploads, file manager" }
How can i make this in the_post_thumbnail? if I add this code in my theme function.php add_image_size('thumb' , 130, 65, true ); // Thumb add_image_size('max' , 610, 305, true ); // Maximum add_image_size('min' , 270, 135, true ); // Minimum …the file names of uploaded images is: > * photo-name-130x65.jpg > * photo-name-610x305.jpg > * photo-name-270x135.jpg > * photo-name.jpg > How can I rename them to the following (by default)? > * photo-name-thumb.jpg > * photo-name-max.jpg > * photo-name-min.jpg > * photo-name.jpg > And if someone wonders why I want to do this is because: If in the future I decide to change theme, logically I might change because of the new theme the dimensions of the photos. So for what reason should I create too many dimensions when I can just replace them from the original, without taking to much space and so I won't delete the previous sizes and create 404 error in the indexing of the photos in Google.
If you want to ensure your image sizes remain available when switching themes, then you should place them into a plugin. Create a .php file (name it what you want) and place it in wp-content/plugins/, then paste the following: <?php /* Plugin Name: My Custom Image Sizes Plugin URI: Description: Images sizes to be used in all themes Author: Pippin Williamson Author URI: Version: 1.0 */ add_image_size('thumb' , 130, 65, true ); // Thumb add_image_size('max' , 610, 305, true ); // Maximum add_image_size('min' , 270, 135, true ); // Minimum Once you activate the plugin, your image sizes will be available no matter what theme is activated.
stackexchange-wordpress
{ "answer_score": 2, "question_score": 0, "tags": "thumbnails, post thumbnails" }
Internationalize plugin so strings can be translated in WPML A third party developer made a text widget with title, body and thumbnail. This accompany widget plugin has not been internationalized and therefore the strings do not appear in WPML's string translation management. I need them to be loaded. So I am trying to register the plugings domain as indicated here, but the code I added: function accompany_text_init() { $plugin_dir = basename(dirname(__FILE__)); load_plugin_textdomain( 'accompany-text', false, $plugin_dir ); } add_action('init', 'accommpany_text_init'); does not load. It seems as the widget is not registered. Here is the full code. What am I doing wrong? Is the call position off? A plugin coding newbie here and a junior PHP-er so would appreciate some help.
After some great help - even though a bit late - from the guys at WPML, especially @Brooks I managed to ge the code fixed. The icl_register_strings() function was in the wrong place so WPML I shifted it to the update() Method from where one can sanitize the instance variables before they are used by the widget. The icl_t() function was put in the widget() Method. The widget() which is used to display content within the widget when it appears in the sidebar on your blog. They also changed one of the $name argument of icl_register_string($context, $name, $value) to 'widget body – ' . $this->id so we can now have unique values stored for that value. Code can be seen here: <
stackexchange-wordpress
{ "answer_score": 0, "question_score": 0, "tags": "translation, plugin wpml, localization" }
Must permalinks always point to single post pages? Suppose that I have a blog with few posts per month, and no comments, and I don't want to show posts in single post pages, but always "in context" (say, together with the posts in its month - or perhaps a week?). To accomplish this, I'd need to use permalinks with fragment identifiers (#), among other things. I wonder if this is supported, or if someone can point me to some resource or discussion. _Edited_ : I posted in my own answer the details of my implementation.
There are two hooks named `'pre_post_link'` and `'post_link'`. Their first argument – which you can change – is the permalink. So … add_filter( 'pre_post_link', 'wpse_42406_change_permalink', 10, 2 ); function wpse_42406_change_permalink( $permalink, $post ) { // change the permalink, let it point to an archive etc. return $permalink; } … will change the output. In your loop you probably use something like … <li id="post-<?php the_ID(); ?>"> Your permalink could then point to the archive page of your choice plus `#post-$post->ID`. For example:
stackexchange-wordpress
{ "answer_score": 4, "question_score": 2, "tags": "posts, archives, permalinks" }
In wp_list_comments comment dates won't work? I'm trying to create my first comments list and comment form in my wordpress site but the dates are displayed as `%e %B %Y at %H:%M` instead of the date. It seems like the `date format` isn't recognized. I've simply written this code: <?php $args = array ( 'avatar_size' => 48 ); wp_list_comments($args); ?> <?php comment_form(); ?> How can I fix it?
Taken from comments: The plugin qTranslate cannot parse the time format string if no time options are set. Disabling the plugin or setting the time options fixes the problem.
stackexchange-wordpress
{ "answer_score": 2, "question_score": 0, "tags": "comments, date" }
Creating Job Tickets I work in a small print shop and I want to digitize our workflow. I have found many plugins that are for support tickets, but I want to be able to create job tickets for printing jobs. I have found several of form plugins (Gravity, Formidable Pro) that make the form portion easy, but I need a way to create reports and view the data that is being stored in the db. I need the ability to create relational databases. Is this possible within wordpress?
Yes, it's possible. WordPress uses a relational database and you're free to add tables to it. As a warning - you will need to create new functions/classes to work with your new tables. WordPress' built in functions will probably not work with new tables. As a side note, new content types such as reports and tickets can be encapsulated in Custom Post Types. With CPTs you have built in WordPress functions at your disposal and it's easy to create an admin section for your new CPT. I've done both, adding custom tables and using CPTs for new content types. I find using CPTs a lot more convenient and productive most of the time.
stackexchange-wordpress
{ "answer_score": 0, "question_score": 0, "tags": "database, forms" }
Is it possible to use a single custom post as the site front page I know I can set a static page as the homepage but is it possible to set a single custom post as the site front page? I created a custom post type called "portfolio" where users can add all the work they have done as posts and I need one of those posts to display as the homepage, exactly as if you would set a static front page in the reading settings. Thanks in advance!
You don't want a _post_ to be the front page, you want a _custom post type_ entry to be the front page. Now that we have the terminology right, _yes_ it's possible. A client once asked me to do the exact same thing. They had a custom post type they needed displayed on the front page. Doing so was as simple as adding a filter to allow them to select a "stack" (their custom post type) from the reading page: function add_pages_to_dropdown( $pages, $r ){ if ( ! isset( $r[ 'name' ] ) ) return $pages; if ( 'page_on_front' == $r[ 'name' ] ) { $args = array( 'post_type' => 'portfolio' ); $portfolios = get_posts( $args ); $pages = array_merge( $pages, $portfolios ); } return $pages; } add_filter( 'get_pages', 'add_pages_to_dropdown', 10, 2 ); Then it's just a matter of styling your templates to use the data correctly.
stackexchange-wordpress
{ "answer_score": 13, "question_score": 5, "tags": "single, homepage, home url" }
WordPress Network admin options page: how to store options and where will they be stored? I'm creating an additional WordPress Network admin page, and I need to store some system-wide option. The good thing that a config file will be generated, so no access is required from the child blogs, but the question is: how to store options to Network Admin, and where will they be stored in the database? Thanks, Peter
Use `add_site_option()` and `update_site_option()`. You can find these functions in `wp-includes/functions.php`.
stackexchange-wordpress
{ "answer_score": 1, "question_score": 1, "tags": "multisite, options, network admin" }
Step through wordpress code I was wondering if anybody knew how to setup step through code for Wordpress. I have tried xdebug but had no luck setting it up on my VPS. I managed to get it working on my localhost at one stage but it didn't track WP too well in conjunction with NetBeans. It either tried to load my page without the core WP files or lost track of what was going on before I could navigate to the page I wanted to debug. To config my xdebug install I followed all the instructions on < but NetBeans could not talk to my remote testing server. For those interested here is the `phpinfo()` output post xdebug install: pastebin _tried to make this community wiki as I feel it's appropriate but the checkbox turned up absent_
Not the same as what you want, but perhaps this plugin might be of some help? WordPress Hook Sniffer
stackexchange-wordpress
{ "answer_score": 0, "question_score": 2, "tags": "php" }
WooCommerce dynamic menus I have a basic WordPress site set up with the Suffusion theme and the WooCommerce plugin. This is working well for the most part, however when I have folks click / hover over the "Shop" menu icon I would like this to dynamically drop down with the product categories I have defined. How do I make this happen? I'm sure there is documentation on this subject but I'm not sure what to look for. I'm primarily a systems administrator.
Suffusion supports WordPress nav menus. You'll find these in Admin > Appearance > Menus. Simply add your product categories to the menu as children of the 'Shop' page. Assign the newly created menu to the "Navigation Bar Below Header" location. <
stackexchange-wordpress
{ "answer_score": 1, "question_score": 1, "tags": "menus, plugins" }
Post-Registration, post-meta hook? Is there a hook in WP to access meta data of a user JUST after they have registered and meta data has been added to the database? I was reading to use `profile_update`, but wouldn't that be invoked every time they update their profile? I just want something to occur the moment that they have registered, and the users meta has been entered in to the database. Please let me know, Thanks! Tre
You can use `user_register` add_action('user_register', 'wpse42506_user_register', 10, 3); function wpse42506_user_register( $user_ID ) { // do stuff here } If you want to just use the user information, you can use `get_userdata` < If you need more control, you can initiate a new `WP_User` <
stackexchange-wordpress
{ "answer_score": 3, "question_score": 3, "tags": "hooks, user meta, user registration" }
Insert data through a script directly in the db is it possible to insert data through a script or HTML site into the wpdb and this will show up as normal article in the, the same as when I use the 'create new post' page? Which tables are affected or should I care about? BR, mybecks
Yes its possible but why go over the trouble when you can use the native functions like wp_insert_post that will take care of the interaction with the database. If you are still looking to do it directly by `$wpdb` then the post data is saved in the posts table, the meta data for posts is saved in the postmeta table.
stackexchange-wordpress
{ "answer_score": 1, "question_score": 0, "tags": "html, wpdb, scripts" }
Adding tables to dashboard pages programmatically? I think that is not possible with some actions or filters, I know that I can do it just with html and using right css styles, and of course php to achieve what I need, or to write some minde actions. Is there already some predefined functions for this or not? Thanks.
Well in that case take a look at this tutorial on how to use the native WP_List_Table
stackexchange-wordpress
{ "answer_score": 1, "question_score": 0, "tags": "plugin development, functions, filters, actions, pluggable" }
Add page title as a javacript variable to specific posts I'm very new to WordPress and I'm sorry if this question may sound ridiculous. I need a way to add the post title into it's content, only in specific posts, and not always at the same place in the content. I've done some research, but all I find is about changing functions in .php files or in _The Loop_. I don't know if there are any kind of predefined functions, tags or code that can be used to print this type of information manually into the content. I tried including `<?php` code, but obviously is not the way as it gets commented (please correct me if I'm wrong). Ps: This is intended to be used by content publishers, SEOs, and people knowing almost nothing about programming.
Use a shortcode. In your plugin or theme (`functions.php`) add: add_action( 'after_setup_theme', 'wpse_42534_add_permalink_shortcode' ); function wpse_42534_add_permalink_shortcode() { add_shortcode( 'permalink', 'get_permalink' ); } Now, your users can use the string `[permalink]` anywhere in the post to print the URI to the current post or page. Oh, and welcome to WordPress Stack Exchange!
stackexchange-wordpress
{ "answer_score": 1, "question_score": 2, "tags": "shortcode, page specific settings" }
Set default (auto) slug prefix for Tags Is it possible to add default prefix to the slug of each newly added **Tag**. So that full slug, would be stored in database (no rewrites). **For example:** * _**Name_** : Tag1 -> **_Slug:_** prefix-tag1 * _**Name_** : Tag2 -> **_Slug:_** prefix-tag2 * ...
You can use the `created_term` or the `created_{taxonomy}` hooks which are fired just after a taxonomy term is created (the second only if it matches the taxonomy). The following will only alter terms in the taxonomy 'my-taxonomy'. (I believe for the default tags, taxonomy should be 'post_tag'). add_action('created_term', 'my_add_prefix_to_term', 10, 3); function my_add_prefix_to_term( $term_id,$tt_id,$taxonomy ) { if( $taxonomy == 'my-taxonomy'){ $term = get_term( $term_id, $taxonomy ); $args = array('slug'=>'my-prefix-'.$term->slug); wp_update_term( $term_id,$taxonomy, $args ); } } **Note:** From the Codex: > It should also be noted that if you set 'slug' and it isn't unique then a WP_Error will be passed back This shouldn't be a problem if you use this function _before_ any terms are created, because prefixing the same string to unique slugs preserves uniquness.
stackexchange-wordpress
{ "answer_score": 3, "question_score": 2, "tags": "taxonomy, slug" }
How to troubleshoot WordPress issues? > **Possible Duplicate:** > How do you debug plugins? I have an issue that the posts table shows "no posts found" right after the installation although I can see "All (1) | Published (1)" right above it. Now I'm not asking how to fix this very issue, I'd rather **learn how to troubleshoot such issues in general**. Is there a log file? (Haven't found one.) Is there some plugin that would help with seeing which SQL commands are executed and what data is returned? Something to display PHP warnings? Thanks.
There are a few things you can do: 1. Use the Debug Bar plugin < 2. Set WP_DEBUG to true in your wp-config.php file if you are looking for problems in a theme or plugin 3. I created a plugin that allows you to dump any variable into the Debug Bar plugin: < You should look at the global $wp_query var to see the query that is being executed. Beyond that, there are dozens of debug plugins on the plugin repo.
stackexchange-wordpress
{ "answer_score": 2, "question_score": 0, "tags": "troubleshooting" }
Importer fails to import every post I'm trying to move the content of a wordpress.com blog to a self-hosted one. Right now I'm just trying to set things up on my local environment. I exported the content using the built-in WordPress exporter from the original blog and the file is a little bigger than 2 megabytes. Anyway I managed to increase the upload limit so the import is actually working. The problem is that it imports just the posts of 2010. Is there some other limit set somewhere else?
I solved my problem. I exported again the whole content, choosing to export the posts separately. This resulted in a much bigger file (almost 8 megabytes) and it seems it contains all posts I wrote in the past.
stackexchange-wordpress
{ "answer_score": 1, "question_score": 0, "tags": "database, import, export" }
Embedding PHP in shortcode $content I have created an enclosing shortcode that is styled to be a button with the intention of putting content in it. I am echoing this shortcode inside a theme file and want the content to link to a specific relative page. However, I am not using the proper quotations and can't seem to figure this rudimentary php syntax out. <?php echo do_shortcode('[apply]<a href="<?php echo site_url(); ?>/quick-quote">Quick Quote</a>[/apply]'); ?> I know this is wrong. Just looking for some guidance.
<?php echo do_shortcode("[apply]<a href='" . site_url() . "/quick-quote'>Quick Quote</a>[/apply]"); ?>
stackexchange-wordpress
{ "answer_score": 4, "question_score": 0, "tags": "php, shortcode" }
Attaching global meta to custom fields I post music videos on my site and I add the artist name as a custom field to each post. I want to associate certain meta with that artist name so I dont have to enter it everytime like the artists twitter account and link to Facebook. So my question is how could I enter in their meta data once somewhere and call it to every post automatically where their artist name is entered for a field. Hope I explained that right.
I think the way I would tackle this would be a non-hierarchical taxonomy. That would allow you to tag the artist and such as well as give you a few fields to work with for basic data input...you also have the ability to expand, should you need it. If you're going to have a lot of terms and you need additional fields, I think I would store those in a custom table for ease of access and to keep clutter down in wp_options. I can provide pseudo code for any of the above implementation.
stackexchange-wordpress
{ "answer_score": 0, "question_score": 0, "tags": "posts, custom field" }
Gallery image must open up in fancybox directly not post page I am inserting a number of galleries onto a page using the multiple galleries plugin. I want the image to open up in fancybox (highslide js variant or some such) when clicked and installed another plugin called easy fancybox. The problem I am facing is that when the image is clicked in the gallery the image opens up its own post page and when that image is clicked it opens up in a fancybox. I want it to open up directly in a fancybox. I would also like the fullsize image to open up in a fancybox not just the thumbnail. I am quite sure this is possible and I am just doing something silly. Thanks in advance. Nandakumar Chandrasekhar
Make sure that your galleries are set as Links to _"Image File"_ and not to _"Attachment Post"_ for Galleries and images. You'll find the settings in the image/galleries pop-up window. I'm not familiar with your plug-in but you might need to manually add the fancybox class to each image. Another option is to add the code to your theme manually and skip the plug-in. I've posted an answer here: Any good lightbox-like option that works?.
stackexchange-wordpress
{ "answer_score": 0, "question_score": 0, "tags": "gallery" }
How to get the input of a TinyMCE editor when using on the front-end? I'm not sure why I haven't been able to find this, but does anyone know how to get the input of the TinyMCE editor? I am using it in the front end and want to be able to save whatever the user has typed into the TinyMCE to a database but cannot find the best way to capture that value. The two solutions that I've implemented with some success are: 1. `tinyMCE.activeEditor.getContent();` \- This one seems to only get the value of the visual editor so if I'm in the HTML editor and make changes and then save, they aren't picked up. 2. `$('#html_text_area_id').val();` \- This one is the opposite, it only seems to get the value of the HTML editor. I know there is a better way - I just can't seem to find it... p.s Yes, I'm going to implement security measures to make sure people can't blow up the database.
Ok apparently WordPress keeps track of what kind of editor (visual or html) is active as a class which is added to the content wrapper so here is a solution that will get you the latest content in the editor function get_tinymce_content(){ if (jQuery("#wp-content-wrap").hasClass("tmce-active")){ return tinyMCE.activeEditor.getContent(); }else{ return jQuery('#html_text_area_id').val(); } }
stackexchange-wordpress
{ "answer_score": 23, "question_score": 8, "tags": "tinymce, wp editor" }
multi page password protection Is it possible to have the "password protected page" feature of WordPress apply to more than one page? I have dozens of pages which I wish to protect with the same password, but I don't want people to keep having to type the password every time they open a new page. I also don't want people to require an account, all they should need is one password!
WordPress FTW! It actually works this way out of the box. If you use the same password on multiple pages, it only has to be entered once.
stackexchange-wordpress
{ "answer_score": 5, "question_score": 7, "tags": "pages, security, password" }
Adding second Email address for WP user notifications The WP systems sends a lot of mails to authors. There also plugins who use email notifications for authors. But, let say I have a user, who is managed by two persons (because it's a company, an entity that is more then one person) - I want all the emails to be sent also to a second Email address, that I will enter in the profile page of that WP user. What is the best way to achieve this? I know how to add a field to the profile page, but I don't know how to send every notification that the user gets to the second email address. please help :)
Not a WP specific solution, but you can usually set-up an alias/forwarder in your email system that sends a copy to both people. e.g. [email protected] [email protected] etc.
stackexchange-wordpress
{ "answer_score": 1, "question_score": 1, "tags": "users, email, wp mail" }
Assign title-specific class to list items in menu based on WP pages I'm currently using a WP-generated list of pages for my site navigation - this is using the method `wp_page_menu`. I'd like to add custom styling to specfic list items in the menu, and I was wondering if it's possible to have a function that will assign class names to the list items based on the name of the page they link to. So, for example, instead of having to apply styles to `li.page-item-1500`, I'd like to apply styles to the list item generated from the page's title, such as `li.about`. Is this possible? (I'm using WP ver 3.3.1, btw)
Yes - you can do this without having to write any code, too. * On the 'Menus' page, locate the 'Screen Options' at the top of the page and locate the 'CSS Classes' check box. Click it. !enter image description here * After that, expand a menu item and you'll see a new option for 'CSS Classes' !enter image description here
stackexchange-wordpress
{ "answer_score": 2, "question_score": 3, "tags": "css, pages, navigation" }
How to make wordpress nav menu use post custom meta data Using WordPress custom navigation menus automatically gets the menu item label and displays it between the of the menu item, what I need to do is to get a custom field value of the page and displays it instead of the menu item label. How can I do that ?
You need a custom walker. Change the function function `start_el()` to use your custom field’s value.
stackexchange-wordpress
{ "answer_score": 2, "question_score": 0, "tags": "menus, post meta, navigation" }
Wordpress Queue like Tumblr? Is there a way to give Wordpress the queue functionality that Tumblr has? Tumblr's queue, for those who don't know, is a way to space posts out without assigning specific post dates. For example, a Tumblr queue might be set to post every four hours between 9am and 5pm. Tumblr would drop the front post in the queue at 9am, 1pm and 5pm every day. Posts are added to the queue by clicking "add to queue" instead of "publish." It's quite simple. How can this feature be added to Wordpress?
The Time Release plugin comes close, but has a fixed update period. The functionality is there, though, and I'd guess the portion of code that does the checking/updating could be hacked to use whatever (still-fixed) frequency you want without too much trouble. **EDIT 2.16.12** Found a couple others that come much closer to Tumblr's behavior while working on something recently. Automatic Post Scheduler provides a simple setup where you specify a minimum and maximum interval between items. When something comes up for publishing, the system checks against the intervals and automatically pushes its scheduled time to the next available slot. Auto Schedule Posts has a much more robust set of options, allowing you to actually replicate the sort of "every # hours between x and y times" queuing that Tumblr does. It can also be limited to only post on certain days and so some randomizing.
stackexchange-wordpress
{ "answer_score": 6, "question_score": 6, "tags": "posts, tumblr" }
Activate Akismet on installation with akismet key I want Akismet to be activated by default on installation with my Akismet API key. I am making my own distribution that I will use on my own sites and I want the plugin and key to already be activated when installing a new wordpress site.
The link _Bainternet_ provides looks quite promising. Now you only need to automatticaly add the API key. Akismet has a constant for this called *WPCOM_API_KEY* (source code). So you could add something like this to your wp-config.php file and Akismet would use it as API key. define( 'WPCOM_API_KEY', 'abcd1234efgh' );
stackexchange-wordpress
{ "answer_score": 0, "question_score": 0, "tags": "akismet" }
Settings API - how to update options manually? I'm storing all my options using Settings API: function registerSettings() { register_setting('XX_theme_settings', 'XX_theme_settings', 'setting_validate' ); add_settings_section('theme_options', 'Theme Options', 'theme_options_generate', 'page1' ); add_settings_field( 'XX_Option1', 'Option 1', 'text_input', 'page1', 'theme_options', 'XX_Option1' ); add_settings_field( 'XX_Option2', 'Option 2', 'text_input', 'page1', 'theme_options', 'XX_Option2' ); }; add_action('admin_init', 'registerSettings'); Let's say I want to update XX_Option2 manually (not using forms, but via PHP), how should I do that? I was thinking about `update_option('XX_theme_settings[XX_Option2]', value)`, but that doesn't work (?).
That's because your options are stored as a serialised array, in one row with name `XX_theme_settings`. To update one option, you would still need to retrieve the existing settings, ammend the appropriate value and update all options in your array together. For example: $my_options= get_option('XX_theme_settings');//retrieve all options $my_options['XX_Option2'] = 'my new value'; //amend value in array(s) update_option('XX_theme_settings', $my_options); //update option array
stackexchange-wordpress
{ "answer_score": 6, "question_score": 0, "tags": "options, settings api" }
How to display wp_nav_menu() conditionally only when not on a 404 page? I made a custom design for my site. On my header i put my navigation so everytime i call the header the navigation will be called to, so that i would not be calling it all the time. But now i have a problem, on my 404 PAGE , i don't want to include the navigation, but if i don't include the header the themes won't play. SO how can i do this?. Any ideas is greatly and highly appreciated.
Put `<?php if( !is_404() ) : ?>` before your navigation and `<?php endif; ?>` after your navigation and VIOLA! It's gone!
stackexchange-wordpress
{ "answer_score": 6, "question_score": 3, "tags": "theme development, menus, 404 error" }
How to hook wp_list_pages? How can I hook the wp_list_pages function so that it reads a value of a custom field and displays it instead of displaying the page title?
A quick Google Search came up with this Source Try the following: function wp_list_pages_filter($output) { // modify $output here, it's a string of <li>'s by the looks of source return $output; } add_filter('wp_list_pages', 'wp_list_pages_filter');
stackexchange-wordpress
{ "answer_score": 2, "question_score": 3, "tags": "filters, hooks, wp list pages" }
PHP code to use on next & previouspage links I'm having an issue with wp_link_pages tag. I want to list the number of pages of each post with 'next' and 'previous' links that are two image arrows. To better understand the problem I'm having, please see this URL: < At the top of the body you'll see a list of pages of that post. In the left and right side of the pagination there are two green arrows, I want them to function as links to 'nextpagelink' and 'previouspagelink'. I've read the wordpress codex regarding wp_link_pages and 'styling page links' but I still can't figure this out.
adjust the 'nextpagelink' and 'previouspagelink' arguments for wp_link_pages() to have a css class you can style $args = array( 'nextpagelink' => '<span class="next">' . __('Next page') . '</span>', 'previouspagelink' => '<span class="prev">' . __('Previous page') . '</span>' ); wp_link_pages($args); then in your css you can style those spans to use your arrows as background images.
stackexchange-wordpress
{ "answer_score": 0, "question_score": 1, "tags": "php, pagination, wp link pages" }
How do I determine if a certain term is in an array? I am currently running the below wordpress php and it is creating a list for me. $term = get_term_by( 'id', $ptc, $taxonomy ); echo '<li><a href="'. home_url() .'/taxon/'. $pt->slug .'/' . $term->slug . '">' . $term->name . '</a> </li>'; However, I need it to check to see if $term is in_array $product_terms so I tried: $term = get_term_by( 'id', $ptc, $taxonomy ); if(in_array($term, $product_terms)){ echo '<li class="current-cat"><a href="'. home_url() .'/taxon/'. $pt->slug .'/' . $term->slug . '">' . $term->name . '</a> </li>'; } else { echo '<li><a href="'. home_url() .'/taxon/'. $pt->slug .'/' . $term->slug . '">' . $term->name . '</a> </li>'; } But it still returns none with the extra class even though I know one of them is in the array... Any ideas how to make this work?
It depends on what kind of type are the values from your `$product_terms` array. If you have strings there, like term slugs, then you probably want to check if `$term->slug` exists. If you have objects, then make sure the array is indexed, and not associative. For associative arrays use `array_key_exists()` instead.
stackexchange-wordpress
{ "answer_score": 2, "question_score": 1, "tags": "terms" }
How to let someone preview a draft? How can I let a user see my draft post; but don't allow them to edit them? Some context: I'm the only author and admin on my blog. I would like to let someone else read a post before publishing it. None of the builtin roles seems to be a match for this. The role scoper plugin seems a bit too complicated at first sight. What's the easiest way to accomplish that?
Share a draft looks like an easy plugin to do this. (Answering my own question after trying a few different things, other suggestions are still welcome.)
stackexchange-wordpress
{ "answer_score": 1, "question_score": 2, "tags": "user roles" }
users table - user_name vs. nicename Can someone explain the differences or different uses of the user_name and user_nicename fields in the users table? They seem to be, and behave the same. I found a bunch of posts in web searches, but they are relevant only to older version of wp.
The nicename is (usually) just a sanitized version of the username. It's suppose to be 'nice' in the sense that it is the 'nicename' that is used as a slug, for example: www.yoursite.com/author/my-nice-name/ will take you to the archive of the author with nicename 'my-nice-name'. The documentation simply describes it as > A string that contains a nicer looking name for the user.
stackexchange-wordpress
{ "answer_score": 13, "question_score": 14, "tags": "user registration" }
Show whether a post is plus or minus with Wp-Postratings Im using WP-Postratings to show thumbs up or down for posts and I want to show on the homepage in post excerpts whether a post in in the plus or minus. If it's in the plus I want to show a custom image but if the negative I want to show a different image. Any ideas on how to do that?
Ok I figured this out. The ratings score is stored as a custom field so I created and if statements to check whether the score was less, equal, or greater than 0 and then I can show something accordingly. Here's how I set it up. <?php $ratings_score = get_post_meta($post->ID,'ratings_score',true); if ($ratings_score < 0 ) { echo '<span>Plus</span>'; } elseif ($ratings_score > 0 ) { echo '<span>Minus</span>'; } else { echo '<span>Even</span>'; } ?>
stackexchange-wordpress
{ "answer_score": 0, "question_score": 0, "tags": "plugins, plugin wp postratings" }
the_excerpt and shortcodes I'm using the_excerpt on my index page. I'm also using a dropcap shortcode at the beginning of each of my posts. On the index page, the posts will not display the letter with the dropcap shortcode around it. If my post beings with the word "Dog" the index page displays "og". How do I get shortcodes to work when using the_excerpt? Shortcode function drcap ($atts, $content = null) { return '<div class="dropcap">' . do_shortcode($content) . '</div>'; } add_shortcode('dropcap', 'drcap');
Paste this in your theme's functions.php file add_filter( 'the_excerpt', 'shortcode_unautop'); add_filter( 'the_excerpt', 'do_shortcode');
stackexchange-wordpress
{ "answer_score": 12, "question_score": 7, "tags": "shortcode, excerpt" }
Plugin for TinyMCE to create reference to other posts Is there any plugin that would allow me to easily insert reference to another post for TinyMCE? I want to be able to reference another post by permalink and the link text to be the title of the post. Alternatively, is there any plugin that allow me to do this with short-code? i.e [reference post-id="2345" link="peramlink"]
I think `W4 Internal Link Shortcode` plugin is what you're looking for: > Now you can easily embed your wordpress sites internal links (of post, page ,category, author) in post content, page content or category description area. Just write the appropriate shortcode, and you are done. No need to update these links whenever you make any changes to the real link location. <
stackexchange-wordpress
{ "answer_score": 1, "question_score": 0, "tags": "plugins, posts, permalinks, seo" }
Get gallery url (Nextgen) Is there a way to get the gallery url of images. What I want to do is this: image1 image2 image3 are in gallery "Pinto". When a user clicked for example on **image 1** and it pop-ups in lightbox I want there to show from wich gallery is the image and when the user clicked on that link to go to that gallery. I found out how to get the gallery title - `<?php echo $gallery->title ?>` , but couldn't find the right code for the gallery url. Any help would be greatly appreciated. Thanks. p.s. Sorry for my English.
Never mind...i found the CODE (with the help of Alex Rabe), it is as follows: <?php echo get_permalink( $image->pageid ) ?>
stackexchange-wordpress
{ "answer_score": 0, "question_score": 0, "tags": "urls, plugin nextgen gallery" }
How to create a plugin that notifies for updates? At this point when I activate a plugin and an update is available it updates the plugin. I like to create a plugin myself that I want to use private, I have several WordPress blogs and if I made an update to the plugin I like those several WordPress blogs to state that there is an update available. Does anyone know how to do that?
There is a plugin for that: Automatic Updates For Private And Commercial Plugins. To prevent upgrade checks against the WordPress.org data base in your plugin use the function Mark Jaquith has written.
stackexchange-wordpress
{ "answer_score": 3, "question_score": 1, "tags": "plugins, updates, private" }
What's wrong with my wp database query? $cats = $wpdb->get_results('SELECT term_id, term_taxonomy_id, taxonomy, parent FROM wp_terms, wp_term_taxonomy WHERE term_id = term_taxonomy_id AND parent = 1 AND taxonomy = "category"', ARRAY_A); I'm trying to get all the categories in my database that are children of the category of ID 1, but it's not working. What's wrong ?
Any reason why you can't use WordPress API? $cats = get_categories(array( 'child_of'=>1 )); See Codex here.
stackexchange-wordpress
{ "answer_score": 3, "question_score": 0, "tags": "categories" }
Import images from self-hosted to WordPress.com I'm trying to migrate my self-hosted WP blog to WordPress.com, images included. Originally images were hosted on various image-hosting websites, but I've used this plugin to cache and upload them to my self-hosted WP media library. Now posts have image tags in this format: <img src=" alt="" /> I've exported my blog to XML, and used the import tool on WordPress.com. The blog is imported fine, and all images have been added to WordPress.com media library. However, image urls in each post still link to my self-hosted (old) blog. I've contacted their support regarding this issue, and they say I have to change each of the 650~ image urls manually. Is there an easy way of doing this? I can do a _search & replace_ on the exported XML file, but there must be some easier way of importing the urls correctly.
I eventually used this plugin to download and cache all images locally, and replace all links to the local ones.
stackexchange-wordpress
{ "answer_score": 1, "question_score": 0, "tags": "url rewriting, images, import" }
Tabbed feeds with ajax vs. without on homepage I have a tabbed section on my homepage where I call different feeds for new posts by category of my site much like the new youtube layout. I have 10 different feeds so my question is how important is to have those feeds crawled because I'd like to just rotate them with ajax rather than have all of it called and hidden on page load. I looked into the hash tag solution for crawling ajax but that doesn't seem to apply in this situation where the only thing needing crawled is the homepage. The other question is if I let it all load hidden without ajax is that going to dramatically slow down load times or is not so bad because the content isn't actually being shown on load?
I would go with jQuery UI tabs where the feeds would be hidden because WordPress caches feeds for 12 hours using the Transients API. This would be less expensive than doing an Ajax call for each tab. Use `fetch_feed` to parse and and cache. The cache times can be filtered using `wp_feed_cache_transient_lifetime`.
stackexchange-wordpress
{ "answer_score": 1, "question_score": 0, "tags": "ajax, seo, performance" }
Running a function on post content and CPT meta As per this thread I'm scheduling a `wp_cron` every hour which runs a function. The function I'm running is reasonably lengthy and I didn't want authors to have to deal with the waiting times. My question is this - when creating a function which runs from the following code (`$ids` is a list of post IDs): $ids = unserialize( get_option( 'my_updated_posts' ) ); foreach( $ids as $v ) { YOUR_FUNCTION_HERE( $v ); } How do I **a)** retrieve content if the `id` relates to a `Post` type and then update it, or **b)** update meta fields if said `id` is actually a `species` Custom Post Type? For **b)** , will I have to update each meta field individually or is there a filter I can apply? Thanks in advance,
I would filter which posts go into the option, that's light enough processing that it can be done on that end. To get the content of the post you can use `get_post( $v );`. To get the metavalues for the post you can use `get_post_custom( $v );`. To update the meta values you will use `update_post_meta()`. You will have to do these individually.
stackexchange-wordpress
{ "answer_score": 1, "question_score": 0, "tags": "custom post types, wp cron" }
404 error on dynamic stylesheet creation Following this solution to create dynamic css instead of inline css from sorich87 I get an error when requesting the dynamically generated stylesheet. Css is in there but also the default wp error page and a 404 header returned. Solution I used: < My stylesheet url with 404 error: < Any suggestions are highly appreciated! Thanks Quokka
The solution you're using to get the stylesheets onto the page is a terrible method. Wordpress provides the enqueue functions specifically to do what you're trying to do. The codex page on `wp_enqueue_style()` explains exactly what you need to do. If you would like to add a dynamic version, there is a parameter for that.
stackexchange-wordpress
{ "answer_score": 0, "question_score": 1, "tags": "404 error, css" }
Converting Menu Links to List Elements I'm creating a theme from a template based on Wordpress 3.0. I've started with items like Starkers which is a completely bare theme, and even tried modifying something by default like Twenty Ten or Eleven. However, the thing that gets me is how can I adjust the css to covert a single line of PHP such as (used as default now for navigation): <?php wp_nav_menu( array( 'theme_location' => 'primary' ) ); ?> Or: <?php wp_nav_menu( array( 'container_class' => 'menu-header', 'theme_location' => 'primary' ) ); ?> Into a stylized list element that can be adjusted to the length of the entire navigation menu? I'm not understanding how the PHP is turned into the right amount of `<li>`'s (which is the case in the generated html viewable in Firebug or another inspector) where I can modify them how I wish.
`wp_nav_menu()` pulls from the menus selected/generated in `Appearance -> Menus`. There will be one `<li>` for each item in the menu you select.
stackexchange-wordpress
{ "answer_score": 0, "question_score": 0, "tags": "php, css, headers" }
get_post_thumbnail_id() Doesn't return value I'm changing a menu from a loop with `query_posts` to a "custom menu" using `wp_get_nav_menu_items`, but I can't seem to retrieve the `post_thumbnail`. The original code I had (snippet): <?php query_posts($args); if (have_posts()) : while (have_posts()) : the_post(); $image = wp_get_attachment_image_src(get_post_thumbnail_id()); endwhile; endif;?> My new code: <?php $menu = wp_get_nav_menu_items('Homepage blokken'); foreach($menu AS $m){ echo $m->ID; // this echoes the correct ID $pThumbId = get_post_thumbnail_id($m->ID); // this returns empty } ?> Why is this not working?
Dammit, I just discovered that the `$m->ID` I was using wasn't actually the `post->ID`, but the `menu->ID`. I used `$m->object_id` to fix the issue. Hope this will help someone in the future `:-S`
stackexchange-wordpress
{ "answer_score": 0, "question_score": 1, "tags": "post thumbnails, thumbnails" }
Redirect to settings page after install I can't find any info on this anywhere but i'm sure iv'e seen it done before. I would like to have a user taken to the settings page for my plugin after install, so either auto-redirected or change the "back to plugins" link to a custom link. Thanks in advance **SOLVED** function myplugin_activate() { // TODO: Install your plugin here. // I don't know of any other redirect function, so this'll have to do. wp_redirect(admin_url('options-general.php?page=myplugin_settings'));exit; // You could use a header(sprintf('Location: %s', admin_url(...)); here instead too. } register_activation_hook(__FILE__, 'myplugin_activate'); @Zack - Your method works great however you forgot to exit after wp_redirect. (source < Many thanks
Register an activation hook and then redirect the user's browser when you're done installing your plugin. function myplugin_activate() { // TODO: Install your plugin here. // I don't know of any other redirect function, so this'll have to do. wp_redirect(admin_url('options-general.php?page=myplugin_settings')); // You could use a header(sprintf('Location: %s', admin_url(...)); here instead too. } register_activation_hook(__FILE__, 'myplugin_activate');
stackexchange-wordpress
{ "answer_score": 5, "question_score": 5, "tags": "plugins, plugin development" }
Organization of time insensitive content I'm planning to use WordPress to maintain and publish a role-playing system. Is there a best practice for managing content in WordPress that isn't time sensitive? Should I use pages and make short notification posts when those are updated? I know posts and pages are stored the same, it's handling the creation and presentation that's giving me trouble. I want updates to be obvious, but without republishing entire sections of content.
I would recommend using Custom Post Types (and, likely, custom taxonomies). Some intrepid developers did just that, for a proof-of-concept game built on WordPress, and presented it at WordCamp Toronto 2011.
stackexchange-wordpress
{ "answer_score": 1, "question_score": 0, "tags": "posts, pages, customization" }
Where to upload my new custom ShortCode in Separate .php file? I wrote my first ShortCode in a file called: myShortCodes.php. Does the add_shortcode go in the same PHP file as the ShortCode itself? Where do I upload it? How does WordPress know to look in my file? I don't have to modify \wp_includes\shortcodes.php do I? So far I have tried uploading myShortCodes.php to 1. wp-includes/myShortCodes.php 2. wp-content/themes/mytheme/skeleton/myShortCodes.php
In general, special theme functionality (including shortcodes) should be placed in your theme's `functions.php` file, which is in the root of your **theme** folder. If the code is less than a few dozen lines, it probably won't be worth creating a separate file (unless you just really want to organize your code that way). So the shortcode functionality and the `add_shortcode()` call should be in functions.php. Let's say you do want to separate it though. You can include your `myShortCodes.php` file like this in your functions.php file: require_once('myShortCodes.php'); And then you can have the code (including the `add_shortcode()` call) kept in `myShortCodes.php`. It's recommended to **not** alter the WordPress core files (like wp-includes/shortcodes.php) or put anything in the wp-includes folder because then it's outside of your theme folder and any upgrades to the WP core will cause your changes to be lost.
stackexchange-wordpress
{ "answer_score": 1, "question_score": 0, "tags": "customization, shortcode" }
Backing up Wordpress before an update, what's the easiest way to do this? I'm about to update my Wordpress blog to the latest version. It was recommended that I backup my posts and database first. It seems like a plugin would be the easiest way for me to do this. What's the best plugin available for this? Searching Wordpress' site I found the BackUpWordPress plugin: < Alternatively, if a plugin isn't recommended, how should I do this instead?
The codex covers this topic VERY thoroughly. Personally, I use WP-DB-Backup, it's the most popular backup plugin that I know of, and it's really easy to use.
stackexchange-wordpress
{ "answer_score": 1, "question_score": 1, "tags": "backup" }
Plugin won't activate I am trying to redirect a user once they click "activate" on my plugin, the redirect is working great using the register_activation_hook however the plugin is failing to activate. Any thoughts on what i need to do to make it run the hook after activation and not before? function install_redirect() { wp_redirect(' } register_activation_hook(__FILE__, 'install_redirect'); Thanks
From stackoverflow: < register_activation_hook(__FILE__, 'my_plugin_activate'); add_action('admin_init', 'my_plugin_redirect'); function my_plugin_activate() { add_option('my_plugin_do_activation_redirect', true); } function my_plugin_redirect() { if (get_option('my_plugin_do_activation_redirect', false)) { delete_option('my_plugin_do_activation_redirect'); wp_redirect(MY_PLUGIN_SETTINGS_URL); } }
stackexchange-wordpress
{ "answer_score": 1, "question_score": 0, "tags": "plugin development" }
Dynamically determine URI to scripts and styles included with a class which could be added from plugin/theme/child theme/mu plugin I'm working on a settings API class which I'd like to be able to drop into a plugin, wpmu plugin, theme, or child theme directory, and have it just work. My issue is that I'm having trouble figuring out how to determine the URIs for including scripts and styles on the fly. I'd like this to work no matter how the site's WP install is set up, so it should work where ever the wp-content, plugins, mu-plugins, and themes directories are located. I found this post which involves something similar, but it's not quite the same, since it's dealing with paths and not URIs. Also, (frankly), I'm finding it a little challenging to wrap my head around, and I'd like to avoid going down that rabbit hole if my carrot isn't going to be there. Any advice on how to approach this?
For plugins it is: $plugin_url = plugin_dir_url( __FILE__ ); This works even if `wp-content` is on a separate domain. You may get problems if your class is in a subdirectory of the plugin – you should probably make the `__FILE__` a parameter for a function: public function get_plugin_url( $base = __FILE__ ) { return plugin_dir_url( $base ); } You could also check if the parent directory of your class is the plugin directory and adjust the path accordingly. Similar, for themes use `get_stylesheet_directory_uri()`. It works for parent and child themes.
stackexchange-wordpress
{ "answer_score": 0, "question_score": 0, "tags": "include, scripts, css" }
How to get permalink and title from post ID? I have stored an array of post IDs and I would like to list the posts as links, meaning I need to get the title and permalink for the post ID - $id. The list should be echoed out by the following if condition, which means I somehow have to replace $id with the permalink and title. At the moment the code merely lists the post ID numbers. <?php if(count($related)){ echo "<div>Read More<ul>"; foreach($related as $id){ echo "<li>$id</li>"; } echo "</ul></div>"; } ?>
<?php if(count($related)) { echo "<div>Read More<ul>"; foreach($related as $id) { echo '<li><a href="'.get_permalink( $id ).'">'.get_the_title( $id ).'</a></li>';     }     echo "</ul></div>";   } ?>
stackexchange-wordpress
{ "answer_score": 36, "question_score": 16, "tags": "permalinks, title, array, php, id" }
How do I tell what plugins are used on my multisite install? I have a bunch of plugins I have installed but never use, others I am not sure if they are used or not. Is there a way to tell what plugins are not active on any site?
This plugin does what you want. From the site: "Generates a list of plugins that are currently in use, excluding Network-Activated" - hope that helps!
stackexchange-wordpress
{ "answer_score": 2, "question_score": 1, "tags": "plugins, multisite" }
Add an option to a Child theme of Twenty Eleven I developed a child theme of Twenty Eleven. I need additional theme options, so i added a theme-options.php file inside my child theme's folder. However, it appears the option page is still the 2011 theme's option screen. I can't either replace or add another one. Question: what is the correct procedure to add options to a child theme? In case you wish to see the code, here is my theme-options.php code.
This thread suggests that this isn't necessarily an intended Child Theme usecase so theme-options.php isn't explicitly overrideable. It indicates that you should rather be adding extra options using `add_settings_field` and the `admin_init` hook.
stackexchange-wordpress
{ "answer_score": 2, "question_score": 1, "tags": "options, theme twenty eleven" }
Get Child Custom Post Content on Single.php? I have a custom post type, with children 2 rows deep... Outfit 1 > Inner > >> Child 1 Child 1 Child 1 Child 1 Outfit 2 > Inner > >> Child 1 Child 1 Child 1 Child 1 On the inner page, i need to show the content of the children, title, custom post types the normal stuff.. I have the following which does show the child content, but also that of the Outfit 1 and Inner.. <ul> <?php $loop = new WP_Query( array( 'post_type' => 'outfit','posts_per_page' => '-1','post_child' => 0 ) ); ?> <?php while ( $loop->have_posts() ) : $loop->the_post(); ?> <li> <?php the_title(); ?> <?php the_content(); ?> </li> <?php endwhile; ?> </ul> Any idea how to limit it to just the children below Inner? This is code that obviously appears on single-outfit.php also... Thanks for any help :)
If I understand your question correctly, you try to just get the children and ignore the parent. Dont know where post_child => 0 comes from but I'd use post_parent => $parent_id instead. In that case you have to catch the parent ID before you do any new queries. If you do something like this at the beginning of your template: $this_page_id = $post->ID; you can refer later, in your new Query, to that id and just query child pages by using post_parent => $this_page_id
stackexchange-wordpress
{ "answer_score": 0, "question_score": 0, "tags": "wp query, query, single, child pages, get children" }
My blog hosted in distant server is still connecting to localhost my website was installed and fixed on localhost, then i hosted it on a distant server, i also chaged the parameters in the `wp-config.php` file to meet to distant database. However, when i try to call it in the url tab, i see always the localhost call in the bottom of the browser. This is my url website.
All of your content is linked to your localhost install. I would suggest using a plugin like Search & Replace to amend your URLs. Also if you haven't already, you will need to change the two entries in the wp_options table (where wp_ is the prefix used). They are rows 0 & 37\. These are your URLs for moving your site. The next time you move your site from local to a live site check out the WordPress guide, it's got lots of handy tips and solutions to problems like this.
stackexchange-wordpress
{ "answer_score": 2, "question_score": 0, "tags": "localhost, shared hosting" }
Trouble Adding New Logo I'm trying to replace an old logo on a site with a new one. * The old logo was 222×120px * and the new one is 222×150px. I uploaded the new one and had it overwrite the old one. My site hasn't changed though. The 30px added to the new logo is the only difference between the two and it just says "Productions". There should be room for at least part of the "Productions" part to show, but it looks exactly like the old one. How can I fix this? I'm supposed to have this site finished today and this is the last thing stopping me from being done. The logo I'm talking about is the one in the top-left corner of this site. Thanks
Line 429 (or thereabouts) of your theme's style.css, change height: 120px to height: 150px.
stackexchange-wordpress
{ "answer_score": 1, "question_score": -1, "tags": "logo" }
Query from a different database than the default I'm making a layout for a wordpress page. The layout needs to connect to a second database (both databases are in the same domain). But the problem is, when i execute just the file it works. But when i included inside the wordpress layout i don't get data, no errorrs, nothing The script is just: $con = mysql_connect('host','user','pass'); mysql_select_db('db', $con); $q = mysql_query('SELECT * FROM vars', $con); var_dump(mysql_fetch_array($q)); As i say. If i execute the file alone: > < it works great, and returns data. But if i do inside the layout (creating a wordpress page, and giving the layout to it) Returns nothing. Any idea what can be happening there?
I don't know why the mysql_connect isn't working inside WordPress. But an easier way of doing it would be to use the **$wpdb** class. Try replacing your code with this: $second_db = new $wpdb( 'user', 'pass', 'dbname', 'host' ); $q = $second_db->get_results( 'SELECT * FROM vars' ); var_dump( $q ); and see if you get the results you want. _(note that the order of the variables passed to the`$wpdb` constructor is different from the order used by `mysql_connect`)_
stackexchange-wordpress
{ "answer_score": 5, "question_score": 1, "tags": "database, query, page template" }
Plugin to email a post or page to someone Is there a plugin that will allow visitors to email a page or post to someone? I found WP-EMail but it was updated last on April 2010 so I'm not sure if I should use it.
Most of the social media sharing plugins include an email option. I know sharedaddy (within jetpack) has a link that allows a permalink to be emailed to a given address.
stackexchange-wordpress
{ "answer_score": 2, "question_score": 0, "tags": "plugins, email" }
How to make an interface similar to multi-site for switching between multiple (single) sites for administrators? I have a few WordPress sites and I want to make it easier to manage. I was thinking of being able to switch sites in the dashboard like WordPress multi-site, but when I was looking into it I see that's only for blogs inside blogs (if that makes sense). Is there anyway to link to different blogs together (I have around 5 blogs all with content on them so I don't want to make them in to 1 site with mapped domains). So to sum up, I want to make it really easy/fast to switch between sites for the admins. I like how WordPress multi-site does it, but I don't want to move all the blogs in to one and map the domains, the domains are all on 1 server. Is this at all possable and if so how? Are there any plugins? EDIT: If there is no way, how would I make 6 single WordPress sites into a WordPress multi-site?
There is an external services that let you manage multiple sites from one dashboard like **manageWP**. But i would recommend moving them all in to a multisite install and here is a nice codex entry that shows just how to do that **Migrating Multiple Blogs into WordPress Multisite**
stackexchange-wordpress
{ "answer_score": 2, "question_score": 1, "tags": "plugins, multisite, plugin recommendation, dashboard" }
WordPress Theme variables scope I need to create a variable that can be accessed throughout my WordPress Theme template files (index.php, header.php etc..). I know function definitions go inside the `functions.php` template file (in your theme path), but there's no such thing for variables. For example I constantly need to retrieve Categories in my Theme, so I would like to have this accessible from anywhere in my theme: $categories = get_categories(); /* get_categories() is a wordpress function */ This way I can simply access to allocated data, without having to re-allocate it every time I need to get my categories. Unfortunately adding that piece of code in my `functions.php` file, doesn't work, neither does making the variable `global`.
Apparently `global` does the trick. The problem was that my variable `$categories` should have been **redefined** with a `global` in front of it, in each template I needed to use it.
stackexchange-wordpress
{ "answer_score": 5, "question_score": 9, "tags": "php, themes, globals" }
Add More Fields to Users Pages (Admin Panel) So I'm trying to create some custom fields for users. I need to give users access to a 30 day trial of some software and I want to keep track of that in the users page of administration panel. If the user is in the trail I want to add "Trial" at the top and "Yes" or "No" next to the username on the All Users page. I'm assuming this would be a core file somewhere, but I'm not sure which one.
You can hook `manage_users_columns` to add (and I suppose remove) columns from the All users display. This tutorial details that. You might be able to hook `user_edit_form_tag` to do the trial vs not trial at the top...but I'm not sure, you'd have to tinker with it. I think you'll probably end up having to use something else (`WP_Error` might be a good way to go), but that would be where I started.
stackexchange-wordpress
{ "answer_score": 3, "question_score": 1, "tags": "custom field, admin, users, user registration, core" }
Add multiple images to a page sidebar What I am trying to achieve is this: I have a simple page and I want to dynamically add multiple images to it on the sidebar one underneath another. I was thinking about either using meta boxes, post thumbnail or custom field. I am looking for a nice and simple method to do that. Here is a screenshot that better explain what I am looking for: < Notice that adding images to the post itself must be differ than add images to the sidebar. any help will be appreciated Thanks, Gil
I would recommend using MetaBoxes. A nice tutorial is here: <
stackexchange-wordpress
{ "answer_score": 1, "question_score": 3, "tags": "custom field, images, metabox, attachments, sidebar" }
How to make my Home button on the menu redirect to my root page When i create a new page, a permalink is created: `www.example.com?page_id=29`. This page is always pointing to the page which `id` is `29`. Now, i want to point it to the root page in my website: `www.example.com`. I think it has to do with the permalink, but i can't change it. can you help me there please.
I found it, just i had to install this plugin, then when editing the page, in the bottom a new input is added to put on it the link that i want my page point to, in my case i have put `www.mydomainname.com`. Hope this help people running in the same problem.
stackexchange-wordpress
{ "answer_score": 0, "question_score": 0, "tags": "homepage, home url" }
If option: show this. Else show nothing First, I have to admit I'm not entirely sure on how to explain this best. Currently I have this in my `header.php`: <?php if ( is_home() OR is_front_page() ): ?> <meta name="description" content="<?php $options = get_option( 'schema_theme_options' ); echo $options['metadescription']; ?>"> <?php endif; ?> Would it be possible to hide the remaining <meta name="description" content=""> if no option availabe?
Try this: <?php $options = get_option( 'schema_theme_options' ); $meta_desc = $options['metadescription']; ?> <?php if( ( is_home() || is_front_page() ) && '' !== $meta_desc ) : ?> <meta name="description" content="<?php echo $meta_desc; ?>"> <?php endif; ?> It's a bit neater and a bit more foolproof than the other proposed solution.
stackexchange-wordpress
{ "answer_score": 1, "question_score": 0, "tags": "options" }
Display of comment_date within get_comments? Any way to change how the date is displayed with get_comments..? I have the following.. <?php $comments = get_comments( array( 'post_id' => $post->ID, 'number' => 4, 'status' => 'approve' ) ); foreach($comments as $comment) : echo "<li class=clearfix> <span class=comment-details>{$comment->comment_content}</span> <span class=comment-date>{$comment->comment_date}</span> <span class=comment-author>By {$comment->comment_author}</span> </li>"; endforeach; ?> Comes out with something like.. 2012-02-20 17:09:07 when i just want something like 6th January 2011
The way you're doing this, you're going to get the raw SQL date that's stored in the wp_comments table. You can still use the convenience functions like `comment_date` with `get_comments`. In this case, we'll use `get_comment_date`. The first argument is the date format -- if you leave it blank, WP will use whatever date format is set in the options > general page. <?php foreach($comments as $comment) : echo "<li class=clearfix> <span class=comment-details>{$comment->comment_content}</span>"; echo '<span class=comment-date>' . get_comment_date( '', $comment ) . '</span>'; echo "<span class=comment-author>By {$comment->comment_author}</span> </li>"; endforeach; Otherwise you could use PHP's `strtotime` and `date` to generate the date format you want. date('F j, Y', strtotime($comment->comment_date));
stackexchange-wordpress
{ "answer_score": 0, "question_score": 0, "tags": "comments" }
Keep Logged in Users out of Admin Panel So I'm creating user registration. Just simply `<?php wp_register(); ?>` but then it gives them a link to the admin panel, which in my situation they really don't need. How do I remove the "Site Admin" link and redirect a subscriber if they try to access the admin panel? I guess once they log in I will need to redirect them to a certain page also.
So I found the answer and thought it might be useful for later viewers. Adding the code below will redirect all users that are not admin to the homepage. function prevent_admin_access() { if (strpos(strtolower($_SERVER['REQUEST_URI']), '/wp-admin') !== false && !current_user_can('administrator')) { wp_redirect(get_option('siteurl')); } } add_action('init', 'prevent_admin_access', 0); The only problem with this code is that the registration needs to be changed so the user can pick their own password.
stackexchange-wordpress
{ "answer_score": 2, "question_score": 0, "tags": "admin, users, login, user registration" }
Migration: Copying database content to a different server I'm migrating our WordPress site from one server to another. I need some hint on how to deploy a database dump (which I have) from the original server to the new one. There is no phpmyadmin (at least I don't have access to it), so I need to copy the dump using console. Or maybe there is some WordPress plugin for this? Thanks in advance!
phpmyadmin as a plugin: WordPress › Portable phpMyAdmin « WordPress Plugins
stackexchange-wordpress
{ "answer_score": 0, "question_score": 1, "tags": "database, mysql, migration" }
Where should I hook into admin? Where should I hook into the admin backend to check and see if the user is "active" as defined by the Membership Plugin. Or in other words, where can I hook into the WP admin header to check an if-statement and redirect if it fails?
Not sure about the Membership plug-in bit, but `admin_init` will be your best bet. I assume that you don't actually what to hook into the admin header though - this would be `admin_head` or `admin_head-(plugin_page)` \- but you cannot redirect after these hooks (headers already sent).
stackexchange-wordpress
{ "answer_score": 1, "question_score": 1, "tags": "admin, hooks, headers" }
Loop through all media library images and return those where caption contains the text carousel Im new to Wordpress but I'm looking for a way to loop through all the images that have been uploaded to the media library and output the SRC, description and caption of the image when the caption contains the word 'carousel'. Is this possible?
You could do this pretty easily with a simple query: global $wpdb; $results = $wpdb->get_results("SELECT * FROM $wpdb->postmeta WHERE meta_key = '_wp_attachment_metadata' AND meta_value LIKE '%carousel%'"); foreach($results as $result){ //$result->post_id will give you the original attachment post }
stackexchange-wordpress
{ "answer_score": 6, "question_score": 1, "tags": "loop, media, media library" }
How to install a translation for a WP plugin? So I installed this plugin < I need a Spanish translation. There is a link that takes you to a list of translation files: < So I downloaded wp-email-es_ES.mo and wp-email-es_ES.po How do I install a translation?
This Plugin uses `load_plugin_textdomain()`, which by default uses the Plugin's root directory as the path for the translation files. So: simply add the translation files you downloaded to the Plugin root directory, and you _should_ be good to go. ### Edit > > And you're using WordPress in es_ES? > > No, I just want to translate that plugin. It generates a form with fields such as "Your Name" "Your Email" "Your Remark" and I need that form translated in Spanish. If you actually want WordPress to _use_ those translation files, you have to _tell_ it to use them, by changing `WPLANG` from `en_US` to `es_ES` in `wp-config.php`.
stackexchange-wordpress
{ "answer_score": 1, "question_score": 0, "tags": "plugins, translation" }
Limit a meta box to a specific category I'm trying to limit a meta_box to posts in a specific category. I'm using this method: < and it works rather well But I can't seem to get it to work with categories. Heres' my code: <?php // meta box for news category add_action('admin_init','news_init'); function news_init(){ $post_id = $_GET['post'] ? $_GET['post'] : $_POST['post_ID'] ; $post = get_post($post_id); if ($post->post_category == '6'){ add_meta_box('news_details', 'News Details', 'news_details', 'post'); } } ?> I feel like I'm missing a step. Thoughts or ideas? Thank you, Nadine
Just went a different way on this, didn't end up using categories.
stackexchange-wordpress
{ "answer_score": 0, "question_score": 1, "tags": "categories, metabox" }
is_front_page not working at all in any of the themes .php files I am using the Paragrams theme from the kind folks at wpshower. I have a little different front page that I would like to load with an image rotator and different layout in the for loop. I have tried all of the conditional comments, with no avail. There are some posts on this already that didn't have a solution... * is_front_page, is_page('slug'), is_page(id) not working * is_front_page() not working I even tried this most basic if else from the WP forum without any help. What am i missing? :( <?php if (is_front_page()) {?> <div>Flash Gordon</div> <?php } else { ?> <div>Wins the Battle!</div> <?php } ?>
Have you tried creating a page template? Make a copy of page.php and call it page-home.php (if your home page is an actual page in Wordpress with the name of 'Home') or if not, then create a file called front-page.php and Wordpress will use that as the homepage template. These two Wordpress Codex links will help you: * Page templates for pages via ID or slug * Wordpress front page display templates
stackexchange-wordpress
{ "answer_score": 0, "question_score": 1, "tags": "conditional tags" }
CSS in child theme not overriding the parent theme I am trying to make a child theme for a premium template. My css isn't overriding the parent though. I'm trying to figure out what's going on. Other than important the parent theme's css, is there anything else I need to import into the child theme folder? Right now there is just style.css. The site is <
There was a problem in the theme itself, this has been corrected since this question was posted. The parent theme was not properly coded to work with a child theme.
stackexchange-wordpress
{ "answer_score": 0, "question_score": 0, "tags": "theme development, themes, css, child theme" }
My contact form - I've changed the source code but the changes are not being applied I obviously found the file responsible of displaying the contact form with `FireBug`, changed the displayed names in the input area and then re-upload my file, however, nothing was changed. The input value of the first area was `your name`, i changed it to `votre nom`, but still displying me `your name`. You can check it in this url, you can use FireBug to check this. Here is a sceenshot, and I'm use the _Boldy_ theme: !Screenshot of form and firebug
It is because you are overidding your values in custom.js: $('#quickName').val('your name'); $('#quickEmail').val('your email'); $('#quickComment').val('your message'); Remove these lines and you should be good to go.
stackexchange-wordpress
{ "answer_score": 1, "question_score": 0, "tags": "theme development, customization, contact" }