INSTRUCTION
stringlengths
11
999
RESPONSE
stringlengths
0
999
SOURCE
stringlengths
16
38
METADATA
dict
Optimize post insert and delete for bulk operations? Not much noticeable when working with individual posts, but when you create or delete multiple thousands in bulk and by code - process is quite slow. Are there any good tweaks to apply and corners to cut? Context: * `wp_insert_post()` with categories and tags passed; * add several custom fields; * create and associate attachments (from existing files).
When updating post taxonomies, you can call `wp_defer_term_counting( true )` before you do your mass operation, and then `wp_defer_term_counting( false )` to update the term counts only once per term.
stackexchange-wordpress
{ "answer_score": 20, "question_score": 22, "tags": "posts, optimization, bulk" }
Am I using get_posts wrong? I have <?php $folioPosts = get_posts(array('category_name' => 'portfolio', 'numberposts' => 3)); if ($folioPosts->have_posts()) : foreach ($folioPosts as $folioPost) : setup_postdata($folioPost); ?> <article class="col3"> <?php if (has_post_thumbnail()) : ?> <p><a href="<?php the_permalink() ?>"><?php the_post_thumbnail() ?></a></p> <?php endif; ?> <p><a href="<?php the_permalink() ?>"><?php the_title() ?></a></p> </article> <?php endforeach; else : ?> <p>No folio posts to display ...</p> <?php endif; ?> I am getting > Fatal error: Call to a member function have_posts() on a non-object ... I think its because my args to get_posts are wrong. Did I do something wrong?
`get_posts()` returns an array, not a `WP_Query` object. If you want to use `have_posts()` and related functions, use a "raw" `WP_Query` object.
stackexchange-wordpress
{ "answer_score": 3, "question_score": 0, "tags": "theme development, get posts" }
How to get the post id from a permalink? How can I get the post id from a permalink like " in functions.php, I have tried url_to_postid() and get_page_by_path() but none seem to work.
Hi **@Tirithen:** Have you tried _(which assumes your custom post type is`'animal'` and not `'animals'`):_ $post = get_page_by_path('cat',OBJECT,'animal');
stackexchange-wordpress
{ "answer_score": 1, "question_score": 0, "tags": "permalinks, functions, posts, urls" }
Get WordPress post content by post id How can I get WordPress post content by post id?
Simple as it gets $my_postid = 12;//This is page id or post id $content_post = get_post($my_postid); $content = $content_post->post_content; $content = apply_filters('the_content', $content); $content = str_replace(']]>', ']]&gt;', $content); echo $content;
stackexchange-wordpress
{ "answer_score": 214, "question_score": 179, "tags": "posts" }
How do I get terms as a list for a specific post? get_terms allows me to get all taxonomy values, but how do I limit this to a certain post? I don't see anyway to feed a specific post ID to get_terms: < Perhaps there is another way to achieve this?
Ahah! I need to use get_the_terms instead, as this will accept a post ID. <
stackexchange-wordpress
{ "answer_score": 0, "question_score": 0, "tags": "custom taxonomy" }
Is it possible to read the ID of a post and then insert it into the html of the post? If possible I want to insert the ID of a post(from a custom post type) into the html of the post itself when its loaded in the viewport. The scenario is that the content of the custom post type is surrounded by a `<div>`. I want to append an 'id' to the `<div>` that includes the ID of the post. For example if the custom post type is glossary and the post ID is 351 then the resulting html would be: `<div id="glossary351"> Post content </div>` I looked at the conditional statements and googled on the subject but found that 1. A lot of applications of finding the Post ID were to do with showing the ID on the page, as opposed to inserting it into the html. 2. My almost non existent PHP skills were not up to fathoming out how to use the conditionals to get the result I need. I'd appreciate any pointers regarding: * Is this possible * Any examples of how to approach the problem Thanks
Try: <div id="<?php the_title(); ?>-<?php the_ID(); ?>"> This should give you a result of: <div id="Post Title-PostID"> Giving you a unique wrapper for each post.
stackexchange-wordpress
{ "answer_score": -1, "question_score": 0, "tags": "html, custom post types" }
WordPress crashes with "The service is unavailable." after trying to upgrade plugins i went to upgrade my plugins and it never came back .. now when i go to my blog i get an error stating: The service is unavailable. i tried renaming the "upgrade" folder under wp-content but that didn't seem to do anything. Any suggestions?
This is definitely not error message produced by WordPress, so it comes from server software. Please check server logs (if you have access and skills) and ask your hosting support to look into it. It is hard to make a good guess from this little information.
stackexchange-wordpress
{ "answer_score": 3, "question_score": 0, "tags": "plugins, upgrade" }
Post Content Displaying Below ALL Shortcodes Content For some reason, my posts content (the content placed outside of the shortcodes I have set up) is only displaying below all the shortcodes, no matter where I place content in the post. For example, I could set up a post like this: `[boxes cat="Features"]` `test content here` `[boxes cat="Reviews"]` And the test content will display below the Features AND the Reviews. Why would it do that? Some of my shortcodes use the php `include`. Here's an example of one of my shortcodes: function free_ms_cms( $atts, $content = null ) { $free_ms = TEMPLATEPATH . '/get-free-ms.php'; include($free_ms); } add_shortcode( 'free-ms', 'free_ms_cms' ); Anyone able to help? Thanks!
Are your shortcodes setup correctly? This usually means that your shortcode handling is echoing the shortcode content instead of returning it as a string. For your case, while you are including a file in your shortcode, I doubt that you have the file setup to return the output instead of echo'ing it. Try this instead: function free_ms_cms( $atts, $content = null ) { $free_ms = TEMPLATEPATH . '/get-free-ms.php'; ob_start(); //start an output buffer to capture any output include($free_ms); return ob_get_clean(); //return the current buffer and clear it } add_shortcode( 'free-ms', 'free_ms_cms' );
stackexchange-wordpress
{ "answer_score": 4, "question_score": 0, "tags": "theme development" }
Hide page title in Wordpress 3.0 I can't find the option to hide the page title. Is there some other plugin required to get this functionality? If you look in this video video you can see the option to set the page title. I don't have this option. I'm not looking for a code solution here, I need something which will allow end users to hide the title.
the videos shows options that come with the headway theme, in order to see them you must use the headway theme. it's not a build in functionality of WordPress, however you can use the_title filter to replace or remove the title for a specific post based on custom fields values like so: function my_title_filter($title){ global $post; $custom_t = get_post_meta($post->ID, 'my_title', true); if (empty($custom_t){ return $title; }else{ if ($custom_t == 'remove'){ return ''; }else{ return $custom_t; } } } add_filter( 'the_title', 'my_title_filter' ); and after you add this code to your theme's functions.php file all you need to do is edit the post/page you want to replace or remove the title and create a custom filed named "my_title" and enter your "new title" or "remove" to remove completely. Hope this helps
stackexchange-wordpress
{ "answer_score": 2, "question_score": 0, "tags": "customization, pages" }
after server upgrade, if I enable custom permalinks, my /feed stops working I have recently moved server and upgraded my wordpress install to the latest version. Now if I try to access /feed, I get a 404. It used to work. /?feed=atom works correctly. Thanks. **UPDATE** : I fixed it. Virtual host definition had AllowOverrides turned off, so .htaccess was not being picked up. Thanks all for the comments.
Wordpress writes url rewriting rules to the .htaccess file, but apache will only use the .htaccess file if AllowOverrides is allowed for the directory where the .htaccess is located. I enabled it by setting `AllowOverride All` in the virtualhost configuration, and my permalinks are now working again.
stackexchange-wordpress
{ "answer_score": 1, "question_score": 0, "tags": "feed" }
Link to File URL by default Every time I insert an image into my post, the default link is to the image attachment page. How can I change it so it always links to the File address?
Answered a similar question on the .org forums very recently. To sum it up though.. 1. Go to **< (replace `example.com` with your website address) 2. Scroll down the page until you see `image_default_link_type` 3. Set that option to either `file`, `post` or to an empty value. **Empty** = _No link_ **File** = _Links to the file(what you asked for)_ **Post** = _Links to the attachment page(default)_ Hope that helps.. :)
stackexchange-wordpress
{ "answer_score": 7, "question_score": 1, "tags": "images" }
How would an if statement surrounding a custom field with two variables (holding values) look like? This is from the codex: <?php if ( get_post_meta($post->ID, 'thumb', true) ) : ?> <a href="<?php the_permalink() ?>" rel="bookmark"> <img class="thumb" src="<?php echo get_post_meta($post->ID, 'thumb', true) ?>" alt="<?php the_title(); ?>" /> </a> <?php endif; ?> I want to include an if statement like the example above. But I can't figure out the proper way of doing that to the following: <?php // Set and display custom field $mainbar_left_title = get_post_meta($post->ID, 'Mainbar Left Title', true); $mainbar_left_image = get_post_meta($post->ID, 'Mainbar Left Image', true); ?> <div class="float-left"> <h2><?php echo $mainbar_left_title; ?></h2> <img src="<?php echo $mainbar_left_image ?>" alt="" /> </div> <?php ?>
`<?php if ( $mainbar_left_title && $mainbar_left_image ) : ?>` See <
stackexchange-wordpress
{ "answer_score": 5, "question_score": 0, "tags": "php, custom field" }
How to setup sidebar modules to use jQuery Accordian To use jQuery UI accordion, I need markup like <h3>Module 1</h3> <div> <!-- module content here --> </div> <h3>Module 2</h3> <div> <!-- module content here --> </div> ... How can I setup my side bar like that? Or perhaps I somehow change the way jQuery creates accordian, maybe there are some options?
When you register your sidebar, you can change how it handles those things with the `before_title`, `after_title`, `before_widget`, and `after_widget` arguments. For example: register_sidebar(array( 'before_widget' => '', 'before_title' => '<h3>', 'after_title' => "</h3>\n<div>", 'after_widget' => '</div>' )); Would make all of the widgets in that sidebar have that structure. You could also add classes to the tags defined there (`<h3 class="accordion-toggle">`, `</h3>\n<div class='accordion-content'>`). Just make sure all your widgets have a title; otherwise the widget will cause some tag imbalance.
stackexchange-wordpress
{ "answer_score": 1, "question_score": 0, "tags": "theme development, sidebar" }
Function like in_category for custom taxonomies I'm trying to display different content depending on the taxonomy that was been selected. For example I have a taxonomy named Type. Inside that taxonomy I have several different children, one is "Photography." I'd like the single of a "Photography" to have a full width instead of it having a sidebar. You can do this in regular Posts by using "if in_category('photography')" but I've spent the past couple hours trying to rig the_terms and the like to function as such. Thanks in advance for the help. -Pete
Try function has_type( $type, $_post = null ) { if ( empty( $type) ) return false; if ( $_post ) $_post = get_post( $_post ); else $_post =& $GLOBALS['post']; if ( !$_post ) return false; $r = is_object_in_term( $_post->ID, 'type', $type); if ( is_wp_error( $r ) ) return false; return $r; } Usage: <?php if ( has_type( 'Photography' ) ) /* do your thing*/ ?> Hope this helps.
stackexchange-wordpress
{ "answer_score": 4, "question_score": 2, "tags": "custom post types, custom taxonomy, conditional content" }
When using Simple Fields plugin, how do I pull the information out of the database to display on a page? Pretty much what the question says. I used simple fields, but I'm unsure in WP how to get the information back to display on a page?
EAMann helped me and I was able to get the meta data from clicking on "show custom field keys" and using get_post_meta();
stackexchange-wordpress
{ "answer_score": 1, "question_score": 1, "tags": "plugins, custom post types, forms" }
How do I create filters for custom post types? Sorry the question might not make sense. I basically have a custom post type called "Projects" and I need to create a way to filter attributes of the project like "name", "type", etc. For example if I have a project type called airplane, and another project type called airplane. I would want to be able to search for all projects with the name airplane, and display those in the loop. I have looked into Taxonomies, but I do not know how to use them effectively. Thanks
This is how I did it. If you have your custom post type as "projects", and your category as "airplane". If you're not planning on using the pre-build loop you would make another one called loop-projects.php. However, it's not necessary. <?php $args = array( 'numberposts' => 5, 'post_type' => 'projects', 'category_name' => 'airplane'); query_posts( $args ); get_template_part( 'loop', 'projects' ); wp_reset_query(); ?>
stackexchange-wordpress
{ "answer_score": 1, "question_score": 1, "tags": "custom post types, custom taxonomy" }
Filtering multiple meta_values I'm trying to create a filter using two meta_values. Example. If the current page has meta values red and blue, only display queried pages that have both red and blue and none that have just red or just blue. I thought this could be accomplished with two meta values `'meta_value' => $red, $blue` but apparently it's not available. Below is where I found myself before the block. I've done a ton of research and simply can't find a method that works. Any help would be appreciated. $red = get_post_meta($post->ID, 'red', true); $blue = get_post_meta($post->ID, 'blue', true); $args = array( 'post_type' => page, 'nopaging' => true, 'post_parent' => 1440, 'meta_value' => $red, $blue ); query_posts($args);
'meta_query' is what you're looking for: <
stackexchange-wordpress
{ "answer_score": 3, "question_score": 1, "tags": "post meta" }
Adding a Widget : what to put in plugin URL I am signing up to add a widget to wordpress.org here: < What do I put for the field "Plugin URL"? Would that URL be the svn repository I am currently hosting my widget (a personal svn repo) or would that be a URL of a website where the widget is being used?
When adding a plugin to WordPress.org plugin repository you need to host the plugin somewhere (anywhere) and that is the "Plugin URL" so the good guys at WordPress could download it, test it and approve it to be listed. so just upload it to your host and enter the url to the zip file. Once it gets approved you will get access to < using your WordPress.org user name and password. > Here's some handy links to help you get started. > > Using Subversion with the WordPress Plugins Directory < > > FAQ about the WordPress Plugins Directory < > > WordPress Plugins Directory readme.txt standard < > > readme.txt validator: < this is what you get in the "WordPress.org Plugins Request Approved" email notification. Hope This helps.
stackexchange-wordpress
{ "answer_score": 2, "question_score": 1, "tags": "widgets" }
How do I stop Topsy from spamming my site with those annoying trackbacks? Every time I publish a post, Tospy adds their pingback to my post. It's annoying, but I don't know how to stop it. Any advice?
Add `topsy.com/trackback` (or whatever they are using for those links now) to `Settings` > `Discussion` > `Comment Blacklist`.
stackexchange-wordpress
{ "answer_score": 5, "question_score": 3, "tags": "pingbacks" }
After creating custom post type, URL to custom posts are invalid So I created a custom post type like add_action('init', 'create_post_type'); function create_post_type() { register_post_type( 'portfolio', array( 'labels' => array( 'name' => 'Portfolio', 'add_new_item' => 'Add New Portfolio Item', 'edit_item' => 'Edit Portfolio Item' ), 'public' => true, 'capability_type' => 'post', 'supports' => array('title', 'editor', 'thumbnail', 'excerpt'), 'menu_position' => 5 ) ); } When I add a new custom post ( and try going to that page, I get a 404. Whats wrong? **UPDATE** This solution works but what does it do and it sounds like its not good to keep flushing my rewrite rules isit? > Add > > > flush_rewrite_rules(); > > > after you call `register_post_type`.
All that does is reset the rewrite rules. You could do the same by visiting the permalinks page and clicking save. You do need to reset them once but not every time. There is no need to flush every time you call register_post_type
stackexchange-wordpress
{ "answer_score": 2, "question_score": 0, "tags": "custom post types" }
Is Using WordPress Supplied WYSIWYG Advisable? I have been considering using the `the_editor` function to create WYSIWYG editors in my own pages. Is using the WordPress's inbuilt WYSIWYG editor in a plugin meant for general distribution advisable? Is it considered a part of the API that we can rely on to not change and break the plugin in future versions?
Yes using the built in editor is the right way to do it. WordPress prizes backwards compatibility so the function should continue to work forever.
stackexchange-wordpress
{ "answer_score": 2, "question_score": 1, "tags": "plugin development, wysiwyg, customization" }
highslide is overlapped I just integrated High Slide to my wordpress site, which I found over here < I am displaying a form in this high slide window, but the problem is, I have youtube video on my every post and it is overlapping the form and the window, Check this image !enter image description here I dont want this overlapping, and also when I click on the Inline HTML link(which will popup the form) I want that the background should be in dim black color How can that be done?
The problem you have is not with highslide, but rather with your youtube embed. You need to add `<param name="wmode" value="transparent">` to the object tag and `wmode="transparent"` to the embed tag. If you're using the iframe version I think it's `allowtransparency="true"` but I've never tried it with the new iframe code so I'm not sure about that last one.
stackexchange-wordpress
{ "answer_score": 1, "question_score": 0, "tags": "html" }
Plugin Repostitory Questions Hei, i've been developing a few plugins over the last few weeks that i want to share, soon, such as: * a 'helper'-plugin, that eases the creation of standard option pages * a photo contest manager * a subcription signup manager (a rewrite of 'user role subscriptions' by Byrd) * a basic affiliate ad campain manager with referral tracking Since im a lazy c*** i'm wondering if there's a necessity to setup my own site properly (which i have, but it still shows the ads from the hosting company ;-) ) or if using the SVN hosting offered by Wordpress Plugins gives me all i need? Also, what are the licensing policies when hosting on Wordpress Plugins? Thanks.
The plugins have to be licensed under the GPL and no, you don't have to set up your own site for them. More info here: <
stackexchange-wordpress
{ "answer_score": 2, "question_score": 0, "tags": "plugins, hosting" }
Shortcode But Without The Equals Sign? I am aware of creating a shortcode this way: function font_fam($atts, $content = null){ extract(shortcode_atts(array( 'f' => '', ), $atts )); return '<span style="font-family:'.$f.'">'.$content.'</span>'; } add_shortcode ('f','font_fam'); And to use it would be like this right: [f f="Arial"] Text Text [/f] But is there a way so that it will be used like this: [f Arial] Text Text[/f] [f Tahoma] Text Text [/f] (skipping the "f=") Thanks!
Try this: function font_fam($atts, $content = null) { extract(shortcode_atts(array( 'f' => isset($atts[0]) ? $atts[0] : '' , ), $atts)); return '<span style="font-family:' . $f . '">' . $content . '</span>'; } add_shortcode ('f','font_fam');
stackexchange-wordpress
{ "answer_score": 5, "question_score": 2, "tags": "shortcode" }
Custom Taxonomies but with Icons associated? Can I have custom taxonomies but with icons associated with them? Example: I want a list of skills I used for my portfolio item (eg. PHP, MySQL, CSS etc). Instead of text, I thought of displaying icons. So I needto somehow set icons for my taxonomies. How might I do it? Is it very complex? How might it look or whats it like to build it? the steps?
I'd suggest the Taxonomy Images Plugin. It says it's in Beta but I've used it on a few sites already and it works great.
stackexchange-wordpress
{ "answer_score": 2, "question_score": 3, "tags": "custom taxonomy" }
After creating hierarchical post type, still not getting any way to set parent After creating a custom post type like below, I still dont get any option to set the parent of the post, am I missing something? register_post_type( 'projects', array( 'labels' => array( 'name' => 'Projects', 'singular_name' => 'Project' ), 'public' => true, 'capability_type' => 'post', 'supports' => array('title', 'editor', 'thumbnail', 'excerpt', 'comments'), 'hierarchical' => true, 'menu_position' => 5 ) ); ![](
Try adding 'page-attributes' to the supports flags: `'supports' => array(..., 'page-attributes')`.
stackexchange-wordpress
{ "answer_score": 3, "question_score": 1, "tags": "custom post types" }
How can I query for all children posts regardless of parent How can I get all children posts regardless of parent. If you require more info: > The setup I have is like this: I have a custom post type "Project". I will create top level pages as the "main" project page. Then I will have children pages as something like a project blog. Mainly for WIP posts. > > I will have a Portfolio page that shows all completed projects, and a "WIP" page showing all WIP posts regardless of project. How can I do this
Couple of possible ways. 1. Use `get_pages()` with `parent => 0` to fetch top-level ones and put them as `post__not_in` in query. 2. Filter `posts_where` to add `AND post_parent > 0` when necessary.
stackexchange-wordpress
{ "answer_score": 2, "question_score": 0, "tags": "query posts" }
How do I add a front menu button that redirects to another website or sub-domain? _Hello there,_ > I would like to add a front menu button (viz. Home, About, Archive etc.) to my blog that links to another website. WordPress only shows the pages that I have created using dashboard in the front menu. I hope my question is clear. Let's assume I have a Yoga blog and a Yoga store at another website. I'd like to add a "STORE" button -- after my Home, About and other pages -- that links outside the WP blog. Thanks for your help. :) PS - I am using lightword theme.
Lightword theme as wp_nav_menu enabled so you can create your menu from the > Appearance → Menus panel where you have Custom Links and that is just what you are looking for. you can read more on how to use WordPress Menus panel Hope this helps
stackexchange-wordpress
{ "answer_score": 4, "question_score": 1, "tags": "html, pages" }
Require Custom Taxonomy for Custom Type I have created a fairly unexciting custom type (Event) and an equally vanilla custom taxonomy (Venue). Whenever a user creates an Event, I want them to be required to either create a new Venue or select an existing Venue. How can I make this a required field when publishing? It seems like the sort of thing that should be rather trivial but I've been going up and down < and haven't found anything obvious. Am I going about this in the wrong way? Any assistance would be appreciated.
You can hook an 'init' action callback in which you get the post-type and if it's 'event' check $_POST for if your taxonomy value is empty. If it's empty, you can then reset $_POST['action'] to 'edit', so that post.php simply reloads the editor. And you can inject $_GET['message'] = 11 and add your (11th) response message via hooking a callback to the 'post_updated_messages' filter. That's not ideal, but it's somewhat of a solution.
stackexchange-wordpress
{ "answer_score": 0, "question_score": 0, "tags": "custom post types, custom taxonomy" }
Create a homepage like Wordpress.com? How can I create a homepage like Wordpress.com. I am currently using wordpress MS and would like to display the latest posts across the network on the homepage. How is this possible?
This theme sort of does the same thing <
stackexchange-wordpress
{ "answer_score": 2, "question_score": 1, "tags": "multisite" }
Whats the way to format a date after using get_posts() I see that theres no way to get a formatted date from a function like echo get_the_date($post->ID, 'd M Y'); `get_the_date` only works with the current `$post`. If I used `get_posts()` how can I format the date. With pure PHP I can do something like ... echo DateTime::createFromFormat('Y-m-d h:i:s', $cp->post_date)->format('d M Y'); but its abit long, and I don't know if there's a need to actually create a `DateTime` object, perhaps its a waste of resources?
`echo date('Y-m-d h:i:s', strtotime($cp->post_date));` ... or better use the wordpress functionado `echo mysql2date('Y-m-d h:i:s', $cp->post_date);`
stackexchange-wordpress
{ "answer_score": 7, "question_score": 3, "tags": "date time, get posts" }
What template is used for a custom taxonomy page? When I create a custom taxonomy, what template file is being used to display the page? How might I create a custom listing page for my custom taxonomy. eg. I have a custom taxonomy skills. In it are values like: PHP, MySQL, HTML/CSS/JS ... When users goto say `/skills/php` they will see all posts containing PHP in skills. What template is used by default for this page and how might I create a custom page template for this?
It really depends on your theme. Term archive views are governed by the rules of template hierarchy which means that more than one template may display these archives. For your project, I would suggest that you create a new template file called "taxonomy-skills.php". This file will get use only for archives of skills enabling you to create a design that differs from other term archive pages. You do not need to start from scratch. It often saves time to copy the contents of another file and adjust the code to your needs. I would first look for taxonomy.php. If it exists in your theme, copy and paste it's contents into "taxonomy-skills.php". If this file does not exist, try to locate the following files in the order specified: category.php, archive.php, index.php. Best, -Mike
stackexchange-wordpress
{ "answer_score": 8, "question_score": 1, "tags": "custom taxonomy, page template" }
404 errors after plugin options update and category base change I'm calling the function below after each "save changes" on my plugin's settings file via the sanitization callback. The plugin allows the end user to change their category base, and needs to completely rewrite the permalinks in order to avoid 404 errors. However, I'm still getting 404s. The only way I can resolve them is to go to the "Settings > Permalinks" manager and clicking "Save Changes". What am I missing in this function to get rid of the 404s? function myplugin_refresh() { wp_cache_flush(); global $wp_rewrite; $my_permalinks = get_option('permalink_structure'); $wp_rewrite->set_permalink_structure($my_permalinks); $wp_rewrite->flush_rules(); }
Check the code in wp-admin/options-permalink.php lines 91 to 129 (3.0.5). Compare if you do all that.
stackexchange-wordpress
{ "answer_score": 0, "question_score": 2, "tags": "plugin development, permalinks" }
Is there an easy way of exporting posts with their category already asigned and pictures from localhost? Every time I export a database using the Export Tool in wp-admin. There are two things left out: The category 'checked' (I have to do that all over again every time I export the posts). Also I can't download the pictures because I usually work in my localhost. How to export absolutely everything (100%) from the database of a Wordpress site?
To export everything in the database, go to your hosting provider's control panel such as CPanel and find out how to do _"an SQL dump"_. An SQL dump is a text file containing the SQL script to rebuild your database on your local computer. You can often do that in software your host may provide named phpMyAdmin. Alternately you could use a desktop SQL tool; if you are on Windows one of my favorites is the free HeidiSQL; on Mac I used the commercial software Navicat for MySQL which I also used on Windows because of advanced features that HeidiSQL did not have. If you use a desktop tool you will probably have to enable remote access to MySQL from your IP address. After you've imported your SQL dump, you can consider using this plugin to _"fix up"_ all your URL references. Hope this helps. -Mike P.S. You'll need to use FTP to download all of your photos and other files you may have uploaded.
stackexchange-wordpress
{ "answer_score": 2, "question_score": 0, "tags": "database, export" }
How can I hide certain submenus of the Settings tab in the dashboard? I'd like to hide certain menus like Media, Privacy, and Permalinks. I've been using the following code to hide entire parent menus but not sure how to go about for submenus. function remove_menus () { global $menu; $restricted = array(__('Links'), __('Comments'), __('Appearance'), __('Tools')); end ($menu); while (prev($menu)){ $value = explode(' ',$menu[key($menu)][0]); if(in_array($value[0] != NULL?$value[0]:"" , $restricted)){unset($menu[key($menu)]);} } } add_action('admin_menu', 'remove_menus');
If you would like to code it yourself, here is a good tutorial for customizing the Admin Menu. < Copying from the tutorial, they remove the Editor sublink: function remove_editor_menu() { remove_action('admin_menu', '_add_themes_utility_last', 101); } add_action('_admin_menu', 'remove_editor_menu', 1); _note: you need to know the function / action that displays it_
stackexchange-wordpress
{ "answer_score": 2, "question_score": 3, "tags": "dashboard" }
How to create thumbnails with a fixed width, so all of them will have the same width? right now, a thumbnail will be _either_ 150px in height _or_ in width, depending if it's landscape or portrait. Is there a way to make them always the same width and scale them in height accordingly, without squaring them? Kind regards
Use `add_image_size()` in your `functions.php`: add_image_size( 'post-icon', 150); ...and then use this in your template: <?php the_post_thumbnail('post-icon'); ?>
stackexchange-wordpress
{ "answer_score": 3, "question_score": 4, "tags": "images, customization, post thumbnails" }
Wordpress “Categories to tags converter” not working. Pointing to import.php instead I just imported my posts from blogger into wordpress. In doing this, the tags were converted to categories for some strange reason. I am now trying to convert them back into tag using wordpress' built in converter. However, whenever I click on the "Category to tag converter" link, it directs me to the import page "/import.php". Is there anything i can do to rectify this. Alternatively, could someone please copy the end of the URL for the converter tool's page, and paste it here so i can append it to my blog URL. Im guessing that could work meanwhile. Cheers in advance..
It's not actually included with WordPress, you'll need to download it. Plugin can be found here. < Once that's activated you'll be able to reach the importer at. **yoursite.com/wp-admin/import.php?import=wpcat2tag** Hope that helps.
stackexchange-wordpress
{ "answer_score": 0, "question_score": 1, "tags": "plugins, categories, tags" }
Front end post editing using a form I have a custom-post type with the standard meta boxes and some custom fields. How could I edit a post through a form in the frontend?
If you want to edit an existing post, try my Front-end Editor plugin. If you want to create new posts, try one of these: * < * < * < * <
stackexchange-wordpress
{ "answer_score": 6, "question_score": 10, "tags": "custom post types, posts, editor, front end" }
How to change a user's password programatically I am trying to create a totally different profile page (not the one provided by Wordpress), since the layout and feel of the default profile page is too "Wordpress" for the users. Now I am successful in being able to present a page that can modify user meta data like firstname, lastname, city, zip code, etc. Now what stumped me is changing the password of the user. Is there any built-in wordpress function, say change_user_password($user_id, $new_password)? I'm surprised that I can't look for anything that does this. Worse comes to worst I'm doing an `UPDATE wp_users SET user_pass = md5($new_password) WHERE ID = $user_id`, but I would be really amazed if there is no function for this one.
wp_set_password( $password, $user_id ); See reference for details.
stackexchange-wordpress
{ "answer_score": 35, "question_score": 22, "tags": "plugins, plugin development" }
First Wordpress Plugin - Stat Issues I built my first plugin and after a bumpy start got my plugin downloadable from the WordPress. On my plugin's stats page it version 1.2.0 is the only active version in the pie chart. See: < Why is that?
I'm having the same problem. Take a look at the opening comments of content-types-wordpress-plugin.php, it looks like there are extra line breaks between each line, which may disrupt the parser that pulls out the version number, etc. If you don't see the extra breaks when you develop locally, you may have to play with the settings in your text editor; specifically, Unix line breaks vs Mac or Windows ones, but possibly other settings also. If that doesn't work, compare your comments against the example in the Codex and the file header specification to see if you notice any minor differences.
stackexchange-wordpress
{ "answer_score": 0, "question_score": 1, "tags": "plugins, plugin development, statistics" }
Using a Shortcode to Replace Themes Stylesheet? Is there a function to replace the active theme's stylesheet with a different one (not just adding a new one, but actually replacing the current one)? I'm developing a plugin, and using shortcodes (eg: [design style="dark"]) and I want this shortcode to remove the current stylesheet and apply a new one, along with new HTML for the page as well. **In fact,** I want this shortcode to completely replace _all of the source code_ for that specific post. Can anybody point me in the right direction? Thanks in advance.
Main stylesheet of theme is surprisingly rigid concept. It is usually semi-hardcoded in `header.php` before any meaningful hooks and is very hard to change by code and reliably. Since your context is actually wider and includes markup as well, you are better of hijacking template entirely, see `template_redirect` action for starters.
stackexchange-wordpress
{ "answer_score": 3, "question_score": 1, "tags": "plugin development, shortcode" }
User-submitted reviews of different custom post types How would one go about allowing reader-submitted reviews of different custom-post-types? For example, if I had a site with a custom-post-type Restaurant and custom-post-type Accommodation. The review structure for each would basically be the same (name, email, comment and rating), and just the star-rating would be styled differently (cutlery vs beds instead of stars). When you view each restaurant, you'd see the reviews for that restaurant, and when you view the restaurant archive, you'd see all the restaurant reviews but not the accommodation reviews, and vice versa for accommodation. Would customising the comments ability in WP be sufficient for something like this?
Yup, customizing comments should do the trick for you. No need to reinvent the wheel and you can take advantage of many plugins that take the comments functionality a few steps further. You can use some plugin to add the rating functionality (GD star rating seems to be the most used one) or use comments meta fields to write your own. When it comes to styling be sure to check the output of body_class() and post_class() functions - you should find a class referencing your post type there.
stackexchange-wordpress
{ "answer_score": 2, "question_score": 0, "tags": "custom post types, comments" }
Function Reference Documenting Template Tags for use in Custom Theme Templates? _( **Moderators Note:** Original title was "custom template / wordpress functions?")_ I'd like to use a modified WordPress theme template and was wondering where I can find a reference for the .PHP functions that can be used within theme templates?
You can find an extensive function reference on the codex here. < And there's also the WordPress PHP Doc which can be found here. < Anything in particular you were looking for?
stackexchange-wordpress
{ "answer_score": 1, "question_score": 0, "tags": "php, functions, templates, customization" }
removing <li> tags from wp_list_pages() using PHP as the title states, I am trying to remove the `<li></li>` tags from the list that gets generated with `wp_list_pages()`. My thinking is to somehow run a for/foreach loop through the menu items and remove the `<li></li>` tags using `str_replace()`, but first I would need to parse the returned list into an array or something to traverse through the list items... Any ideas on how I can accomplish that? or maybe a better way of going about it? Thanx in advance!
You could try to remove them, but maybe it's easier to not generate them in the first place. The page list is displayed by a _Walker_. This is a class that "walks" over all the items in the tree, and displays them. `wp_list_pages()` by default (via `walk_page_tree()`) uses the `Walker_Page` class, which displays everything in `<li>` elements. However, you can duplicate this class, remove everything it in you don't need, and pass that class to `wp_list_pages()` (with the `walker` argument).
stackexchange-wordpress
{ "answer_score": 6, "question_score": 1, "tags": "php, menus" }
How to override .htaccess with new rules without ftp or edit it manual I want script will add new rules to current `.htaccess` and user no need to ftp or edit it manually. Example, I use timthumb for resize image on my theme and want rewrite the URL and current `.htaccess` will be something like this. <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteRule ^images/thumb/(.*) timthumb.php?filename=$1 RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] </IfModule> Question How to add the new rule to the `.htacces` on my theme option. Enable Mod rewrite for Timthumb? : [Yes] [No] If click [Yes] `RewriteRule ^images/thumb/(.*) timthumb.php?filename=$1` will automatic added to current `.htaccess` Let me know
You can add extra rules right after the `^index\.php$` line via the `WP_Rewrite` class, more specifically the `add_external_rule()` method. They are added to the `non_rewrite_rules` array, which is written in the `mod_rewrite_rules()` method. This is a very simple example. You should still flush the rewrite rules (once), either on plugin activation or by visiting the _Permalinks_ page. add_action( 'init', 'wpse9966_init' ); function wpse9966_init() { global $wp_rewrite; // The pattern is prefixed with '^' // The substitution is prefixed with the "home root", at least a '/' $wp_rewrite->add_external_rule( 'images/thumb/(.*)$', 'timthumb.php?filename=$1' ); }
stackexchange-wordpress
{ "answer_score": 4, "question_score": 2, "tags": "php, theme options, htaccess" }
How can i move search results onto a specific page? I was wondering if it is possible to have the wordpress search results displayed on a different page? At the moment they are displayed on ` but I would like them displayed on my **search-results** template page, so ` Is this possible? Any help greatly appreciated, S.
You created a page with the slug `search` to "capture" that URL, but WordPress by default already uses that URL for search results. So you were "lucky" that this worked for you, and this is the reason the redirect supermethod mentioned will work. So, instead of creating a "fake" page to hold the template, you should just rename the template to `search.php`, like tnorthcutt suggested. If you still want to have content from the page defined in the admin area, I suggest you rename this page and get it via `get_posts()` or another method, because the main loop will contain search results, not this specific page.
stackexchange-wordpress
{ "answer_score": 8, "question_score": 7, "tags": "search" }
Combine internal search with Google custom search? I currently have a search box in my sites header, (on every page), which sends the search query to a page called 'Search', which uses a template called `searchpage`. The page/template uses Google custom search to display the results. Now this all works great, but I would like to use the built-in WordPress search to also return search results on the same page, above the Google results. Effectively using 1 search box to return 2 sets of results on the same page; 1 for WordPress and 1 for Google custom search. Is this possible and how would I go about doing it?
The standard search results can also be formatted with a theme file, by default `search.php`. You don't need to create a "fake" page for that. If you don't include any content from the page, and only use the theme file, you can just rename `searchpage.php` to `search.php` and it will work. If you do have some content that comes from a page written in the admin area, then you will have to query for this yourself (using `get_posts()` or another way), because the standard loop will only contain the search results, not that specific page. So if you want to add the internal WordPress search results to the page, just add a classic loop at the top, and this should display the results.
stackexchange-wordpress
{ "answer_score": 0, "question_score": 2, "tags": "search" }
Is there a way to tell menu items to force non-SSL URLs? I've got a client site which uses SSL for only a small chunk of pages where users purchase subscriptions. So, for those pages, we just make sure that any links into them have hrefs with < and everything's fine. The problem is that once they're finished with the purchase and _exit_ those pages using any links managed by the site theme menus, the SSL connection is retained. These URL references are not under our direct control, as they're just created by dragging the requisite page/category block around in the menu manager, so we can't adjust the http(s) portion. This results in spurious security warnings about unsecured content on pages that shouldn't be secured anyway, and some issues with certain bits of scripting, etc. How can we fix this? Is there something I'm missing?
The WP HTTPS plugin will be your friend.
stackexchange-wordpress
{ "answer_score": 2, "question_score": 0, "tags": "menus, ssl" }
What's a good way to unenqueue all scripts for a single template page? I've found that my attachment templates are inheriting the enqueued scripts for single posts. My first instinct was to unenqueue these scripts one-by-one or to do an `is_attachment()` check before enqueueing them at all. It strikes me that a more robust way to do this might be to simply be to remove any and all enqueued scripts for that page type; that way, I don't have to update code in multiple places if I add or remove an enqueued script in the future. Offhand I can't find a way to do this. What's a good way to unenqueue all scripts for just a single page?
I haven't tried it, but this might do it: global $wp_scripts; if (is_a($wp_scripts, 'WP_Scripts')) { $wp_scripts->queue = array(); } Basically just resetting the scripts queue to blank. Should work, I think. You'd want this right at the top of your attachment template, probably. From an optimization perspective, it would be faster to use the is_attachment() method to not enqueue the ones you want at all instead.
stackexchange-wordpress
{ "answer_score": 3, "question_score": 0, "tags": "themes, templates, wp enqueue script, scripts" }
template_redirect for single posts w/ custom fields Is there any way I can use `is_single()` inside of my plugin's functions.php file? Currently, this is what my code looks like: if(is_single()) : function my_template() { include(PLUGINDIR . '/supersqueeze/all.php'); exit; } add_action('template_redirect', 'my_template'); endif; But for some reason, it is not working at all. If I remove `if(is_single())`, it works but is for all pages. And then once I get that working, I'll need to filter it once more to see if the post has a certain custom field value, lets say the name will be `Design` and the value will be `Custom`. Thanks in advance for anyone who can help me out.
The problem with your code is that you're checking is_single() when your plugin is first loaded, before the global query has run, so is_single() still returns false. You should move the is_single() check within your my_template function: function my_template() { if(is_single() && have_posts() && 'Custom' == get_post_meta(get_the_ID(), 'Design')) { include(PLUGINDIR . '/supersqueeze/all.php'); exit; } } add_action('template_redirect', 'my_template');
stackexchange-wordpress
{ "answer_score": 5, "question_score": 2, "tags": "plugin development, custom field" }
Is it possible to query_posts using post__in and then Loop through them in the ordered they were queried? query_posts( array ( 'post__in' => array( 5, 76, 21, 56, 3 ) ) ); I'd like to query the Loop using `post__in` and a set Wordpress IDs. I'd then like to run through the Loop in the exact order of the query. Does anyone know if that is possible?
Yes, using this plugin: < Also see <
stackexchange-wordpress
{ "answer_score": 3, "question_score": 1, "tags": "query posts, loop" }
Sort plugins by rating When I want to install a new Wordpress plugin, I do a search for the plugin I want, and I receive a list of results. Is there any way to sort the results by rating, or name? If not, it would be a useful addition to Wordpress.
If you search for plugins at < rather than through your WordPress install you get more options on your search results.
stackexchange-wordpress
{ "answer_score": 2, "question_score": 6, "tags": "plugins, sort" }
Restore svn trunk of my plugin repository to the initial state? I messed it up and I don't know how to fix it. I thought it would be easier if I just literally delete all the files and start over again. Is there a way to do it? I tried some tips in google to no avail. Neither 'svn cleanup' nor 'svn delete' works. :-(
In the root directory of your SVN checkout directory, try this: svn revert -R svn update That usually will restore it to the main state.
stackexchange-wordpress
{ "answer_score": 1, "question_score": 0, "tags": "plugin development" }
WP 3.0.5: Best way to add custom metaboxes for post categories? I haven't been working with WP for a while and noticed that there are some new features in WP 3+ such as creating meta data for taxonomies. I'd like to be able to add unique meta data setups for different categories on my posts - what would be the best approach for this? Take for example the following categories: "press releases" "cases" "concepts" In the first, I'd like the admin to be able to attach more than just 1 image (the default thumbnail). In the other two I need the option of an additional textbox. Is this easier to do with custom post types? I'd rather work with the regular post categories. Thanks, -Staffan
WordPress doen't have a term/texonomy meta table in its database so in order to save the meta data you will need to either create your own table hold the data, use the Options table to hold the data or use a plugin that creates that table for you like Simple Term Meta. some tutorials * add meta data to categories using the options table * add meta data to taxonomies using the options table Hope this helps.
stackexchange-wordpress
{ "answer_score": 3, "question_score": 2, "tags": "categories, metabox" }
How do I embed a YouTube video in WordPress 3.0? I've upgraded to version 3.0. My site is wordswithfriends.net My administration panel looks like the following Add New Post screenshot with toolbar I thought there was supposed to be a special YouTube button which I don't seem to have. Adding media asks for URL + text and I just get a link not embedding.
According to the docs: < as long as you have "Auto-embeds" checked in Administration > Settings > Media SubPanel you can paste in the youtube url and if it's on its own line the video should be embedded. Alternatively you can wrap it in the embed short code e.g. [embed width="123" height="456"]...[/embed]
stackexchange-wordpress
{ "answer_score": 6, "question_score": 0, "tags": "youtube, embed" }
Is Dreamweaver CS5 a serious choice for theme/plugin development? I've heard that Dreamweaver has been improved significantly in latest versions. Does anyone have experience in developing a theme or plugin using Dreamweaver? What are the pros/cons? Thanks in advance
I guess the only real cons are it offers nothing that you cannot get with other editors, but without the massive bloat and pricetag. An IDE comes down to a lot of personal preferences and feel, since you have a lot of choice, some people swear by Notepad++, TextMate, or Gedit, others prefer something with more PHP features like NetBeans or PhpStorm. Here is a list of PHP based IDE's A list of text editors Personally I really dislike DW.
stackexchange-wordpress
{ "answer_score": 2, "question_score": 1, "tags": "plugin development, theme development" }
looking for navigation plugin (accordion) does anyone know if there's a jQuery-navigation plugin with accordion animation which can be auto-applied to the wordpress default navigation? it should also support marking the current item (+ also its parent) - any ideas? thanks
Try using DropDown Menu. It worked perfectly for me. Good luck! :)
stackexchange-wordpress
{ "answer_score": 1, "question_score": 1, "tags": "plugins, jquery, navigation" }
Add custom fields from different posts I am trying to add up custom fields from different posts. The array I created is not working. Here is the code. <?php $totalpricearray = query_posts('post_type=items&author='.$thisauthorID.'&tag='.$thispostID); while (have_posts()) : the_post(); $productprice = get_post_meta($post->ID, "productprice", true); $productquantity = get_post_meta($post->ID, "productquantity", true); $totalproductprice = ($productprice * $productquantity); echo $totalproductprice, ','; endwhile; $totalprice = array($totalpricearray); echo array_sum($totalprice); ?> Any ideas, Marvellous (ps just noticed array is working but equals 0)
<?php $totalprice_posts = get_posts('post_type=items&author='.$thisauthorID.'&tag='.$thispostID.'&numberposts=-1'); $totalprice_array = array(); foreach ($totalprice_posts as $post) { $productprice = get_post_meta($post->ID, "productprice", true); $productquantity = get_post_meta($post->ID, "productquantity", true); $totalproductprice = ($productprice * $productquantity); array_push($totalprice_array, $totalproductprice); } echo implode(',', $totalprice_array); echo array_sum($totalprice_array); ?
stackexchange-wordpress
{ "answer_score": 1, "question_score": 0, "tags": "php, custom field, array" }
Include related posts on a page i've got several posts which are tagged with "design", but also a page called "design". my question: i put some text into the design-page and would then display all posts which are tagged by "design". how is that possible? can i put a placeholder directly into the text or do i have to code it by myself in php? thx
You could easily modify the page template of your theme to include a section that reads "Related Posts" at the bottom and then execute a simple PHP query to get posts as follows: <?php query_posts('category_name=wordpress&showposts=5'); ?> <?php while (have_posts()) : the_post(); ?> <li> <a href="<?php the_permalink(); ?>"> <?php the_title(); ?> </a> </li> <?php endwhile; ?> You'd need to tweak the category accordingly, and you could always format the post listing the way you want.
stackexchange-wordpress
{ "answer_score": 2, "question_score": 0, "tags": "posts, pages, tags" }
Dynamic widgets In wordpress is it possible to have different widgets on different pages, I mean, I am having a form widget which has to be just displayed on posts page, it should just display on single.php Is this possible? Is their any plugin for this?
Hi **@ntechi** : Look at the plugin **Widget Logic**.
stackexchange-wordpress
{ "answer_score": 3, "question_score": 1, "tags": "widgets" }
Author custom fields post meta, the code? If I wanted to get a custom field of the current user I would use something like this. `<?php echo get_user_meta($user_info->ID,'address_line_2',true);?`> This time however I want the author so I tried multiple version of the following to no avail. <?php $thisauthorID = get_the_author_ID(); echo get_the_author_meta($thisauthorID,'address',true) ;?> Any ideas? Marvellous
`get_the_author_meta()` != `get_user_meta()`. Change to: `echo get_the_author_meta('address', $thisauthorID);`
stackexchange-wordpress
{ "answer_score": 2, "question_score": 1, "tags": "author, custom field, user meta" }
show the meta values to visitors that collected via coment form in stackoverflow (here) there is a solution for collecting extra information from visitors, and i want to ask that, is it possible to show the collected information to other visitors in his/her comment section? Thanks...
In the link you have provided it shows how to get the value of the "collected" meta using $twitter = get_comment_meta($comment_ID,'_twitter',true); so all that is left for you to do is edit your comments loop and add the next few lines in it. $extra_field = get_comment_meta($comment_ID,'_extra_field',true); echo $extra_field; Hope this Helps
stackexchange-wordpress
{ "answer_score": 3, "question_score": 1, "tags": "customization, comments, comment meta" }
how do I display a featured image in a post type? I have a single-posttype.php and I'm trying to figure out how to display the image
Everything you need can be found on the Codex documentation page for post thumbnails. < Specifically i think you're looking for.. <?php the_post_thumbnail(); ?>
stackexchange-wordpress
{ "answer_score": 2, "question_score": 3, "tags": "custom post types" }
Multiple plugins using the same OAuth class issues I just updated a plugin that needed to be updated. The issue is they added support for OAuth, the problem this plugin and another are using the same OAuth classes. Is there a easy way to fix this? I've never messed with OAuth or classes in PHP, I'm not a programmer. Error: PHP Fatal error: Cannot redeclare class OAuthSignatureMethod_HMAC_SHA1
Your code probably looks like this: class OAuthSignatureMethod_HMAC_SHA1 { ... } It should look like this: if( ! class_exists( 'OAuthSignatureMethod_HMAC_SHA1' ) ) : class OAuthSignatureMethod_HMAC_SHA1 { ... } endif; This is more a PHP issue than a WordPress issue, but if multiple plug-ins `include` or `require` files that declare the same class with the same name, you'll get a collision. You only need to _define_ the class once, then you can instantiate it as many times as you need in your multiple systems.
stackexchange-wordpress
{ "answer_score": 5, "question_score": 2, "tags": "plugins, customization" }
How to use relative links on my pages? In my web pages I want to use relative links instead of absolute links. However, pages do not allow php code inside them, so i cannot do to from a url in a relative manner. How does one get relative urls inside wordpress pages so that changing domain names wouldnt affect the links?
$my_url = 'my/relative/url.php'; echo site_url($my_url); site_url() when used by itself will return the absolute path to your blog. But, if you add an argument to it, as per my example above, it will prepend the absolute path to your path. Just make sure your URL doesn't contain a leading slash (eg: /this/may/not/work). Finally, if you happen to have your wordpress installed in your server's root, you can use a server-relative path (this uses the leading slash to indicate starting at the server root). So if your blog is installed at ` then you can access your relative links safely with `/blog/my_link.php`.
stackexchange-wordpress
{ "answer_score": 5, "question_score": 6, "tags": "permalinks, links, urls" }
wp_reset_query equivalent for WP Ecommerce I'm having product duplication issues while running two loops on a single page. Is there an equivalent to wp_reset_query for wp ecommerce? You can see the site at < You can see the loop here since it didn't format properly on the page. As you can see I set a variable to grab the first product only. The site only have 7 products so I didn't figure it would be a big deal to let the loop run 7 times. Of course I'd rather query for just the first product but wp ecommerce doesn't support queries like WordPress does, or at least that's what I've found. It then runs into the slider loop.
You can use (according to docu over @wp-ecommerce) `global $wpsc_query;` to modify your query. Resetting the loop can be done with `wpsc_rewind_products();` right before the second call to `while (wpsc_have_products()) : wpsc_the_product();` For the final solution, pls read the comments below.
stackexchange-wordpress
{ "answer_score": 1, "question_score": 1, "tags": "plugin wp e commerce, post duplication" }
How to call shortcode function directly and pass $atts I am using the Media Library Categories plugin. It does not have much documentation, so I have concluded the way to implement it would be using the shortcode `[mediacategories categories="6"]`. I want to implement this directly into the theme template. So I have tried: <?php if(function_exists(do_shortcode('[mediacategories categories="6"]'))) { ?> <h1>Inspiration</h1> <?php do_shortcode('[mediacategories categories="6"]'); } I also tried to implement the function directly, but could not pass the $atts correctly for the function to use them.
`do_shortcode()` just parses the string. You have to use `echo` or `print` to print it out. `function_exists()` expects a string that matches a function name. After looking at the plugin, I would try this code: <?php if ( function_exists( 'mediacategories_func' ) ) { ?> <h1>Inspiration</h1> <?php print mediacategories_func( array( 'categories' => 6 ) ); }
stackexchange-wordpress
{ "answer_score": 4, "question_score": 3, "tags": "plugins, shortcode" }
How to change my URL on intranet I have a WordPress blog installed on my machine. I got a strange requirement from my team but I don't know how I should implement it: blog pages should be segregated under "blog/" or a similar sub-domain. For example: < rather than < How should I do this? The index page of the website is the WordPress front page.
Add "blog" to your Permalink settings, like: /blog/%post_title%/
stackexchange-wordpress
{ "answer_score": 0, "question_score": 0, "tags": "permalinks" }
How to display custom taxonomies in posts? Almost all themes display categories (with its permalink) by default. I am looking for similar type of code to add in my theme. From where can I get it? To create custom taxonomies, I'm using More Taxonomies plugin.
The easiest way to list terms of custom taxonomy and display them would be to use <?php get_the_term_list( $id, $taxonomy, $before, $sep, $after ) ?> For example in the loop, my custom taxonomy is 'jobs' list as li <ul><?php echo get_the_term_list( $post->ID, 'jobs', '<li class="jobs_item">', ', ', '</li>' ) ?></ul>
stackexchange-wordpress
{ "answer_score": 17, "question_score": 6, "tags": "custom taxonomy, taxonomy" }
How do I use add_action on custom widget? First hope you will take a look example widget < There have male and female option. Let say I select male and I want add male.css to `wp_head` When I put something like this into the code it's not working. add_action('wp_head','load_face'); function load_face() { wp_enqueue_style('style', WP_PLUGIN_URL . '/sample/'.$sex.'.css', null, null, 'screen'); } Let me know what is the correct code to archive my goal. :)
when calling a function within a class you need to use $this `prefixadd_action('wp_head',array(&$this,'load_face'));` and you will need to populate the value of $sex public function load_face($instance) { $sex = $instance['sex']; wp_enqueue_style('style', WP_PLUGIN_URL . '/sample/'.$sex.'.css', null, null, 'screen'); }
stackexchange-wordpress
{ "answer_score": 3, "question_score": 0, "tags": "plugins, widgets, css" }
Core framework/helpers for logging stuff? I'm writing two plugins at the moment which need to (optionally) log stuff...lots of stuff...somewhere. Since i don't like the 'you need to have proper permissions in this and that folder' messages of some plugins, ideally, i'd like to do it in the database. But before i start creating my own db tables (which is also something i don't like for plugins to be doing), i'm wondering if WordPress has anything that could help with suchalike enterprise hidden in the dark deep of its codebase catacombs? Ta.
I created my own plugin and it's now available from in the repository. (Edit: The plugin moved to its new home under the right name, so packaging and auto-update should be fine.)
stackexchange-wordpress
{ "answer_score": 2, "question_score": 4, "tags": "plugins, logging" }
WordPress and bbPress Login conflicts? For some reason, if I log into my WordPress dashboard, I get logged out of my bbPress forum. When I log into my bbPress forum, I get logged out of WordPress. I followed all of the instructions correctly, and the installation told me it validated my information and it's all correct, so why is it not letting me stay logged into both at the same time?
You can achieve so by following this tutorial - < and then keeping the bbPress integration plugin active on WordPress side (it is responsible for generating bbPress admin side cookies when you login from WordPress). So see where you missed out and get it back on track. Let me know if you are stuck or lost.
stackexchange-wordpress
{ "answer_score": 2, "question_score": 1, "tags": "wp admin, login, bbpress" }
Find out if a page has no parent Hay, have a basic menu looking like this Item 1 Item 1.1 Item 1.1.1 Item 1.1.2 Item 1.2 Item 2 Item 2.1 I'm outputting this as a list using WordPresses "wp_list_pages()" function. This is working fine. However on the pages, i am list the subpages. So, when I'm on page "Item 1.1" it says "Other pages" and lists "Item 1.1.1" and "Item 1.1.2". I'm using <?php wp_list_pages( array('child_of'=>get_the_ID(),'title_li'=>'') ); ?> to do this. However, i only want this to output "other pages" on the subpage. I don't want to display the "other pages" on the top level pages (like "Item 1, Item 2"). Is there a way to see if the current page is a top level page?
< If post_parent is zero, you are there.
stackexchange-wordpress
{ "answer_score": 2, "question_score": 1, "tags": "menus, navigation" }
Post edit screen: How to check if meta_box is registered? I got some custom post types where i deregistered the "title" meta box. Now i always get "Auto Draft" as title. To avoid this i'd like to add the name of a taxonomy as the title. But how would i check if the meta box "title" exists or not?
Check the metabox global directly? `$wp_meta_boxes['YOURTYPE']` should hold data on metaboxes for a given type. Had a quick look in `wp-admin/includes/template.php` but i can't see any convenience functions for extracting metabox information from the array so you'll probably need to create your own code to loop over or extract the necessary info from it. Of course make sure you run your code after the `add_meta_boxes` actions(else they'll likely not exist at the point you run your code).
stackexchange-wordpress
{ "answer_score": 1, "question_score": 0, "tags": "metabox" }
How to add logo in Thematic I've done my sharing of hacking themes before, especially to replace the site title with a logo, but for newest thematic theme, I can't figure out where to edit the code to add my logo. I've checked header.php and the style.css but can't figure it out. < Appreciate any help!
The easiest way is to use a css background image for your logo. Go to line 65 of default.css and change #blog-title { font-family:Arial,sans-serif; font-size:34px; font-weight:bold; line-height:40px; } To This: #blog-title { background: url(images/path_to_your_logo.png) no-repeat; display:block; width: 00px; /* enter logo width */ height: 00px; /* enter logo height */ text-indent: -999em; /* replaces blog title with your logo */ }
stackexchange-wordpress
{ "answer_score": 2, "question_score": 0, "tags": "themes" }
Is the built-in updater the "best" way to upgrade WP installations? With the release of WordPress 3.1, I'm about to update my own WP installation. I've had a thought about the different ways one can do the update: by hand (ugh), via Subversion checkout on the server, and using the built-in updater. To this point I've used the SVN route, not sure why, possibly that was from before WP added the auto-update feature. It's a minor hassle though, as I have to log in to the server and run `svn up` to get the new release - admittedly that's not a big deal, but it's an extra step over logging into WP to apply the update. I would imagine that the WP folks have worked hard on the auto update feature and kept it as smooth as possible. With that in mind, should I just not bother with an SVN checkout to run my site, and just use the updater? Or is there any reason why I should keep using the SVN method?
If you're already using the SVN method, then keep using it. Trying to auto-upgrade an SVN site will probably fail due to all the extra .svn directories and such. Auto-upgrade doesn't do anything special or different. It's just replacing the WordPress files with the new ones. SVN will do the same thing.
stackexchange-wordpress
{ "answer_score": 8, "question_score": 2, "tags": "upgrade" }
The new WordPress 3.1 "Admin Menu" isn't appearing on my site or in the Dashboard WordPress 3.1 added the Admin Bar feature, similar to the one used in WordPress.com websites, which appears on both the website and Dashboard for logged in users (if enabled in your User settings). I've updated to WP 3.1 and enabled both settings for the admin bar ("when viewing site" and "in dashboard"), as well as clearing all caches (through W3 Total Cache) and my browser cache. Any ideas on why I'm still not seeing the admin bar? I am using a custom theme, but I don't see how that would affect the Dashboard admin bar.
Do you have <?php wp_footer(); ?> in your footer.php? It should be right at the bottom before the closing tag <
stackexchange-wordpress
{ "answer_score": 1, "question_score": 0, "tags": "upgrade, customization, admin bar" }
hide Wordpress 3.1 admin menu I just updated one of my blogs to the new wordpress 3.1 and i need to hide the admin menu that shows up on top of the pages. How do i disable it ? thanks
this is the simplest way. install showhide-adminbar. then all subscriber won't see the adminbar even they set to show it in viewing site. <
stackexchange-wordpress
{ "answer_score": 1, "question_score": 7, "tags": "admin bar" }
Post belonging to many categories I have a post that belongs to two categories (Drinks, Food). The post appears on category pages under `/category/drinks` and `/category/food` When I click on the post under category archive `/category/drinks` it takes me to a post page that's in `/food/` Is there any way to solve this in a way that the post stays in the same category?
If the template is using the permalink when generating the posts, it retrieves all the categories for a given post and then grabs the first category it gets after sorting them by Id. I see two ways around this: 1. If you want to recreate your categories with the preferred order, then you should be set. However, if you have a lot of posts in the system, this would be a hassle. 2. Modify the template to generate your own links. When retrieving the category for the link, if multiple exist, you'll want to use the one that matches the category of the URL you are currently viewing the page in. You can use the source code of the get_permalink method as a way to get started.
stackexchange-wordpress
{ "answer_score": 2, "question_score": 0, "tags": "categories, posts" }
All pages load the home page if pretty permalinks are used I'm trying to help a buddy out -- his site, on a fresh WordPress install, is behaving oddly. With default permalinks set, everything works, but with pretty permalinks set up, all of the pages on the navigation bar load as the home page. If you hover over them, the links are still in the original `?page_id=x` form.... Any ideas why this is happening? Hosting is with Go Daddy and they are singularly unhelpful. Many thanks. Martin
In my experience, GoDaddy has been notorious for problems while setting up pretty permalinks for the first time. Are you working with a Windows or Linux GoDaddy server? The following sites may be of some help, but from what I've read you may need to have somebody at GoDaddy make changes for you if you do not have sufficient privileges. * < * < * <
stackexchange-wordpress
{ "answer_score": 1, "question_score": 0, "tags": "permalinks, redirect" }
Add Custom Filter to Admin User list What is the correct way to add a custom filter (a dropdown box in this case) to the admin user list (wp-admin/users.php)? There are no filters or actions that I see to hook into that would allow me to output a select box. I know I can inject it via javascript, but I'm hoping there's a way to do it on the PHP side. I am planning on using the results of that filter int as outlined here: How to search all user meta from users.php in the admin
Actually found a potential way (with WP3.1), but it's a bit more involved than using filters: Since WP3.1 now uses the `WP_List_Class` to generate the admin pages, you can create your own `My_User_List_Table` class, inheriting from `WP_Users_List_Table` and in that class override the `extra_tablenav()` method. In your own method you duplicate the code from `WP_Users_List_Table::extra_tablenav()` and add your own stuff. Then you create a duplicate of `wp-admin/users.php`, modify it to use your class instead and modify the users menu entry in the admin navigation to call your duplicate instead of `wp-admin/users.php`. I'm not sure if WP3.1 now comes with easier methods to do that then the hacky solutions necessary for WP3.0. Unfortunately, all this new WP_List_Class stuff comes without good action or filter hooks, it would have been so easy had they added an `apply_filters()` call to `_get_list_table()`. Grmpf.
stackexchange-wordpress
{ "answer_score": 0, "question_score": 1, "tags": "users, filters" }
Fatal error: Call to undefined function term_exists() In Which version of WordPress did term_exists() first appear?
Its since wordpress 3.0 <
stackexchange-wordpress
{ "answer_score": 0, "question_score": 0, "tags": "fatal error" }
Notify Author of the post if admin deletes his post and perform some function i am working on a theme in which points are added in user meta when he does a post... it works fine but the problem is when a post is deleted by the admin then the point should be reduced and the author should get intimation . The main problem is getting the author id of the post and doing function after the post is deleted.... the code i am trying is function deletePointFromUser($post_ID) { global $wpdb; $authorid = $wpdb->get_var('SELECT post_author FROM wp_posts WHERE post_id = $post_ID'); $currentPointNumber = get_usermeta($authorid, 'points'); //Delete 1 to the current Point Score $newPointNumber = $currentPointNumber - 1; update_usermeta( $authorid, 'points', $newPointNumber); } add_action('deleted_post', 'deletePointFromUser');
Firstly, it's better to user WP functions than write your own SQL. Even though it might be a bit more expensive: $post = get_post($post_ID); $authorid = $post->post_author; Secondly, it's not `get_usermeta()`, but `get_user_meta()` and the complete call should include `true` as the third parameter: $currentPointNumber = get_user_meta($authorid, 'points', true); And then it's `update_user_meta()`, again, and you don't need to initialize a new variable, just do: update_user_meta($authorid, 'points', $currentPointNumber-1);
stackexchange-wordpress
{ "answer_score": 0, "question_score": 0, "tags": "posts, author, functions" }
query_posts and only show results if a custom field is not empty How do I `query_posts` and only show results if a custom field is not empty or has a value. I want to put in a URL in a custom field and only show these pages if there is a URL? current code but I can't figure out the rest: $args = array( 'posts_per_page' => '10', 'post_type' => 'programmes', 'orderby' => 'meta_value_num', 'meta_key' => 'popularityfig', 'order' => 'DESC', );
Try this code: $args = array( 'posts_per_page' => '10', 'post_type' => 'programmes', 'meta_key' => 'popularityfig', 'meta_value' => '', 'meta_compare' => '!=', 'order' => 'DESC' ); There're 2 arguments you might want to note in the code: `meta_value` and `meta_compare`. Using `meta_compare` with operator `!=` will exclude posts with empty meta value.
stackexchange-wordpress
{ "answer_score": 6, "question_score": 3, "tags": "custom field, query posts" }
Load scripts based on post type Is there a nice way to load a js file based on the post type being viewed? I have a supplier which has a map on it but I only want the load the js when a single one is being viewed. I load the script in my functions.php file.
If you hook onto a later action such as `template_redirect`, you should be able to check the query vars to determine if your specific post type is being viewed. add_action( 'template_redirect', 'example_callback' ); function example_callback() { if( is_single() && get_query_var('your-posttype') ) wp_enqueue_script( .. your args .. ); } Or alternatively like this... add_action( 'template_redirect', 'example_callback' ); function example_callback() { if( is_single() && get_query_var('post_type') && 'your-type' == get_query_var('post_type') ) wp_enqueue_script( .. your args .. ); } Hope that helps.
stackexchange-wordpress
{ "answer_score": 0, "question_score": 1, "tags": "custom post types, functions" }
Which directory in my plugin repo does Wordpress Plugin Directory package? I am a little confused about that. If I want tags/1.2.3 to be available for download instead of the one in trunk, how do I do that? In the FAQ, it says that I should change stable tag to 1.2.3 in trunk/readme.txt. I did that but WPD is still showing the old version in the trunk. I thought it would automatically package tags/1.2.3 after changing stable tag in trunk/readme.txt. Or I am doing it wrong?
you have to commit the changes to the /trunk directory yourself, changing the version number in the /trunk/readme.txt is not going to do this on its own. ## Update Whenever i update a version say from 1.0.0 to 2.0.0 i first create a directory in /tags and name it just like the last version 1.0.0 the i copy everything from /trunk to it so if someone wants an older version he can get it. the i just commit any changes of the new version to /trunk so basically trunk holds only the latest version (no need to create a new directory in trunk.)
stackexchange-wordpress
{ "answer_score": 2, "question_score": 1, "tags": "plugin development, repository" }
custom uploader in the admin area I am building a wordpress plugin that needs to allow the admin to upload CSS documents, and attach thumbnails. I want to know if there are any methods within wordpress that would be useful in assisting me in building an admin page that allows upload and deletion of css documents and images.
You can use the file uploader that come with Wordpress, using this guide to insert it in your meta-box: < You can create some custom fields and use it to upload thumbnails or CSS to your server.
stackexchange-wordpress
{ "answer_score": 2, "question_score": 0, "tags": "plugins, plugin development, uploads" }
Injecting JavaScript into a Post with WP3.x I have a client who is trying to inject some JS directly into a post using the web interface. The script is stripped out on the live site. I am unable to replicate this behavior on a local installation. The JS is added as expected. The main difference between my installation and the client's is that my installation is a fresh WP3 installation, whereas the client's is WP3 upgraded from WP2. Is this a configuration option or a legacy issue? Is there some other reason why this might be happening? Rich
At least in my installation, Admin and Editors are able to inject script into their posts. Authors are not able to. Author content is parsed using a plugin called KSES, which strips out disallowed HTML. The KSES plugin can be overridden or extended. Which I have done by hacking a community plugin called Extend KSES (< Not too keen on the idea of allowing script injection, so the client should be made aware of the dangers. Rich
stackexchange-wordpress
{ "answer_score": 1, "question_score": 1, "tags": "posts, javascript" }
How do I add (css) class to a custom link to make it current_page_item As a custom menu item wp doesn't add the class current_page_item All other links it does? <ul class="nav" id="menu-mainmenu"><li class="menu-item menu-item-type-custom menu-item-home menu-item-21152" id="menu-item-21152"><a href=" <li class="menu-item menu-item-type-post_type current-menu-item page_item page-item-21154 current_page_item menu-item-21156" id="menu-item-21156"><a href=" TV Guide</a></li> <li class="menu-item menu-item-type-post_type menu-item-21153" id="menu-item-21153"><a href=" </ul> I would like to show it as an active link
Can't you just target .current-menu-item along with .current_page_item?
stackexchange-wordpress
{ "answer_score": 0, "question_score": 1, "tags": "menus, css" }
Upgrade to 3.1 - Fatal error: Call to undefined function wp_cache_get() I just upgraded to 3.1, and after refreshing I get the following error: > **Fatal error** : Call to undefined function wp_cache_get() in **/public_html/blog/wp-includes/functions.php** on line **336** A quick google search led me to this post on WordPress support forum, however I tried disabling all plugins as suggested, and I'm using TwentyTen as my only theme. I also set `define('WP_CACHE', false)` in the config, didn't help... Any ideas before I attempt to roll everything back? Any ideas?
The problem was linked to the WP-Hive plugin, and it was (partially) resolved, when the plugin's author had fixed the problem.
stackexchange-wordpress
{ "answer_score": 0, "question_score": 0, "tags": "upgrade, fatal error" }
How to view plugin ratings? So I recently submitted my first plugin, and have since got a 1-star rating. Is there a place to review ratings and comments on my plugin?
There's no way to see the individual ratings, but you can see the total number of ratings and what they average out to. In the bottom left of your plugin page (in the repository) there is a section for "What others are saying", and it will display any posts from the WordPress forum talking about your plugin.
stackexchange-wordpress
{ "answer_score": 0, "question_score": 0, "tags": "plugin development" }
What is the best way to avoid spammers registering to my blog? I would like to be able to easily control who registers to my blog because recently I had tons of spam users registering. I came accross the plugin Stop Spammer Registrations, but i'm not sure it is reliable enough and I would also like to have a full log of every user who was rejected by the plugin/service. Is there any good alternative? Thanks
I am a HUGE fan of the Bad Behavior plugin: > Bad Behavior complements other link spam solutions by acting as a gatekeeper, preventing spammers from ever delivering their junk, and in many cases, from ever reading your site in the first place. This keeps your site's load down, makes your site logs cleaner, and can help prevent denial of service conditions caused by spammers. We started using Bad Behavior on our tech blog and noticed an immediate reduction of spam, as shown below. !Bad Behavior activated on January 14 Here is our full article on Bad Behavior: <
stackexchange-wordpress
{ "answer_score": 4, "question_score": 2, "tags": "users, user registration, spam" }
Custom Post Type “Event”: chronological list of recurring events i'm looking for a good and easy way to have a custom post type "event" that can have multiple dates. (I have tested about 20 plugins). I think i have no problem building a metabox allowing the user to duplicate the field group "date and time" multiple times. But **how would a query look like that creates a chronological list of events from the meta data?** (The project is a playing schedule for a theatre. Productions play on several dates.) Thank you!
Here's a plan: 1. Store the dates as individual custom fields with the same meta_key (ex: start_date) 2. JOIN the wp_posts table with the wp_postmeta table, _without_ a GROUP BY (to allow the same event to appear more than once) 3. ORDER BY start_date The full query would look like this: SELECT wp_posts.*, meta_value AS start_date FROM wp_posts INNER JOIN wp_postmeta ON (ID = post_ID) WHERE post_type = 'event' AND post_status = 'publish' AND meta_key = 'start_date' ORDER BY start_date PS: This requires you store the date in YYYY-MM-DD format, which you should do anyway, for compatibility with mysql2date() etc.
stackexchange-wordpress
{ "answer_score": 4, "question_score": 3, "tags": "query posts, wp query, events, custom post types" }
Fallback_cb is messing around with containers I have the following code in place for a custom menu area: $wp_nav_header = array( 'container' => '', 'menu_class' => 'sf-menu', 'fallback_cb' => 'wp_page_menu', 'theme_location' => 'primaryheader', 'depth' => 0,); wp_nav_menu( $wp_nav_header); It works fine when there **is** a menu in place, and outputs: <div id="nav-main"> <div class="sf-menu"> <ul><li... However, when it's **falling back** , it outputs: <div id="nav-main"> <ul id="menu-default" class="sf-menu"><li... Needless to say, this is throwing off my design as it's adding these classes (for which I have no styling) & stripping suckerfish , but makes my nav disappear (despite showing up in source). Anybody encounter this before? Thank you!
basically you are missing the container div so if you change your fallback to a custom function you can pass parameters to wp_page_menu that give you a bit of control over it and add your missing div try: $wp_nav_header = array( 'container' => '', 'menu_class' => 'sf-menu', 'fallback_cb' => 'my_fallback_menu', 'theme_location' => 'primaryheader', 'depth' => 0,); wp_nav_menu( $wp_nav_header); function my_fallback_menu(){ echo '<div class="sf-menu">'; $args = array( 'sort_column' => 'menu_order, post_title', 'menu_class' => '', 'include' => '', 'exclude' => '', 'echo' => true, 'show_home' => false, 'link_before' => '', 'link_after' => '' ); wp_page_menu($args); echo '</div>'; } Hope this helps
stackexchange-wordpress
{ "answer_score": 1, "question_score": 1, "tags": "navigation" }
Wordpress + bbPress registration user-unfriendly? I'm testing Wordpress + bbPress (both latest versions): < When I press Register it sends me to Wordpress' backend login page (I'm no longer in the site). If I click the Registration User page, and fill my username and email it sends me to Worpdpress' backend login page again and it says: `ERROR: The password field is empty.` Is there a way of letting the user just sign up while being on the site?
this Article < provides a great tutorial on how to create you own frontend register/login/restore password forms. or if you are looking for a plugin then i've used these before and can recommend them: * Ajax Login/Register * Login With Ajax * Theme My Login
stackexchange-wordpress
{ "answer_score": 2, "question_score": 0, "tags": "user registration" }
How long does it take to update a plugin page from the readme.txt? So I updated my plugin this morning to a new version and made some changes to the readme.txt (basic FAQ, changelog info). But the plugin site isn't reflecting the changes. I updated the 'Stable tag' to version 0.0.2, then copied the trunk file to the tags/0.0.2 directory. The svn page shows the correct readme.txt . Am I missing a step?
It normally takes at most 15 minutes before the Extend page is refreshed, so just give it a little while.
stackexchange-wordpress
{ "answer_score": 3, "question_score": 4, "tags": "plugin development" }
How to add a filter to all widget output Is there one last filter that is ran over the widgets before they are sent out to the browser? I would like to add a filter that adds `rel="nofollow"` to all links in all widgets. For instance, I can add a filter to the text widget: add_filter('widget_text', 'xrvel_nfp_modify_nofollow'); But I don't want to hunt down every single hook for every widget. (Also, the RSS widget doesn't even HAVE a filter. Trac ticket submitted)
There is another thread on here that discusses a workaround. Well... the familiar php workaround when a function does not provide a "get to variable" output actually... use ob_start: < to just capture the output and manipulate it before sending it on its way. Leads on stackoverflow: <
stackexchange-wordpress
{ "answer_score": 2, "question_score": 4, "tags": "widgets, nofollow, filters" }
WordPress 3.1 and Disqus throws Warning: number_format() error in Posts List After upgrading to WordPress 3.1, the comment count for each post in the Posts list now shows the PHP error `Warning: number_format() expects parameter 1 to be double, string given in /wp-includes/functions.php on line 155`. This problem is definitely related to the Disqus comments plugin, which I suspect is manipulating the comments count. I see how I could fix this error by editing the WP core file /wp-admin/includes/class-wp-list-table.php and neutering the "get_comments_number()" function, but I'd rather find a solution for whatever is being manipulated in disqus.php. Any thoughts?
After quite a bit digging, I managed to fix it without modifying any WP core files. Essentially, Disqus usurps the comment count from WordPress and wraps it in its own with unique identifiers. Since WP is calling its own comment count when viewing the Posts lists, it's getting a string value filled with HTML rather than a plain double value with the comment count. This breaks its internal function `number_format_i18n()`. The fix is to edit disqus.php and have the function `function dsq_comments_number($count)` simply return `$count`. Just delete the extra HTML. Hopefully Disqus will roll a fix out for this soon, I've had problems with how they handle comment counts in the past. Edit: I just published a full write-up of the fix if you need more explanation: <
stackexchange-wordpress
{ "answer_score": 2, "question_score": 0, "tags": "plugins, customization, disqus" }
meta query not showing any results? I'm trying to show result for a custom field that is not empty on a custom post type but getting no results? <?php if (have_posts()) : $args = array( 'post_type' => 'programmes', 'meta_query' => array( 'key' => 'linktovideocatchup', 'value' => '', 'compare' => 'NOT LIKE'), //'caller_get_posts' => 1, ); ?> <?php query_posts( $args ); ?> <?php while (have_posts()) : the_post(); ?> `enter code here`
you're missing an array within the meta_query element: $args = array( 'post_type' => 'programmes', 'meta_query' => array( array( 'key' => 'linktovideocatchup', 'value' => '', 'compare' => 'NOT LIKE' ) ) ); (this is required to allow for querying of multiple meta fields.) you also had an extraneous comma after the meta_query array element which can cause problems. i think you should also be able to use the operator '<>' rather than 'NOT LIKE', i believe it's more efficient. there's a good write-up on the meta_query functionality here: <
stackexchange-wordpress
{ "answer_score": 7, "question_score": 1, "tags": "custom field, query posts" }
How to display a page? I'm creating new pages under Pages > Add new. And creating my own page.php file from the ground up, what's the best way of displaying pages contents? I guess not get_template_part( 'loop'), since there will be no posts, just static pages?
Actually, pages also use the loop to display contents, but there will only be one "post" to loop through. Pages are treated almost exactly the same way as single posts as far as reading and rendering content goes. If you're creating your own `page.php` file for a theme, take a look first at how Twenty Ten is put together. It's always easier to learn from others than to reinvent the wheel.
stackexchange-wordpress
{ "answer_score": 0, "question_score": 0, "tags": "pages" }