INSTRUCTION
stringlengths
11
999
RESPONSE
stringlengths
0
999
SOURCE
stringlengths
16
38
METADATA
dict
BuddyPress - A hook available to hide custom born date on public profile view? I'm trying to hide some fields on public BuddyPress profiles, it is possible? Thanks in advance.
I dont know, but you can hide via css or javascript the areas; via css: #id_or_.class_of_elemet { display:none; }
stackexchange-wordpress
{ "answer_score": 1, "question_score": 0, "tags": "filters, hooks, buddypress" }
How to make a share-this window drop when reaching end of post? The following blog of okcupid had this interesting feature that shows a "share this" window only when you reach the end of the post: < How is it possible to do this? Thanks
They've attached a function to the scroll event of the page, it looks at the scroll position of the document relative to its height to detect when you've reached the bottom, in which case they animate the flyout div. jQuery has some easy methods for this: `$(document).height();`, `$(document).scrollTop();` edit: these may help one two
stackexchange-wordpress
{ "answer_score": 0, "question_score": 0, "tags": "facebook, sharing" }
Category Slugs = 404s? With the help of the internet and you lot, I have been stumbling about to create a worpress site here. So at this stage, its not exactly a default install. \- Im running the boldy theme from Site5. \- Have made some tweaks to the underlying PHP, but nothing that I can think that would cause this issue. **Issue** : Slugs setup normally for categories: !enter image description here But the URL it takes me too is a 404. > < All my categories are broken, except my case studies category. \- This uses a Portfolio template to display posts in that category (part of Boldy theme) Im sure I had both the 'portfolio' and the other category links working at the same time. **What have I missed?**
Here's what I think is causing the problem: <?php query_posts($query_string . '&cat=-98, 101, 102'); ?> should be: <?php query_posts($query_string . '&cat=-98,-101,-102'); ?> The way it is now, it's telling WordPress re-run the old query, but give me nothing from category 98, AND only pull posts from categories 101 and 102. I'm guessing you want it to be re-running the original query, leaving out 98, 101, and 102.
stackexchange-wordpress
{ "answer_score": 1, "question_score": 0, "tags": "slug" }
Notification when certain posts are published I normally work ahead of schedule and sometimes need to contact people when a certain post reaches publication. Is there any plugin that will do this? It would need to be customisable for each post as most posts I don't need this reminder, and for the ones where I do need it I would need to write something different each time.
Would you consider using a specific category or tag to use on posts that require notification? If so, you could use Peter's Collaboration E-mails plugin which can automatically notify you (or other specific users) when a post is set to Pending, Scheduled, or Published. In the plugin settings, you can define specific categories, post tags, authors, etc which defines certain notifications. !Peter's Collaboration E-mails The settings shown above should alert me when any posts in the category Apple are submitted or published.
stackexchange-wordpress
{ "answer_score": 1, "question_score": 0, "tags": "notifications" }
Child themes: disabling the parent I'm creating a parent theme and several child themes. But how can I prevent the parent theme from ever being used?
Not using the current system. In order to serve as a valid Template for a Child Theme, the Parent Theme must exist, and be a valid Theme. That's because the Parent Theme's template files must be accessible via `locate_template()`, in order for the Child-Parent fallback to work properly. Note: if this core Trac ticket is implemented, then you'll be able to filter `locate_template()`, which would conceivably enable you to put your Parent Theme in a separate location, not accessible by `Dashboard -> Appearance -> Themes`.
stackexchange-wordpress
{ "answer_score": 2, "question_score": 1, "tags": "theme development, child theme, parent theme" }
Including PHP files doesn't work outside of Localhost I have a bunch of widgets that I load from php files, like so: I added a PHP CODE widget and inside wrote: <?php include '/wp-content/themes/myTheme/parts/block1.php'; ?> This worked well on my localhost, but for some reason it stopped working when I uploaded that website online (and switched the home and site_url of course). Any ideas?
The correct way to load a PHP file in the theme directory is to use the locate_template function. <?php locate_template(array('parts/block1.php'),true,false); ?> The true makes it automatically require it. The false makes it not require_once it.
stackexchange-wordpress
{ "answer_score": 2, "question_score": 1, "tags": "widgets" }
Remove classes from body_class I don't need this whole mess of classes like this... `<body class="page page-id-829 page-template page-template-page-template-portfolio-php portfolio">` I'd like something like this... `<body class="portfolio">` Is there a filter snippet somewhere that has a list of all the classes and I can then just uncomment the stuff I don't want to see in the body class. Thanks.
You can configure the `$whitelist` array in this function to filter out all other unwanted classes. add_filter( 'body_class', 'wpse15850_body_class', 10, 2 ); function wpse15850_body_class( $wp_classes, $extra_classes ) { // List of the only WP generated classes allowed $whitelist = array( 'portfolio', 'home', 'error404' ); // Filter the body classes $wp_classes = array_intersect( $wp_classes, $whitelist ); // Add the extra classes back untouched return array_merge( $wp_classes, (array) $extra_classes ); }
stackexchange-wordpress
{ "answer_score": 33, "question_score": 18, "tags": "filters" }
add_action hook for links.php page What is the definite hook which identifies links.php page (add, edit, delete, etc. Blogroll Links), and only this page? Any help would be appreciated. Thanks, cadeyrn EDIT Sorry, I forgot to mention, I need this hook in the admin area. I have a plugin, that brakes an other one, because both are triggered by the admin_menu add_action. Therefore I need an add_action point that is only valid for the admin menu's link edit/add/delete part.
OK, I made an awful, but working solution: the hook is `admin_menu`, than, in the called function, I added if( strstr($_SERVER['PHP_SELF'],'link.php') in the begining. If there's a better solution, please someone send it.
stackexchange-wordpress
{ "answer_score": 1, "question_score": 0, "tags": "hooks, links" }
Category Icon on custom post type I am using custom post types "listings" and I have a category called "type" and 3 sub cats, "available", "pending", "sold". I want to display an image/icon on each post in the loop (not the single-listings.php) but the archive view, that corresponds to it's category. Take a look at woothemes' Estate for an example. They have an image over the featured image that says "on show". Any thoughts on how to go about this? or a plugin that might do something similar? thanks! I found this code reference: <?php $cats = get_the_category(); echo $cats[0]->category_name;?>"> And then it said to style using the category as a class in the css, but no go. It returns nothing - wondering if custom post type cats need to be handled differently?
You can use the conditional with `in_category`. < For example after your loop: <?php if (in_category('type')) { ?> <img src="<?php echo get_stylesheet_directory_uri();?>/images/custom.gif" alt="" class="customicons"/>
stackexchange-wordpress
{ "answer_score": 2, "question_score": 0, "tags": "custom post types, categories" }
Sliders with buttons I'm looking for a slider plugin that allow me to insert additional buttons in a slider, not the next and prev neither numbers, I mean buttons to redirect users to a different page, etc... I would appreciate your info! Regards
You should look for sliders that allow you to insert HTML content inside your slides. jQuery Cycle is a good example, look at non-image content: <
stackexchange-wordpress
{ "answer_score": 0, "question_score": -2, "tags": "jquery" }
Set Image width='x%' (percentage width not pixel width) when inserted via the media manager? When uploading images via the media manager there are a couple of set sizes available such as thumb, medium and large. I do know how to add additional sizes, but I have yet to get it to insert an image with width='x%'. the concept is that i am building an adaptive theme and I never want the inserted image to be larger than the container even upon browser resize, By manually editing the inserted image code to include widths with a %, then it works just fine. However trying to get my users to remember this is downright impossible. What I would like would be a button to insert an image into a post with a set % (percentage) instead of a set pixel width. possible?
I guess what you're looking for is the `$content_width` global that would basically limit the width of your images, used in functions.php. Some more info here: <
stackexchange-wordpress
{ "answer_score": 0, "question_score": 2, "tags": "css, media, uploads" }
Directing a page to a default subpage I would like to introduce page-hierarchy navigation in my WordPress blog using subpages. So each page may have sub-pages, but I'd like that when a visitor clicks on a page header he will be redirected to a specific subpage. For example, say my hierarchy is: 1. Movies 1.1 General 1.2 Westerns 1.3 Animated 2. Music 2.1 General 2.2 Classic 2.3 Country What I want is that when someone clicks on "Movies" he will reach "Movies/General". Can this be achieved using plugins alone? If not, what's required?
Using WordPress custom nav menus create a menu and add the "General" page 2 times. The first as the parent and the second as the first child then add the rest of the pages as childs under the first General. Change the title in the first general to movies then on the front end when a user clicks movies they will got to the general page. !enter image description here
stackexchange-wordpress
{ "answer_score": 5, "question_score": 3, "tags": "menus, pages" }
wp_enqueue_style for plugin options page I'm trying to add a stylesheet to the options page for my plugin - code looks like this: add_action( 'admin_print_styles-rps-paypal', 'rps_paypal_add_css' ); function rps_paypal_add_css() { wp_enqueue_style( 'rps_paypal', plugins_url( '/rps_paypal/css/rps-paypal.css' ) ); } add_action( 'admin_menu', 'rps_myplugin_add_page' ); function rps_myplugin_add_page() { add_options_page( 'My PayPal Plugin', 'My PayPal Plugin', 'manage_options', 'rps-paypal', 'rps_myplugin_option_page' ); } Can't figure out why it's not showing up...
the call to add_options_page will return the string literal to use for your RSS, so it should look something like this: $page = add_options_page( ... ); add_action( 'admin_print_styles-' . $page, 'rps_paypal_add_css' ); More info here: <
stackexchange-wordpress
{ "answer_score": 1, "question_score": 0, "tags": "plugins, wp enqueue style" }
Wordpress Contact Form 7: populate the value of a field dynamically with PHP Well my question is quite simple, I would like to populate a field with the value of a variable that have been passed via a $_GET Request. thanks
Take a look at Contact Form 7 Dynamic Text Extension
stackexchange-wordpress
{ "answer_score": 2, "question_score": 1, "tags": "contact, plugin contact form 7" }
Do you use links? DO you use links in your wordpress and why? Isn't it much easier to use you browser's bookmarks? I don't get the idea of having links at all! Please enlight me!
Links are not supposed to be bookmarks, they are more of a convenient way to integrate links in site. The feature is kinda underused (I think blogrolls it single most common usage for it and seems to start to fade) and so under-appreciated. Really there are plenty of stuff you can do with links, for example I wrote a post how to use them to display banners.
stackexchange-wordpress
{ "answer_score": 3, "question_score": 0, "tags": "links" }
Network-Wide Plugin Settings Management I'm using WordPress 3.1.2, and have three blogs in a WordPress network. I would like to change some settings for a specific plugin, but have the changes applied to all the blogs on the network. I can't change plugin settings on the "Network Admin", and instead have to do it on the "Site Admin" page for each individual blog. I'm looking for the ability to change settings "sitewide" as is done, for example, by this outdated plugin.
It really depends on the plugin developer and how they incorporate settings. The other option is to try and put it inside the /wp-content/mu-plugins but I'm not sure if that will allow you to have only a master setting. You could also try hard coding it in the plugin files. What plugin is it? I might be able to better help you.
stackexchange-wordpress
{ "answer_score": 1, "question_score": 3, "tags": "plugins, plugin recommendation, multisite, options" }
Using wp_insert_post() with Networking enabled I'm working on a script that will drop articles directly into the wordpress database, using wp_insert_posts(). However, I have networking enabled and the wp_insert_post() reference page has no documentation relating to using wp_insert_post() to upload to a specific site on the network. How can I do this with wp_insert_posts()? Or is their another function which does this?
When using function like `wp_insert_post()` It will work on the currently active blog, meaning that if you are on a blog in your network with blog_id of 2 the the post you insert using `wp_insert_post()` will be inserted to that blog. Now if you want to insert the post to a specific blog you can use `switch_to_blog()` function which will tell WordPress that "the current blog is" so you can use `wp_insert_post()` to insert to that specific blog. Then to tell WordPress that what is the real current blog you can use `restore_current_blog()` so: switch_to_blog($wanted_blog_ID); ... ... your wp_insert_post() stuff ... ... restore_current_blog(); take a look at **WPMU Functions** to understand more about the available functions in a network.
stackexchange-wordpress
{ "answer_score": 10, "question_score": 8, "tags": "multisite, wp insert post" }
Upgrading WordPress (File permission group owner) I have a problem when i want to upgrade Wordpress or install plugin via the Admin. It's say that I don't have the permission to write. but I can upload images and other things... but i cannot install plugin and/or update plugin/WordPress. I know that my user server is not the file owner but is part of the group owner.
I find the answer to my question define('FS_METHOD', 'direct'); core.trac.wordpress.org/ticket/10205 thanks @xLRDxREVENGEx for the tip for upgrading manually but when you make a theme framework and you want to update you parent theme framework in the admin you need to apply the define('FS_METHOD', 'direct');
stackexchange-wordpress
{ "answer_score": 0, "question_score": 0, "tags": "upgrade, permissions, wp filesystem" }
Easy-Post-Type is visible in search, but 404 when clicked * I've installed Easy Post Types * created a custom post type: Attractions * created an Attraction: (joes-cafe) * created a category set: attraction-type (cafe) * copied single.php to single-attractions.php * added the category: cafe to wp-navigation-menu But when I visit the menu item, I get a 404, when i search for the cafe by name, i see an excerpt, but clicking its title gives me a 404! Any Clues? What am i doing wrong? I am using a Thematic child theme, and i duplicated single-attractions.php as single-attraction.php just in case, because i found the distinction confusing... Thanks, Tim
The rewrite rules need to be flushed when you add a custom post type, this can be done by visiting the permalinks admin page.
stackexchange-wordpress
{ "answer_score": 1, "question_score": 0, "tags": "custom post types" }
wrong php date()? hey guys, it's weird and I've never experienced that before. I've created a new blog and a custom theme. I'm using `<?php echo date("H:i"); ?>`in my theme. The time that's put is 2h earlier. e.g. if it's actually 16:00 o'clock the date generated with date() is 14:00. I don't know why that happens? I'm using the german wordpress version with the german language pack. Also doesn't make a difference when putting setlocale(LC_ALL, 'de_DE'); date_default_timezone_set('Europe/Berlin'); into wp-config.php. any idea how I could solve that? the time set in my wordpress settings is UTC+2 which is the correct time.
This could probably make exquisite debugging session, but taking in account it's Friday evening - just use `date_i18n()` instead and let WordPress deal with a huge mess that time/date issues usually are.
stackexchange-wordpress
{ "answer_score": 2, "question_score": 1, "tags": "php, date time, functions" }
How to automatically add rounded corners to thumbnails? I want to created automatically rounded corner thumbnails for a particular project I'm working on, using something like this: < What I'd ideally like to do is find a way to hook something like this into the thumbnail creation process itself and cache it serverside. `/wp-includes/media.php` doesn't seem to have any applicable hooks, so I might have to roll my own. Any clues on where to start? EDIT: **Not in CSS.** There have been some good suggestions about this but I'm using border-radius all over the site, and the images specifically need to be rounded on the server side. Thanks
Looks like you can hook into the `wp_create_thumbnail` filter: function wp_create_thumbnail( $file, $max_side, $deprecated = '' ) { if ( !empty( $deprecated ) ) _deprecated_argument( __FUNCTION__, '1.2' ); $thumbpath = image_resize( $file, $max_side, $max_side ); return apply_filters( 'wp_create_thumbnail', $thumbpath ); } So just do your manipulation, and return the result to `wp_create_thumbnail`.
stackexchange-wordpress
{ "answer_score": 5, "question_score": 10, "tags": "images, post thumbnails" }
Making some links generated from the wp_nav-menu function unclickeable? In this website: < I have a navigation menu taken from the twentyten theme. I want to make some links clickeable and some not (some don't have to behave like a link). I have accomplished this with some CSS but it doesn't work in all browsers. The links are dinamically generated with: wp_nav_menu Any suggestions?
Create a custom menu item in the admin panel with a dummy URL, foo.com or whatever. Add it to the menu, then delete the target URL and save. The menu item will be rendered without an href attribute and will be unclickable.
stackexchange-wordpress
{ "answer_score": 1, "question_score": 2, "tags": "navigation" }
Apply class to every paragraph that holds image? When adding an image to a page or post, Wordpress is automatically adding a paragraph tag `<p>` as parent holding the image. Like so: <p><img src="my-image.jpg" alt=""></p> Since there is no parent selector in CSS I'd love to find a solution to apply a specific classname to those paragraphs holding an actual image. The example above would thus result in: <p class="my-class"><img src="my-image.jpg" alt=""></p> Any idea if I can use `add_filter()` to apply a classname to each `p` that holds an image?
You could use jQuery if you don't mind to rely on JavaScript for adding the class. $(document).ready(function() { $('p:has(img)').addClass('image'); }); Update: the `.has()` method is probably faster, see this jsperf.com test. $(document).ready(function() { $('p').has('img').addClass('image'); });
stackexchange-wordpress
{ "answer_score": 8, "question_score": 7, "tags": "php, functions, filters" }
Your own Bookmarklet in a blog Does anyone know how to publish your own bookmarklet in a blog like wordpress.com or blogger.com? All of them seem to format the bookmarklet removing the javascript or messing it up. E.g., pasting this in wordpress blog: <a href="javascript:(function(e,a,g,h,f,c,b,d){if(!(f=e.jQuery)||g>f.fn.jquery||h(f)){c=a.createElement("script");c.type="text/javascript";c.src=" title="Run"></a> results in <a href="//ajax.googleapis.com/ajax/libs/jquery/"+g+"/jquery.min.js";c.onload=c.onreadystatechange=function(){if(!b&&(!(d=this.readyState)||d=="loaded"||d=="complete")){h((f=e.jQuery).noConflict(1),b=1);f(c).remove()}};a.documentElement.childNodes[0].appendChild(c)}})(window,document,"1.3.2",function($,L){$.hide()});">Run jQuery Code</a>
Create a clickable link on < and link to it.
stackexchange-wordpress
{ "answer_score": 0, "question_score": 0, "tags": "wordpress.com hosting, bookmark" }
How can I combine this php statement to get the results of multiple variable inputs? This is my query, it shows the posts that have meta_key as extra1 and meta_value as test <?php $customkey1 = 'extra1'; ?> <?php $customvalue1 = 'test'; ?> <?php query_posts('meta_key=' . $customkey1 . '&meta_value=' . $customvalue1); ?> <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?> <?php the_title(); ?> <?php endwhile; ?> <?php endif; ?> My question is how can I still show the posts that have extra1 as metakey and test as metavalue but also the posts that have extra2 as metakey and test2 as metavalue in the same query. A combination of two or more variables.
If you are using WP 3.1, I would recommend using the `meta_query` parameter with the WP_Query class. $args = array( 'meta_query' => array( array( 'key' => $customkey1, 'value' => $customvalue1, 'compare' => '=' ), array( 'key' => $customkey2, 'value' => $customvalue2, 'compare' => '=' ) ) ); $query = new WP_Query( $args ); if ( $query->have_posts() ) : while ( $query->have_posts() ) : $query->the_post(); the_title(); endwhile; endif; The meta_query parameter allows for very powerful queries with metadata. Sources: <
stackexchange-wordpress
{ "answer_score": 2, "question_score": 0, "tags": "custom field, customization" }
How do I list all child categories that apply to current post? On my site, I am working on categorizing pictures based on what is in them and am having trouble listing the categories that apply to the post. For instance: A post might include a picture of an ice cream cone with three flavors of ice cream. My category hierarchy for this post might be: Flavors ->Vanilla, Mint Chip, Chocolate Style ->Cone However, I cannot seem to get a list that includes just children of 'flavors' or 'style', without listing all checked categories. Essentially I am hoping to have two, nicely organized lists, where one lists the flavors and the other lists the style. Just I don't want them both in the same list. Is this possible? -get_categories seems to have the proper arguments, but I have not been able to work it out. -the_category seems like it is close, but it doesn't allow for excluding a particular category from a list
Having two separate taxonomies may make sense for you in this case.
stackexchange-wordpress
{ "answer_score": 0, "question_score": 0, "tags": "categories" }
Free starter theme to make mobile websites? Is there any free starter theme to make mobile websites using WordPress?
Yes, there are a few - did you search for them? Here are the top results from Google: * WPTouch * Carrington Mobile * WordPress Mobile Pack
stackexchange-wordpress
{ "answer_score": 3, "question_score": 1, "tags": "theme development, mobile" }
disqus: comments that've been liked the most rise to the top...like youtube? With Disqus, can I allow the most 'liked' or 'favorited' comments to rise to the top, sort of like YouTube? If not, are there any other commenting systems that have this functionality built in?
You can use other plugins to do this too. Here are some I can think off: * IntenseDebate * Comment Rating * Comments Vote I would suggest you use IntenseDebate by Automattic which means it will always be up-to-date and most compatible with your site.
stackexchange-wordpress
{ "answer_score": 0, "question_score": 0, "tags": "disqus" }
How to modify the comments list in WP & BuddyPress? I'd like to modify the **comments list** (comments left by users) on WP site using BuddyPress. In **comments.php** I narrowed it down to the following code: <?php wp_list_comments( array( 'callback' => 'bp_dtheme_blog_comments' ) ); ?> Any clue where I can find **bd_dtheme_blog_comments** , and the best way to modify it? Thank you.
Just search though your source code to find the function definition? It's in `plugins/buddypress/bp-themes/bp-default/functions.php`, and you can create your own version in your theme that should override the supplied one.
stackexchange-wordpress
{ "answer_score": 0, "question_score": 0, "tags": "comments, buddypress" }
Paypal API and Wordpress Hi does anybody know where i can find a PayPal API tutorial that can help to point me in the right direction, What im needing is something that when payment is verified by paypal it bounces through some code to update_user_meta and also a few fields in a custom table in wp database. Information that i can find via google is pretty vague in what im requiring. regards Martin
Try working through the source code of a plugin such as PayPal Framework. From your question, the WP side is fairly trivial, but you should study general PayPal tutorials to understand the API, for example, here's the first search result from Google for PayPal API tutorial: Using PayPal's IPN with PHP Also some additional helpful info can be found here.
stackexchange-wordpress
{ "answer_score": 3, "question_score": 0, "tags": "user roles, paypal" }
Making update notification functionality for my themes the question is simple :) I am making a theme that i will use in lots of sites. So, i don't want to go all the site and ftp the files every time i fix a bug or do a theme upgrade. Is there any way i can make a update system like the plugins hosted in wordpress plugin directory. Looking forward to your answer. Thanks! **Solved:** Thanks Chip Bennett for his excellent link. The update library for themes is now available in that site. You can find it here: < Always consider donation if you see some excellent work that made available for free.
You can also hook into the core update routine. (I'm looking for tutorial links, but my Google-fu is failing me this morning.) EDIT: See if this tutorial helps. It explains how to implement automatic upgrades for private/commercial (i.e. non-repository-hosted) Plugins.
stackexchange-wordpress
{ "answer_score": 9, "question_score": 17, "tags": "theme development, updates" }
Using Tags Instead of Categories for site structure I noticed that huffingtonpost.com and some other websites are using tags instead of categories for blog structure. For example the last tag in this post (like every post) is redirecting to "technology news" section of the menu. Is it OK to use tags instead of categories in the wordpress menu? what's the advantage of doing this with tags?
There is neither inherent advantage nor inherent disadvantage in using Tags versus Categories. Tags and categories are merely _taxonomies_ , which are used to describe content. Tags and Categories don't actually provide site "structure", though their index pages can be added to custom Nav Menus. The primary difference between Categories and Tags is that Categories can be hierarchical, whereas Tags cannot.
stackexchange-wordpress
{ "answer_score": 1, "question_score": 0, "tags": "html, design" }
Delete all user attachments In buddypress when a user wants to delete their own account --> is possible to delete all their attachments entries and images uploaded using media? Note: Images are not attached to posts, because im not letting users create normal posts, they only can upload images using media. Thanks in advance.
As media uploads are simly files with no related data stored, you can't do that unless you extend the user data and save the file names, etc. as user meta data. Simple answer: No, it doesn't work.
stackexchange-wordpress
{ "answer_score": 1, "question_score": 3, "tags": "buddypress" }
Bulk category update is not updating I am using wordpress 3.1. and I have to reorganize categorize my posts. For this purpose, I am willing to remove some categories. Therefore, after login to admin section of my blog, I go to post > posts > I select the articles I want to edit > I select edit option from "Bulk Action" select box > I select new categories and put some tags as well. But it adds tags only. It doesn't remove previously assigned categories. Please let me know if there is any plugin to do the same work. Or some other alternative.
Bulk category update (wordpress inclusive) just for adding more categories or to remove a category which is among all selected posts.
stackexchange-wordpress
{ "answer_score": 1, "question_score": 1, "tags": "categories, bulk" }
Where did the Add New Custom Field go? In the latest version of WP it's gone. Why?
It seems that it still exists, you just have to enable showing it, with screen options <
stackexchange-wordpress
{ "answer_score": 2, "question_score": 1, "tags": "custom field, metabox" }
wp-admin slow in multisite Running Wordpress 3.1.2 (newly updated, installed as 3.0 about a year ago) with subdomain multisite & using the Sunrise domain mapping plugin. The frontend is fast, the backend (wp-admin) is very slow on the network admin site (www.example.com/wp-admin) but runs at "normal speed" on one of the subdomain backends (foo.example.com/wp-admin). The server is our own, Ubuntu 10.04 with mod_security (which I've heard can slow things down). Is there anything I can do to speed up the backend or run a trace somehow?
I ended up enabling WP_DEBUG and found an error - something about `fsockopen()` not being able to connect to my host (I didn't write it down and now can't reproduce it) - and found that it was a DNS issue;- my subdomain (foo.example.com) was resolving to the correct IP (10.0.0.1) but the primary domain wasn't. I'm in the process of cloning & replacing a live server, external IP 10.0.0.1, internal IP 192.168.0.1; the new server has internal IP 192.168.1.1 (different subnet) and the external IP is accessed via a second interface. Adding the correct DNS entry in `/etc/hosts` fixed the problem: 10.0.0.1 example.com www.example.com
stackexchange-wordpress
{ "answer_score": 3, "question_score": 3, "tags": "multisite, wp admin, customization, performance" }
Managing media by folder I'm looking for a plugin that could help me managing more precisely medias. I'd like to be able to manage folders and sub-folders. I found out the ImageManager plugin but it's kind of outdated ( so if anyone can help ;) PS : working on WP 3.1.1
You might give NextGEN Gallery Plugin a try. While not specifically intended for sub-folder management of media, the end result is the same, since images added to galleries are organized by folder.
stackexchange-wordpress
{ "answer_score": 1, "question_score": 0, "tags": "plugins, plugin recommendation" }
Advantages of dbDelta I understand its advantage for something which will be released in public, but does it do any good for a developer by saving efforts as the code evolves over time? Like right now, I am hardcoding the table name in my queries, what if I was to change the name or something?
The purpose of `dbDelta()` is both to create and update tables. If you don't need updates then you can skip it. For keeping track of name you can simply follow WP convention and save name of your table in field of `$wpdb` object. Also note that you should consider there is possibility of code running on multisite. Even if you are not releasing it you might need to run it that way one day and then you are in for a painful refactoring if all table-related stuff is hardcoded.
stackexchange-wordpress
{ "answer_score": 1, "question_score": 0, "tags": "database" }
What is difference between get_bloginfo('url') and get_site_url()? I am developing a plugin. I want to know difference between get_bloginfo('url'); and get_site_url(); I got same output, then what's the difference?
* **`get_bloginfo('url')`** calls `home_url()` calls `get_home_url()` reads option `home` * `get_bloginfo('wpurl')` calls `site_url()` calls **`get_site_url()`** reads option `siteurl` * `get_bloginfo('siteurl')` and `get_bloginfo('home')` are deprecated arguments and return `get_bloginfo('url')` (`siteurl` argument is documented wrong in Codex as equal to `wpurl`, it's not in current code) The difference is that these two function chain to different options, which are typically same. It would be more appropriate to compare `get_bloginfo('url')` to `get_home_url()` or `get_bloginfo('wpurl')` to `get_site_url()`. Then the answer is that these functions are on different level in chain. Typically the deeper function is - the more flexible it is and the less filters output passes through.
stackexchange-wordpress
{ "answer_score": 21, "question_score": 13, "tags": "plugins, plugin development, bloginfo, site url" }
Getting Warnings & Notices from Fresh WordPress 3.1.2 install I just installed WordPress 3.1.2, I got > `Notice: automatic_feed_links is deprecated since version 3.0! Use add_theme_support( 'automatic-feed-links' ) instead. in /works/web/elements/wp-includes/functions.php on line 3303 I also got an error about Cannot open stream or something about `wp-cron.php?doing-cron` or something Its WordPress's own code, plus from a fresh install, this should not happen right? **UPDATE** The error I got was > `Warning: fopen( failed to open stream: HTTP request failed! in /works/web/elements/wp-includes/class-http.php on line 1063` Running WordPress 3.1.2 fresh install
it sounds like even though its a fresh install of WP 3.1.2 that you are also using an existing theme that is using a deprecated function (you havent said so but im presuming), if so paste this into your themes functions.php file (if your theme doesnt have one just create one and save it in your themes root folder).. if(function_exists('add_theme_support')) { add_theme_support('automatic-feed-links'); }
stackexchange-wordpress
{ "answer_score": 3, "question_score": 2, "tags": "errors, warnings" }
After creating a new page, filling the page with structure I looked 2 days now but I couldn't figure out how this is done: I created a new page in wordpress. This is easy. Then I see, that I can put content into the page. This is easy too. But how can I edit the page and add let's say the googlemaps api to it. I know there is a plugin but for some technical reasons I need to use the normal include of google maps. =) The name of my page is "About". I can't find any about.html or about.php in my wordpress folder.
Your best bet is to create a new "physical page" and save it in your theme root folder as a template called something suchlike tpl_aufwind.php like this: <?php /* * Template Name: Aufwind * * */ ?> you will need that code above at the very top of the tpl_aufwind.php so that it shows up in wp-admin dashboard >> pages >> Page Attributes (right sidebar) >> Template Create Your Own Wordpress Template your options then if you need to add google maps the normal way is to hardcode it in (or if you know of a plugin where you can use a shortcode try that), but if you are using shortcodes or wish to show more on the page than just the Google Maps api then add a wp loop either above or below your hardcode so at least something on the page can be edited via the admin pages panel
stackexchange-wordpress
{ "answer_score": 1, "question_score": 0, "tags": "pages, editor, customization" }
hard code shortcode only on specific category I am looking to embed several shortcodes into my post template, but I want the tags to be conditional to a specific category (and subcats). I've looked through the codex, but I'm unsure where to start.
If you're embedding the code directly into the template file, why bother with shortcodes? Simply extract the code from the `add_shortcode()` function call, and add it to your template, wrapped in an appropriate conditional tag, such as `in_category()`, e.g.: if ( in_category( $cat ) ) { // put shortcode code here } Note: the `$cat` argument can be an ID, name, or slug.
stackexchange-wordpress
{ "answer_score": 1, "question_score": 0, "tags": "shortcode, conditional tags" }
functions.php conditional tag - only show in single.php? //Geo Map add_action( 'woo_post_inside_after', 'my_geo_mashup' ); function my_geo_mashup() { global $post; if ( in_category('listings') ) { echo GeoMashup::map(); } } Works to embed my map tag only on my single posts categorized as "listings" But, the embedded tag is also showing within the index of posts (thumb, title, meta, excerpt) and I need to remove it from the loop of posts and have it only show on the single.php thoughts?
if ( is_single() && in_category('listings') ) {
stackexchange-wordpress
{ "answer_score": 3, "question_score": 1, "tags": "categories, hooks, conditional content, conditional tags" }
Query for multiple post types does not work I'd like my frontpage to display a list of my lastest blog posts merged with my latest "Products" custom post type posts. From the documentation i gather this should work: query_posts( array('post_type' => array('post', 'product') ) ); while (have_posts()) : the_post(); the_title(); the_excerpt(); endwhile; But that turns a weird list, made of pages ! Note that I've put it outside the loop. What am i doing wrong?
almost! when doing it outside of the loop, you have to reset the query as in: wp_reset_query();
stackexchange-wordpress
{ "answer_score": 3, "question_score": 1, "tags": "custom post types" }
finding whether request is for post, and post id I need a hook such that when visitor lands on any of the post **(not page)** , I need to record a hit. How can I find whether the request is for post, and is there any hook to find if the loaded content is post, and if yes, what is post id
something like this will work: function record_hit_if_post(){ global $wp_query; if($wp_query->is_single==1) // single post's ID: // $wp_query->post->ID; } add_filter('template_redirect', 'record_hit_if_post');
stackexchange-wordpress
{ "answer_score": 1, "question_score": 1, "tags": "plugins, plugin development, posts" }
Pull images from the gallery I am building a template where wordpress is being used primarily as an image CMS, I am pulling the first image from the content section of each post. <img src="<?php echo grab_image() ?>" /> function grab_image() { global $post, $posts; $first_img = ''; ob_start(); ob_end_clean(); $output = preg_match_all('/<img.+src=\'"[\'"].*>/i', $post->post_content, $matches); $first_img = $matches [1] [0]; if(empty($first_img)){ $first_img = ""; } return $first_img; } My question is how can I, instead of grabbing it from post_content, grab the first image from the uploaded image gallery? So, the process to add an image would be to upload and then exit out (without inserting into post). I dont know what you call this or what to look for.. attachments? media library? The content area would be used strictly for text along with any extra meta boxes.
Use `get_children()` (Codex ref): $images = get_children( array( 'post_parent' => $post->ID, 'post_type' => 'attachment', 'post_mime_type' => 'image', 'orderby' => 'menu_order', 'order' => 'ASC' ) ); The first image will be `$images[0]`. EDIT: And by "first image", I mean, the `$ID` of the first image, which you can use with any of the myriad image- and attachment-handling functions in WordPress. If you can clarify what you want to _do with the image_ , I can provide more specific, further instruction.
stackexchange-wordpress
{ "answer_score": 1, "question_score": 1, "tags": "images, attachments, media" }
Can upload doc and pdf but not ppt - not permitted for security reasons "Insert search engine here" was pretty useless for this one - I've had a look through `wp-includes/functions.php`, `wp-admin/includes/file.php` etc. but not found a reason for the behaviour I'm getting. I'm running multisite, and when I upload a .doc or .pdf I don't have a problem. When I upload a .ppt - regardless of the actual filename or mimetype (i.e. a .ppt renamed to .txt, a .txt renamed to .ppt) - I'm told "Sorry,this file type is not permitted for security reasons" with little other explanation. Do I need to modify the mimes table, add an override (and if so, what's the syntax for this), or is it something in my Apache conf? I've done some funny fiddling to try and lock things down in a few places, possibly blocking .pot files.
Found it while digging around in multisite network admin settings: there is a setting called "Upload file types" (in the database it's the row with `meta_key` = "upload_filetypes" in the `wp_sitemeta` table) which contains a list of allowed filetypes. Adding "ppt" to the list allows them to be uploaded.
stackexchange-wordpress
{ "answer_score": 6, "question_score": 7, "tags": "multisite, customization, security, uploads" }
Menus - Open items in new tab/window? I have 3.1.2 running with the Boldy theme. Site link. I have a menu that has a number of external links listed in the items. By default, these items do NOT load in a new tab/window. There is no option in the Admin --> Appearance --> Menus, to tick a box to say open in new window. How do I get them to do this?
In your WordPress admin panel, go to `Appearance > Menus`. Select `Screen Options` in the top right corner. Enable the property `Link Target`. Now you can set your link target element in your external link. !Screen Options !Enable Link Target !Set Link Target on link
stackexchange-wordpress
{ "answer_score": 2, "question_score": 1, "tags": "menus" }
Lightword Theme - only one menu item Since I am pretty new to WP and the whole stuff i ran into a problem. I am using the pretty-well known "Lightword" Theme. And today i've upgraded to the newest version. It's now possible to add/edit the menu items through the theme-settings. Although I like this very much I am not able to display more than one additional menu-item. When I go to "wp-admin/nav-menus.php" I am able to select a menu item in a box (the english titel of the box is probably: "Position in theme") on the left-side. But I am only able to select one. So what can I do to show up all created menus? Thanks for your help
You are trying to display multiple menu items, or multiple menus? Each theme supports a certain number of menus. Your's may only support one menu, that is the menu position. You create a menu to go there. From withing the menu creator interface you put all the items you want to appear on your menu. You can even nest items, to create children in your menu. You assign that menu you have created to the position, depending how many your theme supports. Many only support one menu natively. You can only add one menu per position, but that one menu can have as many items as you like. You set up your top level items, and assign children by dragging the items below and slightly to the side of a parent item. For most themes, the children items will behave as dropdowns. If you want to add more, you can code them in, or use a widget. WordPress comes with a custom menu widget which allows you to assign custom menus to it.
stackexchange-wordpress
{ "answer_score": 0, "question_score": 0, "tags": "themes, menus" }
How to implement friend system for Wordpress? At the moment my users posts are only viewable to them. I would like to implement a system where they can choose to share any post with other users they know. The problem I'm having is, how do I make the connection between users? The best I came up with is to create a table in the db and store their friends by user id's. Example: user_ID 2 friends_ID 5,9,34,85 user_ID 87 friends_ID 67,2,99,100,58,309 I want to be able to retrieve their friends list so I can use it later in various parts of the site. I know this will not be simple, but I am fully open to ideas, suggestions or similar plugin. Thank you all in advance.
BuddyPress can be used as a framework - it allows you to friend other users, and is a good place to start from. [Update] This is the structure of the BuddyPress friends table (bp_friends) CREATE TABLE `wp_bp_friends` ( `id` bigint(20) NOT NULL AUTO_INCREMENT, `initiator_user_id` bigint(20) NOT NULL, `friend_user_id` bigint(20) NOT NULL, `is_confirmed` tinyint(1) DEFAULT '0', `is_limited` tinyint(1) DEFAULT '0', `date_created` datetime NOT NULL, PRIMARY KEY (`id`), KEY `initiator_user_id` (`initiator_user_id`), KEY `friend_user_id` (`friend_user_id`) );
stackexchange-wordpress
{ "answer_score": 5, "question_score": 0, "tags": "users, author" }
How to list users and their post amount? I want to list all the users of my site and the amount of posts each user has. So far I have the function below, but I don't know how to pull in each user's ID to use in the count_user_posts... <ul> <?php foreach ( get_users('order=DESC&orderby=post_count') as $user ) : ?> <li style="color:#fff;"><span style="font-weight:bold;"> <?php echo $user->display_name; ?></span> as <?php echo $user->user_nicename; ?> (<?php echo $user->post_count; ?> Posts)<br /> <?php echo 'Posts made: ' . count_user_posts(1); ?> </li><br /> <?php endforeach; ?> </ul> I have foreach function going, but count_user_posts requires an integer I don't pull in each individual user ID to grab their post amount. I would appreciate some help with this. I know it's probably something simple... I'm kind of new to php :D. Thanks a lot.
WordPress has a wp_list_authors function with the option to list post count. <?php $args = array( 'orderby' => 'post_count', 'optioncount' => true); wp_list_authors( $args ); ?> EDIT: While it's possible to do it the way you're doing it and use count_user_posts(), this will trigger a query to retrieve users, then additional queries to get each user's count. this is a very inefficient way to do this and may have a significant impact on performance if you have a lot of authors. A better way is to select users, and count the posts all in one query. If you look in `wp-includes/author-template.php` you'll see the query `wp_list_authors` generates to do this.
stackexchange-wordpress
{ "answer_score": 2, "question_score": 1, "tags": "posts, users" }
Media library only show 2 items per page? For some reason WordPress media manager is only showing 2 images per page? This is happening on 2 separate sites now and I can't get rid of it. Is there a way to manipulate items per page for the wp-admin media library?
thanks Jan - it was the 'more fields' plugin and the temp plugin fix is here; <
stackexchange-wordpress
{ "answer_score": 0, "question_score": 0, "tags": "pagination, attachments, media, media library" }
Wordpress for Podcast Network Is there a theme or some hack of the categories system that I can use to create a site for a podcast network? I want it similar to This Week in Tech in that all the podcasts will appear on the front page, but also each have their own homepage. I do not think a multi-site installation will be my solution. Each podcast must have its own RSS feed with podcast enclosures. Any ideas on how this could be done? I'm thinking that each podcast would be a category and each podcast home would be a separate category listing page.
Any Theme will do, for the most part. Simply install the Blubrry PowerPress Plugin or the podPress Plugin, and away you go!
stackexchange-wordpress
{ "answer_score": 2, "question_score": 0, "tags": "categories, podcasting" }
Wordpress 3.1.2 Network Enabled non-www to www OK so i am drawing a blank. I have setup a WordPress 3.1.2 Network site and want the main site to appear with www.mydomain.com not mydomain.com and i can get that to work but the back-end on the network admin breaks when i go to add a site it gives me the error "Are you sure you want to do this". When i disable the redirect of non-www to www it works fine. I have setup the wp_options table with site home and url of www.mydomain.com so i do not get this at all. I had it working in 3.0 but now 3.1 not working
Where are you trying to do the force redirect? I think the best place for this may be in a `.htaccess` file. Something like RewriteEngine on RewriteCond %{HTTP_HOST} !^www.your_domain.com$ RewriteRule ^(.*)$ [R=301]
stackexchange-wordpress
{ "answer_score": 1, "question_score": 0, "tags": "url rewriting, redirect, multisite" }
Linking an image to open a youtube video in lightbox/fancybox in wordpress Here is what i'm having problems with... I want to link a youtube video to start playing in a lightbox/fancybox when a person clicks an image. Kind of like this site has - < \- if you click the "Click to Play" (which is an image) a window will open (although not lightbox/fancybox) and video will start autoplaying. Would preferably want to do it with the least possible programing needed. I can do some basic editing but don't really know how to write any PHP/javascript
Follow Tip #4: < or I use Easy FancyBox for my wordpress sites. In the WP Admin, under Settings > Media you can edit the settings for Fancybox and it has a way to autodetect Youtube embeds.
stackexchange-wordpress
{ "answer_score": 1, "question_score": 1, "tags": "plugins, videos" }
What Does this Code Snippet Do? I got this error message when I was installing a plugin: "Unable to locate WordPress Content directory (wp-content)". I found a solution here: They suggested adding the following code to the wp-config.php file: if(is_admin()) { add_filter('filesystem_method', create_function('$a', 'return "direct";' )); define( 'FS_CHMOD_DIR', 0751 ); } This solution worked for me. My questions are: a) What does this code do? b) If I run into the same error on the production server is it safe to use this code? Thank you. -Laxmidi
The first part (`add_filter()`) tells WordPress to use the direct-write method. The second part (`define()`) tells WordPress to apply `0751` permissions to any directory it creates. More information here. I would **not consider using the Direct Write method to be safe** to use in a live, public, shared-hosting environment. Also, it might not - and in fact probably won't - work in a shared-hosting environment.
stackexchange-wordpress
{ "answer_score": 2, "question_score": 1, "tags": "wp config" }
Odd functions.php issue in Wordpress I'm using More Fields plugin, and when I use my functions.php to embed the custom field, I get an odd issue. The field value is followed by a "1" I use this code: //Address add_action( 'woo_post_inside_before', 'my_address' ); function my_address() { global $post; if ( is_single() && in_category('listings') ) { echo more_fields('address', '<h1>','</h1>'); } } But, if I use the following code - their is no "1" //Address add_action( 'woo_post_inside_before', 'my_address' ); function my_address() { global $post; if ( is_single() && in_category('listings') ) { echo meta('address'); } } How do I style the above using the echo meta? Or has anyone ever seen the "1" issue?
There is no WordPress function called `meta()`. Try using `get_post_custom()` (Codex ref) instead. For example: //Address add_action( 'woo_post_inside_before', 'my_address' ); function my_address() { if ( is_single() && in_category('listings') ) { global $post; $meta = get_post_custom(); echo '<h1>' . $meta['address'] . '</h1>'; } } Note: I'm not sure you need to call `global $post;` in this context? EDIT: updated to add HTML tags.
stackexchange-wordpress
{ "answer_score": 0, "question_score": 0, "tags": "custom field, functions, customization" }
While in "the loop", detect if a post is the most recent While inside "the loop" in WordPress, is there an easy way to detect if a post is the most recent? A Usage Example: I want to make the first post output an H1 for the title instead of an H2. Or I want the first post to display a thumbnail image (and not the rest). Here is some pseudocode what I'm trying to get across: if (have_posts()): while (have_posts()): the_post(); the_excerpt(); if(is_most_recent()): // do this endif; endwhile; endif;
In addition to @Milo Answer (this avoids a senseless query, because we already got every needed information from the current wp_query): if ( have_posts() ) : while ( have_posts() ) : the_post(); $headline_html_tag = $GLOBALS['wp_query']->current_post === (int) 0 && $GLOBALS['paged'] === (int) 1 ? '1' : '2'; the_title( '<h'.$headline_html_tag.'><a href="'.get_permalink().'" title="'.the_title_attribute( array( 'before' => 'Permalink to: ', 'after' => '', 'echo' => false ) ).'">', '</a>'.'</h'.$headline_html_tag.'>', false ); endwhile; endif;
stackexchange-wordpress
{ "answer_score": 2, "question_score": 2, "tags": "posts, loop" }
Static home page with "Blog" inside? I'd like to have a static home page and also have a link called "Blog" that lists posts in the "blog" category in chronological order. Would the best way to do this just be to place code in archive.php and do a "switch case" on the category and do a loop on the posts? Just looking for some options before I decide on a strategy and code the solution.
wp dashboard > 'Page' > add new > name it 'Home', publish wp dashboard > 'Page' > add new > name it 'Blog', publish wp dashboard > Reading Settings > 'Front page displays' select 'a static page' set 'Front page' to 'Home' page that you have added > set 'Posts page' to 'Blog' page that you should have added. It doesn't seem like you need to create a 'Blog' category. Just let your new 'Blog' page display the posts loop, which will be your index.php theme file.
stackexchange-wordpress
{ "answer_score": 4, "question_score": 0, "tags": "theme development" }
How to insert custom code into wp_nav_menu structure? I was able to use `<?php wp_nav_menu( array( 'theme_location' => 'primary-menu', 'container' => false ) ); ?>` to create the menu within my theme. Messed around with 'items_wrap' but couldn't get it to display correctly. I need to add an image and container div into the sub menu ul before the li's. This is the structure I want: <ul id="nav"> <li><a href="#">Page</a> <ul> <img src="<?php bloginfo('template_directory'); ?>/images/nav_ul_tab.png" class="nav_ul_tab" /> <div class="nav_spacer"> <li><a href="#">Sub Page</a></li> <li><a href="#">Sub Page</a></li> <li><a href="#">Sub Page</a></li> </div> </ul> </li> </ul>
What you want is invalid markup. The only children an `ul` can have are `li`. Use CSS instead: #nav ul { padding-top: 40px; /* Your image size. */ background: url(/path/to/your/image/img.png) top center no-repeat transparent; }
stackexchange-wordpress
{ "answer_score": 5, "question_score": 1, "tags": "menus, css, navigation" }
adding .current* tags to custom post types and taxonomies TwentyTen adds some classes to custom menus, for instance: `#access #menu-item-262.current-menu-item, #access #menu-item-262.current-menu-ancestor` All the top-level links in my primary navigation have the class `.current-menu-ancestor` when the user is on a child page -- **except when I'm viewing content in the custom post type I've built**. _**How do I set the current page in navigation when viewing a custom post type?_** Thanks...
The classes are not added by the Twenty Ten theme, but by the common custom navigation menu code, in `_wp_menu_item_classes_by_context()`, which is called from `wp_nav_menu()`. If you want to add extra classes you can do that by either hooking into `wp_nav_menu_objects`, called once with the whole menu tree, or into `nav_menu_css_class`, called when rendering each individual item.
stackexchange-wordpress
{ "answer_score": 2, "question_score": 2, "tags": "custom post types, theme development, menus, navigation, theme twenty ten" }
Is it possible to use WordPress functions in a page template? When a user enters a page I want to check if he is logged in. How can it be done in the page's template? Or is it possible only in functions.php or a plugin?
if (is_user_logged_in()) { echo 'You are logged in. Yay!'; } Codex: `is_user_logged_in()`
stackexchange-wordpress
{ "answer_score": 1, "question_score": 0, "tags": "login, templates" }
How to remove row-actions from pages table? I've already found out here how to remove the row-actions from the posts table in wordpress admin. Now I'd like to do the same in the pages table. I've looked in the core files but, well, I just don't get it. Anyone? Here's the code used in functions.php to remove row actions in posts: function remove_row_actions( $actions ) { if( get_post_type() === 'post' ) unset( $actions['edit'] ); unset( $actions['view'] ); unset( $actions['trash'] ); unset( $actions['inline hide-if-no-js'] ); return $actions; } add_filter( 'post_row_actions', 'remove_row_actions', 10, 1 ); Thanks in advance!
For non-hierarchical post types the filter is called `post_row_actions`, for hierarchical it's `page_row_actions`. If you want to remove all actions you don't have to unset the individual items, you can just return an empty array. add_filter( 'page_row_actions', 'wpse16327_page_row_actions', 10, 2 ); function wpse16327_page_row_actions( $actions, $post ) { if ( 'page' == $post->post_type ) { return array(); } return $actions; }
stackexchange-wordpress
{ "answer_score": 3, "question_score": 5, "tags": "functions, admin, customization" }
Multiple sites that share some pages, but not others I'm pretty new to WordPress... I'm trying to set up a few sites, each with their own top level domain name. What I want them to do is share some of the pages, but not others. For example - they would all share Services, Contact, and Team pages; but would each have their own Biography page. When one of the shared pages is updated, they're all updated. I can't figure out if WP multisite is this or not? Thanks for your help.
I do not believe this is possible. The only way is to create the page in each site or add a custom link to one main page but doing this will show only that sites theme
stackexchange-wordpress
{ "answer_score": 0, "question_score": 2, "tags": "multisite" }
Using WordPress Multisite to manage multiple projects? I currently use WordPress for most of my projects, the way I manage them is creating a folder for each in my local environment each containing a WP install which in times makes it a paint to maintain, upgrade and takes more space. I was looking at WP Multisite and I was wondering if I could use it to create multiple projects with the same WP installation but ran into a problem, when I finish a project using my current method I just send my client a SQL Dump of my DB, tell them to replace the URL and install all the files/folders to his server and it works fine. But WP Multisite creates an unique folder and DB structure which makes it difficult to do this since most of my clients won't be using MU but regular Wordpress installations. So is there an easy way to "export" a WP MS site to use it on a regular WP install? Or should I stick to having multiple WP copies? Thanks in advance!
Export/Import like you would the data for any other WordPress install: On the development site: 1. `Dashboard -> Tools -> Export -> All Content` (save file) 2. Package up the Theme files as "theme-name.zip" 3. Make note of any custom settings On the live site: 1. Install the custom Theme 2. `Dashboard -> Tools -> Import -> WordPress data file (upload file) 3. Change any custom settings noted above EDIT: If you still want to try a database export, you could try network-enabling one of the many database-backup Plugins in the repository, such as WP-DBmanager, and running it from your dev site.
stackexchange-wordpress
{ "answer_score": 3, "question_score": 0, "tags": "themes, multisite" }
Fastest server stack configuration for WordPress? If you were configuring a new VPS for a WP website that hasn't launched yet, What technologies would you choose? (website specs below) **Website** Targeting 50-60k hits /mo. and more The website is designed to categorize embedded YouTube videos using a chained select menu (1 query for multiple boxes). Using less than 5 "static" pages. I would like to keep the homepage fairly static so the server can cache it easier. **Server** Starting with a Linode 512mb VPS, can scale up as needed. **What I have planned so far** After scouring the web, it seems that Apache with an Ngnix reverse proxy does not offer any benefits with unless you need Apache for cPanel, or are more comfortable with it (i'm not, just starting out). Latest Nginx PHP-FPM X-Cache (also using W3 Total cache in WP)
There's a post here that's very good about load optimization and performance: Steps to Optimize WordPress in Regard to Server Load? It might be a good idea to also utilize a CDN for a majority of your page requests. If you want performance you'll have to minimize requests to your database and setup aggressive caching. Working with Drupal i know this can be built into your drupal install. I'm not very familiar with Wordpress and if there are capabilities integrated into Wordpress to facilitate reverse proxy requests. If you're going to use mem-cache you may need more Ram to serve up the page. You may want to also setup varnish on your server. Setting up varnish alone will give you a big boost; as i've been told. Varnish <
stackexchange-wordpress
{ "answer_score": 2, "question_score": 5, "tags": "performance, nginx, vps" }
Cannot upload to S3 using CDN Sync Tool I'm trying to synchronise my files with the Amazon S3 server for distribution using CloudFront, as the CDN. I am currently having troubles syncing the files though. I've verified that the details are correct, though, when I click on sync it says it is syncing 1 item of many, but looking at the S3 bucket, it doesn't seem to do that. There are no errors in the PHP log to help me either. I'm running WordPress 3.1.2, on Windows Server 2008 R2, IIS 7.5 - PHP 5.3.6. cURL is installed, as per PHPInfo Any ideas what's going on here? Thanks, Shamil
I switched to W3 Total Cache, and it now works.
stackexchange-wordpress
{ "answer_score": 0, "question_score": 0, "tags": "customization, cdn" }
PHP in Edit Post link What is the best way to add php to the edit link? For example: insert `<?php echo of_get_option('dappo_actionbtncolor', 'dappblue' ); ?>` into the span tag of `<?php edit_post_link( __( 'Edit this', 'mytheme' ), '<span class="edit-link">', '</span>' ); ?>`
The easiest way might be to use `get_edit_post_link()` (Codex ref), which returns _just_ the link, allowing you to use it however you need, according to your purposes.
stackexchange-wordpress
{ "answer_score": 2, "question_score": 0, "tags": "php" }
Showing errors with $wpdb update I am using `$wpdb->update` to update a custom table I have in my database. When I `var_dump` the result it returns: int(0) So I tried `$wpdb->print_error()` to see what's wrong. However, it shows nothing. I also tried `$wpdb->show_errors()`, but again it showed nothing. The wpdb docs don't go into much detail on how to use these functions, so I am unsure if I am using them correctly. But why would the result of updating a table return 0, and not show any errors?
I would recommend running the following code right after your query to see what's happening: exit( var_dump( $wpdb->last_query ) ); This should print the last query that hit your database. In cases like these, I usually will manually run such a query through phpMyAdmin to see if it runs without errors and to see if it even affects the database. Additionally, by seeing the query that was actually run, you may find problems in the query that results from your code. For instance, the query may not return any MySQL errors, but it could run a query that is different than you expect it to be. With this debug code, you'll at least be able to see what it is and continue on the wonderful debug trail! Furthermore, you may want to explore more of the "Class Variables" (Codex Ref) for `$wpdb` as they may help further troubleshoot your issue.
stackexchange-wordpress
{ "answer_score": 25, "question_score": 27, "tags": "errors, wpdb" }
Customizing Titles on the Fly with Code I hope this question is easy. I want to customize my theme so that the post titles are created on the fly with code. For example, I might have a post where a price changes on the page 4 times a week, and I want to be able to change my to say: Get Product X for $19.99 without having to manually edit a meta variable... Is it possible to do? Is there a wordpress function I can call to override the title using a plugin?
I can't answer how you'll get your dynamic data with which to update your Post Title, but you can easily hook into the Post Title, using the `the_title` filter: <?php function mytheme_dynamic_title( $title ) { // do something to the Post Title, which is passed // into this function as the variable $title // and then return $title return $title; } add_filter( 'the_title', 'mytheme_dynamic_title' ); ?> That should get you started with hooking into the Title.
stackexchange-wordpress
{ "answer_score": 2, "question_score": 0, "tags": "plugins, theme development, customization, title" }
How to get a taxonomy term name by the slug? If I know a taxonomy term slug, how can I get that term's name?
The function you are looking for is `get_term_by`. You would use it as such: <?php $term = get_term_by('slug', 'my-term-slug', 'category'); $name = $term->name; ?> This results in `$term` being an object containing the following: term_id name slug term_group term_taxonomy_id taxonomy description parent count The codex does a great job explaining this function: <
stackexchange-wordpress
{ "answer_score": 61, "question_score": 39, "tags": "slug, terms" }
Login with OpenID, similar to Stack Exchange sites? Basically, I would like to add something like this into my WordPress site (which obviously will also give the user an option to sign up for an account using WordPress' default sign up system): !Stack Exchange login system with OpenID Is there any plugin or tutorial that may be helpful to accomplish this?
Try Make Your Site Social plugin which does most of the job for you !enter image description here
stackexchange-wordpress
{ "answer_score": 2, "question_score": 6, "tags": "plugins, login, openid" }
Analytics plugins that allow for inclusion of _trackPageLoadTime()? Are there any plugins that allow one to make use of the _trackPageLoadTime(); functionality available in the new version of Google Analytics yet?
Google Analytics by Yoast has _Custom Code_ setting to add stuff to tracking code. But says that it is added before `trackPageview`, while site speed instructions show it added after. Might or might not matter, I don't know. **Update** Plugin has been updated to support (and default to) site speed tracking.
stackexchange-wordpress
{ "answer_score": 2, "question_score": 4, "tags": "plugin recommendation, google analytics" }
Stream Video Player does not work with do_shortcode()? I have downloaded a plugin called Stream Video Player, which has a shortcode. If I put the shortcode into the content editor, it works well and it displays the video. However, if, inside a template I am creating, I call it through the `do_shortcode()` function, it doesn't work, it just shows the text `[stream bla bla]`. Can anyone help me and tell me why this is happening?
It's not really a shortcode, its a content filter but you can try calling the plugins function directly: if (function_exists('StreamVideo_Parse_content')){ echo StreamVideo_Parse_content("[stream flv=xxx.es/wp-content/uploads/2011/04/VIDEO-UE.mp4 mp4=xxx.es/wp-content/uploads/2011/04/VIDEO-UE.mp4 provider=video img=xxx.es/wp-content/uploads/2011/04/previo-video.jpg embed=false share=false width=500 height=333 dock=true controlbar=over bandwidth=high autostart=false opfix=true /]"); }
stackexchange-wordpress
{ "answer_score": 1, "question_score": 0, "tags": "templates, shortcode" }
Adding %author% in custom post type URL structure? I'm trying to do some WordPress URL rewriting ... Specifically I have custom post type that currently works like this: ` But I would like to have it located at: ` Is there any way to achieve this?
using Jhon's Custom Post Permalinks plugin it should be easy using: /%post_type%/%author%/%postname%/
stackexchange-wordpress
{ "answer_score": 5, "question_score": 3, "tags": "custom post types, url rewriting, author" }
A plugin for having rel="nofollow" in posts? I'd like to make all the links in posts on one of my sites to be with rel="nofollow" on links inside posts. I wasn't able to find a plugin that did the job except for WP-NoExternalLinks. It also didn't work, unless I used it's dooms day option: > "Mask ALL links in document (can slow down your blog and conflict with some cache and other plugins. Please use it on your own risk." But when I use it, it also puts nofollow on my blogroll links (which I would have preferred to keep alive.) Any suggestion what might be causing this? or how to resolve it? Thanks.
you can add a filter in your functions.php add // Nofollow in content add_filter('the_content', 'my_nofollow'); function my_nofollow($content) { //return stripslashes(wp_rel_nofollow($content)); return preg_replace_callback('/<a[^>]+/', 'my_nofollow_callback', $content); } function my_nofollow_callback($matches) { $link = $matches[0]; $site_link = get_bloginfo('url'); if (strpos($link, 'rel') === false) { $link = preg_replace("%(href=\S(?!$site_link))%i", 'rel="nofollow" $1', $link); } elseif (preg_match("%href=\S(?!$site_link)%i", $link)) { $link = preg_replace('/rel=\S(?!nofollow)\S*/i', 'rel="nofollow"', $link); } return $link; }
stackexchange-wordpress
{ "answer_score": 3, "question_score": 1, "tags": "plugins, links, seo, nofollow" }
Multiple image uploader under editor? I need a plugin for custom post type. I need something like this: !Mockup with image uploader under edit screen Can anyone suggest a plugin which has this feature, especially image upload and "Add another" button option.
This metabox class does exactly what you are after and so much more. wpalchemy-metaboxes
stackexchange-wordpress
{ "answer_score": 0, "question_score": 0, "tags": "custom field, plugin recommendation, images, uploads" }
get variable from url? say i've got a url < that works with; add_rewrite_rule( 'category/(.+?)/orderby/([^/]+)/order/([^/]+)(/page/?([0-9]{1,}))?/?$', 'index.php?category_name=$matches[1]&paged=$matches[5]&orderby=$matches[2]&order=$matches[3]', 'top' ); how do i get the value of orderby or order on a page? Think wordpress removes the GET values which is what i'd normally use... Just want to highlight the active order filter on the page!
ended up with; class="<?=( strpos( $oby ,'date' ) ? 'active' : null )?>" though can imagine i'll need to get this working on one job or the other... thanks all!
stackexchange-wordpress
{ "answer_score": 0, "question_score": 0, "tags": "url rewriting, filters, urls, variables" }
Wordpress 3.1's admin bar disappears only leaving its 28 px padding (in ubuntu)! At the begining, I thought there was an issue with my HTML or CSS files. But then I realized that other people using Wordpress 3.1 had the same problem (check out this link). The admin bar disappears when I click another 'Pages' or 'Posts,' but it leaves its 28px padding at the top of the page. I'm not sure if this has something to do with folder's permission issues in ubuntu (I'm using ubuntu 11.04). I did `chmod -R 777` to my `www` folder (the default folder for my `locahhost`), but I'm still having the same issue. Any suggestions to fix this?
Verify that `wp_footer()` is being called in all template files, and that the Admin Bar javascript and CSS are being properly hooked into the document head.
stackexchange-wordpress
{ "answer_score": 3, "question_score": 0, "tags": "admin, customization" }
Can't display custom menu using name? I want two menus using the new WordPress 3.0 feature. In `functions.php` I have: function register_my_menus() { register_nav_menus( array( 'header-menu' => __( 'Header Menu' ), 'top-menu' => __('Top Menu') ) ); } add_action( 'init', 'register_my_menus' ); And in `header.php` I have: <?php wp_nav_menu( array( 'name' => 'Header Menu' ) ); ?> .... <?php wp_nav_menu( array( 'name' => 'Top Menu' ) ); ?> Now they seem to fallback or something, always showing the same menu. The menus have been defined and setup in wp-admin "theme-locations". Why won't they load appropriately?
`wp_nav_menu()` does not have a `name` argument. Instead, you should use `theme_location`. With `register_nav_menus()`, you indicate that you have two locations in your theme where you can display a menu. The user can then create multiple menus, and assign them to these locations. This is why we have the indirection via `theme_location`. If you know the ID, slug or name of the menu you want to use, you can use the `menu` argument of `wp_nav_menu()`.
stackexchange-wordpress
{ "answer_score": 2, "question_score": 0, "tags": "menus" }
How do I use the control callback when creating a simple dashboard plugin On this page: < The function **wp_add_dashboard_widget** is described. It states: wp_add_dashboard_widget($widget_id, $widget_name, $callback, $control_callback = null) How do you use the $control_callback, properly? I am completeley stuck, as I have defined it but cannot use it. I need to create a form within this widget which is why I am using the control_callback. **EDIT:** as a side note I am using Wordpress 3 and Multisite
Solution : hover on the title bar of your widget, then click **configure** Don't ask me why this works like this but it does.
stackexchange-wordpress
{ "answer_score": 2, "question_score": 3, "tags": "widgets, dashboard, callbacks" }
Wordpress plugin for real estate that scales? Anyone have recommendations for wordpress plugins that can scale easily and integrates with Wordpress' new custom post types? Not interested in themes as discussed here: <
Ended up going with something custom in drupal. Seems like the best way to go.
stackexchange-wordpress
{ "answer_score": 0, "question_score": 1, "tags": "plugin recommendation" }
I'm a super admin and I want to give an admin the ability to add new users...? How can I do that? So far the admin can only add exisiting users.
To follow up to xLRDxREVENGEx's answer, here's a screenshot of the checkbox you need to check in the network admin section: !enter image description here
stackexchange-wordpress
{ "answer_score": 1, "question_score": 0, "tags": "admin, users" }
Countdown Widget Can someone recommend me a nice countdown widget plugin for Wordpress? I've been using the Countdown widget under Blogger and it's exactly what I need. A simple number from now until date or from date. I can't seem to find a very simple, easy countdown that does the same thing in Wordpress.
Yes, there's a great widget called the jQuery T-Minus Countdown Widget Enjoy!
stackexchange-wordpress
{ "answer_score": 1, "question_score": 0, "tags": "widgets" }
Multisite installation on an existing single installation How to create a blog in a sibling directory of an already installed WordPress directory? The domain is `example.com` and there is an existing installation in `blog` directory and the root directory at `example.com/` is free. Is it possible to create a blog at `example.com/anotherblog/` through multisite instead of `example.com/blog/anotherblog/`? On a new installation at the root this can be achieved by simply installing WordPress at the root and having two multisite blogs in two directories. However, that is total of 3 blogs(including the one at the root). Can the same be achieved without the 3rd blog and keep the root free?
I'm pretty sure that this can't be done. I think WP multisite can only control blogs that are underneath it - which is why you'd have to install WP at the root. I was once looking to do the same thing, and unfortunately all my research pointed to "no" being the answer.
stackexchange-wordpress
{ "answer_score": 0, "question_score": 1, "tags": "multisite, installation, directory" }
WordPress Cumulus How to install WP-cumulus add-on into WordPress ? Thanks,
there you go: **Installing wp-cumulus**
stackexchange-wordpress
{ "answer_score": 0, "question_score": -1, "tags": "plugins" }
Custom order of terms for custom taxonomy in admin and website I have a custom taxonomy registered for my custom post type. I need to make it possible for a user to specify the order in which the taxonomy terms should appear (something like menu order for pages). Then when displaying the taxonomy terms on the site I will use the specified custom order to order them. What is the best way to do it? Is there any plugin for it? Many thanks, Dasha
Thank you everyone for advice and apologies, I haven't realised that I hadn't have selected the answer for this question. Since I've asked it, I came across Category Order and Taxonomy Terms Order plugin. I mainly use this plugin for ordering.
stackexchange-wordpress
{ "answer_score": 0, "question_score": 4, "tags": "custom taxonomy, admin, customization, sort, terms" }
Plugin appends ugly URL string to index A custom background plugin has started to cause certain browsers (FF, IE8,9, Safari) to reveal an appended URL string when viewing the index page: < \- this mostly shows when not visiting the site directly, but rather when going through, for example, Google. This persists in IE 9 even after refresh or page reload, but does not on the other browsers. Screenshot: ![]( I have the following custom permalink structure enabled:`/%category%/%postname%/` Thanks for any input!
This doesn't have to be a plugin issue. If someone puts a link on their website to your blog say for example: www.example.com but not only that they place some random string: www.example.com/?foo=bar in that link to your site then when search engines crawl this page with the link to your site on google or any other search engine will see it and try to follow the link to your website. As is the URL is technically valid the search engine will cache it and serve this new URL to its users. Have a read over this post at Perishable Press that talks about it in detail. <
stackexchange-wordpress
{ "answer_score": 1, "question_score": 1, "tags": "plugins, permalinks, url rewriting" }
How to apply style to the body tag of a particular page? I have the following code: <?php if ((is_home()) OR (!is_single()) OR (!is_page('171'))) : ?> <body> <?php else: ?> <body class="last-page"> <?php endif; ?> However it doesn't seem to work as expected. I want the class "last-page" to be applied to the body of the page with the id of 171 and pages that display single posts. If I take the third condition out, the "last-page" class is applied correctly to single post pages but with the third condition there it doesn't get applied to any of the two. I want the "last-page" class to be applied to both single post pages and page 171. Appreciate the help.
from your verbal desription, i would think this should work: <?php if ( is_single() OR is_page('171') ) : ?> <body class="last-page"> <?php else: ?> <body> <?php endif; ?>
stackexchange-wordpress
{ "answer_score": 0, "question_score": 0, "tags": "conditional tags" }
how can I make $ work in wordpress for jQuery? I have a plugin I want to use, but it depends on the $ identifier, as apposed to using jQuery. Is it possible to enable the $, to save me recoding the plugin? **EDIT** The plugin automatically adds the javascript, therefore I can't wrap it.
Try this: jQuery(function ($) { /* You can safely use $ in this code block to reference jQuery Call your plugin here */ }) I think you already know this. But still for reference <
stackexchange-wordpress
{ "answer_score": 5, "question_score": 1, "tags": "jquery" }
WordPress Plugin Development - Headers Already Sent Message I'm developing WordPress plugins. When I activate my plugin, I'm getting the following message: > The plugin generated 293 characters of unexpected output during activation. If you notice “headers already sent” messages, problems with syndication feeds or other issues, try deactivating or removing this plugin. The plugin is working very well but I don't know why I'm getting this message. My plugin is : <
My guess is you get a PHP error, which generates output before the headers are sent. If you have `E_NOTICE` enabled, calling `$_POST['foo']` may generate a "Notice: undefined variable" error if that variable is not set. Best practice: never assume anything about GET, POST, COOKIE and REQUEST variables. Always check first using `isset()` or `empty()`. if ( isset( $_POST['foo'] ) ) { $foo = (string) $_POST['foo']; // apply more sanitizations here if needed }
stackexchange-wordpress
{ "answer_score": 10, "question_score": 15, "tags": "plugin development, headers" }
When is get_template_part() preferable to simply using the template.php files? In this post on wordpress.stackexchange.com I asked whether using get_template_part(), as demonstrated in the TwentyTen theme, is a recommended best practice. The general consensus I got was that it was not necessarily the best practice in all situations. This related question then is: can you provide me with an example where using get_template_part() _would_ be the recommended approach, over simply defining the separate template.php files? For example, I can either define archive.php, single.php and page.php; or I can define loop-archive.php, loop-single.php and loop-page.php. In what circumstances would it be preferable to use get_template_part('loop', 'single') and leverage loop-single.php versus simply defining single.php?
A recommended approach for using `get_template_part` would be for including bits of code that would otherwise be repeated frequently in all your templates. Like if you had conditionals defined within your loop that you wanted to include in archive.php, search.php, single.php etc. It also allows child themes to override that file and include additional more specific files. For example if you used `get_template_part( 'loop', 'single' )` and your theme only has a file named loop.php then a child theme could include a file named loop-single.php that would override your loop.php. It's basically a custom includes tag for template files other than header, sidebar, or footer.
stackexchange-wordpress
{ "answer_score": 6, "question_score": 6, "tags": "page template, customization, get template part" }
How can I limit WordPress editor roles to a specific category? We're trying to use WordPress as a light CMS system and we need to be able to section off parts of WordPress so that editors for one product aren't able to edit other products. Seems like out of the box WP has 5 user levels but there isnt any thought around fine grain access (without using WP Network)
Google is your friend ;) * Restrict categories * Role Scoper
stackexchange-wordpress
{ "answer_score": 3, "question_score": 3, "tags": "permissions, categories" }
How can I migrate all of my custom field thumbnails to the built-in post featured image? I am running a theme on my Wordpress install that was built for Wordpress 2.8, prior to the time that Wordpress started using featured images for posts. I am switching to a theme that was built for Wordpress 3.1 and it uses the featured image instead of looking for a custom field. I have a lot of old posts with the custom field for the image. Is there a tool I can use that takes the custom field image URL and turns it into the post's featured image? I Googled this and also searched here on Wordpress Answers to no avail. I did find a custom script on the Wordpress forums, but I didn't try it because some people had responded saying it didn't work correctly.
< LIsts a plugin: < I'm not sure by the article and description if what you are looking for is exactly what it does? It seems to imply that, but I'm not 100%
stackexchange-wordpress
{ "answer_score": 1, "question_score": 1, "tags": "custom field, post thumbnails" }
How do you add categories to custom post types in WordPress? I'd like to be able to have categories of a custom post type, how do you set this up? update I want to keep the default categories for regular blog posts, but a separate set of categories just CPT.
You need to add `'taxonomies' => array('category')` in your `register_post_type()` function.
stackexchange-wordpress
{ "answer_score": 4, "question_score": 7, "tags": "categories" }
How to hook get_terms() to only show count of posts that have custom meta Here is what I have: A custom post type that has a custom meta value added to a post that stores the posts expiry date. When the post passes this expiry date it no longer shows on the site. This works but I'm using something like this to list the terms for the custom post type: $termcats = get_terms('dcategory', 'hide_empty=0&orderby=name&pad_counts=1'); I'm showing the count of posts in the listed terms but the problem here is that the count shows all post whether or not if the post has expired. So for example I have one post in the term called `test` and that post is expired. The above code shows there is one post but when the user click the category they get a blank list. So I need a way to hook into get_terms() to ignore posts that have expired according to my date field in meta values.
As far as I remember counts for terms are stored in database, so there is nothing to modify when you fetch them - you simply get ready-made numbers. So you will either need to implement and maintain your special logic for counts completely separately or try to recalculate and modify native counts, see `wp_update_term_count_now()`.
stackexchange-wordpress
{ "answer_score": 2, "question_score": 3, "tags": "custom post types, posts, custom field, query posts, terms" }
Grab YouTube Thumbnail AFTER Post? I'm using a feed to receive special YouTube feeds organized via playlists. Unfortunately, the URL is not included in the description field, but I can get the videos to display by including the source URL on post. This works fine except since the URL is not in the post area in the editor, the YouTube thumbnail grabbers I have tried don't retrieve these thumbnails. Does anyone know a way I can fetch the featured image through the published version of the post? It needs to be automated because I have way to many post items to adjust them manually.
Each YouTube video has 4 generated images. They are predictably formatted as follows The first one in the list is a full size image and others are thumbnail images. so if you have the video url the you can extract the video id from it call your image, and to do that on posts that are already posted you can use `the_content` filter hook.
stackexchange-wordpress
{ "answer_score": 4, "question_score": 1, "tags": "rss, post thumbnails, youtube" }
What kind of object type is WP_Query? I am getting this error when I try to return the post_title value from my WP_Query: **Fatal error:** Cannot use object of type WP_Query as array Here is the code: $query = new WP_Query( array( 'meta_key' => 'Old ID', 'meta_value' => $atts['oldid'] ) ); return $query['post_title']; How can I show the elements of the post after this query? I am using WP_Query because I am making a shortcode to be used within Posts and Pages.
I'm not sure you understand the logic of `WP_Query`. Rather than explain in words, here's a code example; $query = new WP_Query( array( 'meta_key' => 'Old ID', 'meta_value' => $atts['oldid'] ) ); if ( $query->have_posts() ) return $query->posts[0]->post_title; return ''; Check out the codex on interacting with WP_Query. **UPDATE** : To use the query as you would normally, i.e. The Loop; <?php if ( $query->have_posts() ) : ?> <?php while ( $query->have_posts() ) : $query->the_post(); ?> <a href="<?php the_permalink(); ?>"><?php the_title(); ?></a> <?php endwhile; ?> <?php endif; ?> <?php wp_reset_postdata(); ?>
stackexchange-wordpress
{ "answer_score": 6, "question_score": 4, "tags": "wp query, shortcode, array" }
Fantastico pros and cons I am working with someone that has a host (internetplanners.com) that uses fantastico to install WordPress. Basically, my question is has anyone had bad experiences with fantastico or webhost internetplanners.com? _Note, I have installed Wordpress on my local machine (Windows) and didn't have any trouble. I don't have experience installing on a hosting service manually but think I could do it needed._ Since I wasn't familiar with fantastico one-click install, I did a search and found 2 links about reasons not to use fantastico: < 1) simplicity = false security (if upgrade breaks, it can be difficult to fix); 2) upgrade doesn't put in maintenance mode or back up database, 3) upgrade doesn't deactivate plug ins. from < : I agree with ZGani. Fantastico doesn't upgrade the third party scripts version frequently. So you have to wait for Fantastico upgrade to get latest version of WordPress. Thanks.
I always thought that Fantastico essentially just; 1. Placed a copy of WordPress on your server (not always the latest version, as you say, this is a local copy limited by the update frequency of Fantastico) 2. Set-up a database (and user) automatically 3. Configured `wp-config.php` accordingly Then you'd just continue to use WordPress for maintenance as you would normally. In the past, I've worked on WP sites that were set-up with it, and don't recall any issues updating it. Personally, being a geek, I always run a manual install. Just feels cleaner, plus I know I'm always starting with the latest and greatest version.
stackexchange-wordpress
{ "answer_score": 2, "question_score": 0, "tags": "hosting, installation" }
Why can't I hook into save_posts after admin_init? I'm trying to hook into the "save_post" action from an AJAX callback in my plugin, but it doesn't seem to work. In fact, hooking into "save_posts" only seems to work from a few key action execution points (e.g. "init" or "admin_init") but not from others (e.g. an "add_meta_boxes" callback). In my particular case, I'd like to click a button on the Edit Post screen to add a new custom metabox, and have it save the metabox's data properly. But of course by the time I click that button and add that metabox, I've already hooked the "save_post" action once and WP seemingly doesn't want to let me hook it again. Looking briefly through the WP source code, I don't see any obvious reasons why I shouldn't be able to hook that action again. Any ideas how to work around this apparent limitation, or at least an explanation as to why it's not working?
Adding function to hooks is runtime operation, it is not persistent. Whatever hook operation you run in Ajax actions - they are performed in separate WP instance and expire as soon as Ajax response is returned. They have no influence on currently loaded page. You probably need to hook your functionality to `save_post` as usual (not in Ajax action) and check for your additional metabox to handle it.
stackexchange-wordpress
{ "answer_score": 2, "question_score": 3, "tags": "metabox, ajax, actions, save post" }