question stringlengths 0 34.8k | answer stringlengths 0 28.3k | title stringlengths 7 150 | forum_tag stringclasses 12
values |
|---|---|---|---|
Goal: I like to use a subtitle in the navigation bar. The most logic location, in my opinion, would be Appearance > Menu and add a field below navigation label called subtitle. So the end user can easily add and change a subtitle there for the different menu items. Looking at <code> wp-admin/includes/nav-menu.php </cod... | have you ticked the 'Description' box under 'Show advanced menu properties' in the 'screen options' tab in the appearance -> menus page? and have a look at this related post: http://www.kriesi.at/archives/improve-your-wordpress-navigation-menu-output | Add an extra field to the navigation menu box? | wordpress |
I'm looking to determine how many images are attached to a post, specifically if there is only one. Basically if there are multiple images I want to display my slideshow script, if there is only one I want to display that image, and not load the slideshow. I saw this on a similar post which determines if any images are... | That code should get the attachments as array which you should be able to use <code> count() </code> on to determine the total number of images. Example: <code> if ( $attachments ) { if ( 1 == count( $attachments ) ) { // handle single image } else { // handle multiple images } } </code> | Determine if only one image attached to a post/page | wordpress |
I am sorry if this is not clear, but I am using translated wordpress so I am translating some names back. I have pages in menu and when I click on some item it goes to that page. But I need f. e. page Item which has subpages SubItem1 and SubItem2. So in menu there would be shown Item, then I click on Item it does not l... | I think you're asking how to make a menu with drop downs clickable rather than hoverable, so here's a very simple example of what I think you want: http://jsfiddle.net/pk5Bx/ HTML <code> <div id="navigation"> <ul> <li class="current_page_parent"><a href="#">Top level 1</a> <ul> <l... | Hide and show menu subpages | wordpress |
I'm creating a custom log in page on a wordpress install and would like to remove the "Lost your password?" link from the "ERROR: Invalid username. Lost your password?" message that comes up if the user inserts the wrong password. I've been looking in the wp-login.php but must be missing something, can someone point me... | I've found the generated text in the <code> wp-includes\user.php </code> file so removed it there and done what I was looking for. | Custom Log In Screen - Disable password recovery | wordpress |
From one domain (foo.com), select export as WXR and import to (bar.com), also I manually uploaded wp-contents to the new location. Everything is working, except the the images in the blog post still using the old domain. How to solve it? I have tried to upload into wp.com and they can auto update the images' location, ... | When you import the WXR file to the WordPress install on the new domain, be sure to click the " Download attachments " checkbox that you are presented during the upload process. | Export WordPress from one domain to another domain | wordpress |
I asked this elsewhere but I'm not getting very far with the answers, so thought I'd try here as it's specific to Wordpress. I have this shortcode: <code> function reytab($atts, $content = null) { extract(shortcode_atts(array('title' => '#'), $atts)); return '<div class="tab">'. '<h2 class="reytab">'. $t... | Your code is fine, the issue is in your shortcode. If you look around line 200 of <code> /wp-includes/shortcodes.php </code> , you can see that only <code> / </code> is supported for the close tag, not <code> \ </code> . If you change <code> [\reytab] </code> to <code> [/reytab] </code> it will work! | Shortcode not showing $content in correct place | wordpress |
I'm curious to find out the process/philosophy behind removing deprecated functions from core. The Codex says this: These functions below have been deprecated. That means they have been replaced by new functions or are no longer supported, and may be removed from future versions. Since 'may be removed' is a bit ominous... | To the best of my knowledge, and having heard Nacin say it explicitly, no deprecated function has ever been removed from WordPress to date. No guarantees for the future, but it's never happened yet. Still, avoid deprecated functions. | How long does a deprecated function live in core? | wordpress |
On a single server, we have a number of single-site WordPress installations (which have been around for many years and have worked fine 'til now) and one newer multi-site installation that has been working fine for a few months. They are all connected to separate databases on a separate MySQL server in the same data ce... | Turns out this problem was due to something wrong with SSL/HTTPS. Once I turned off 'FORCE_SSL_ADMIN' on our WP installations and tried loading the dashboards via just HTTP, they loaded up just fine. So the problem is not with WordPress but with our SSL configuration. This makes perfect sense in hindsight: the reason o... | WordPress Dashboards: slowness and timeouts | wordpress |
I may be missing something really simple here, but I am trying to style the background to my disqus comments to a white color (like the blog post content area) but for some reason the background of the site is still overriding my styling. I have no idea why. Here is my styles.css...Does any one see what's going on? (He... | Not really a WPSE question but I was bored. For starters there is no <code> .dsq-full-comment </code> class, that I could find anyway, on the page you linked to. However if you wanted the entire comments block to look all pretty and white like the rest of you site put this on in your themes <code> custom.css </code> fi... | Can't seem to get this CSS to work...any ideas why? | wordpress |
When new users log into our site they have to organize a number of screen options in order to begin creating custom fields and editing the site. I would like to force a specific order in which these are displayed. Is there a way to force the sort on the edit screen? | The meta box order gets stored in the user meta and is basically an array of "priority" and meta box id. I didn't check if this meta key gets generated upon user setup or when the first manual reordering occurs. To see how this array looks, and how the native WP metaboxes IDs on a page (post, cpt) are, you can var_dump... | Sorting editor screen items | wordpress |
I have set some custom field 'artist' and 'song-name' displaying like: <code> Artist: <user input> Song Name: <user input> </code> My question, how do you make the on artist and song name into a clickable link? Such that when the artist name is clicked for example, it will bring up the page with all posts o... | This is better accomplished by registering a new taxonomy. You get all of the advantages of categories and tags without the hassle of custom fields. Codex: register_taxonomy Tutorial: How to Create Custom Taxonomies in WordPress 3 | Make Custom Field Into A Link On The Front End? | wordpress |
My blog has simple posts including a youtube videos. For example: <code> <iframe width="460" height="342" src="http://www.youtube.com/embed/PkxteedBq9g?rel=0" frameborder="0" allowfullscreen></iframe> </code> and index.php will echo content ( ) I want that the permanent link of this post ( single.php ) disp... | Your best bet is to use custom fields for the YouTube video URL and then use <code> get_post_meta(); </code> to pull out the URL, then in your template files (index.php, single.php) set up the embed code on each template. | Best way to modify content from index.php to single.php? | wordpress |
I am building a custom (child) theme and I want to style the first post of my loop in a different way than the others (bigger image, different position of some stuff). Which is the best way of doing it? My "problem" is that my theme has support for different post types and the style would vary depending on the type of ... | Ok, for now the best solution I've found is passing a global variable in my functions.php, as so: <code> while (have_posts()) { the_post(); if ($post_count == 0 || is_sticky()) { global $highlight; $highlight = true; }else{ $highlight = false; } get_template_part('content', get_post_format()); $post_count++; } </code> ... | Best way to style first post differently? | wordpress |
I am trying to extend the twentyeleven theme's sidebar template. My custom template (its incomplete) is as follows: <code> <?php /** * Template Name: Quote Request * Description: A Page Template that is a free quote request form * * @package WordPress * @subpackage Twenty_Eleven (Custom) * @since Twenty Eleven 1.c *... | you need to correct the automatically added body_class <code> .singular </code> to get the layout; for instance use this in functions.php of your child theme (which you should have created to work from): <code> add_filter('body_class', 'pagetemplate_adjust_body_class', 20, 2); function pagetemplate_adjust_body_class($w... | Trouble in creating a custom template on twentyeleven theme | wordpress |
I have a wordpress query for a custom post type, but I want to filter the results depending on the value of a custom meta. <code> <?php $my_query = new WP_Query('post_type=prizes&showposts=3&orderby=rand'); while ($my_query->have_posts()) : $my_query->the_post(); $do_not_duplicate = $post->ID; $my_m... | This is super easy to do with <code> meta_query </code> s: <code> $args = array( //basics 'post_type' => 'prizes', // from question 'post_status' => 'publish', // you didn't have this, but it's good practice 'posts_per_page' => 3, // I don't know where you got 'showposts', but that's WAY old //order 'orderby' ... | Query posts and filter at query time by value of custom meta | wordpress |
I've set up this query in Wordpress to find all associated news for a company: <code> <h2 class="heading">Related News</h2> <?php $link = get_the_title(); ?> <?php $portfolioloop = new WP_Query( array( 'post_type' => 'news' ) ); ?> <?php while ( $portfolioloop->have_posts() ) : $portfol... | I added <code> $post_e </code> to this line and it worked: <code> <?php $company_e = get_the_title($post_e); ?> </code> Thanks for both your help, it triggered some ideas. | Second wp_query doesn't appear to be working | wordpress |
I have a few custom fields for a taxonomy "Author". The term title is the Author's last name, and one of the custom fields is his first_name. Now I need, in a post loop, to list all "Authors" of that post by their full name. How can I do this? I'm using Ultimate CMS plugin to manage taxonomy custom fields. Just to be c... | So I decided to go another way. I now have the Author's Full Name as terms in the taxonomy. For the index, for which I need to separate Last Name and First Name, I used PHP string functions. <code> <?php $taxonomy = 'autores'; $queried_term = get_query_var($taxonomy); $terms = get_terms($taxonomy, 'slug='.$queried_t... | List taxonomy term "Last Name" + "First Name" (taxonomy custom field) in a post loop | wordpress |
I have a featured posts slider on my site's front page. It displays <code> n </code> posts (5 right now) from the category <code> featured </code> . If I have 5 posts in that category, and publish a 6th, the oldest of the 6 doesn't show up in the slider or below in the list of all recent posts. My solution right now is... | First of all in your image you can see that WordPress lets you filter the posts by category, just bellow the what you have added to the image, But if you want to know how you can add your own link to the filter you can use the <code> views_edit-post </code> filter hook ex: <code> add_action('pre_get_posts', 'query_add_... | Add a special filter link to All Posts in admin | wordpress |
First of all I did a manual upgrade of the wordpress site. I did everything by the book. I disabled all plugins, did all the backups. I upgraded to the new version, everything went fine. Only that I lost all content. I switched from my custom themes to default one (Twenty Eleven 1.3) still my content seems to be gone. ... | This is just a guess, mind you, but it's still worth a shot. First, turn on debug mode and see if there's any glaring errors when trying to view your content. If not (and I'm thinking there won't be, but I would feel quite silly if there were errors pointing to the issue), then roll everything back to 2.8 (database and... | Upgraded from 2.8.x to 3.3.1 and lost content | wordpress |
As I'm often involved with people who don't know anything about WordPress, a CMS or even the internet :) I try to hide things irrelevant (for them) as much as possible. Normally this would involve removing a meta box here and there, but I have to admit, I'm sort of stuck on the WP menu system. Would anyone know perhaps... | As mentioned in a previous comment, I went for a jQuery solution: <code> add_action( 'admin_footer-nav-menus.php', 'cor_advanced_menu_properties' ); /** * Hides the `nav-menus.php` 'advanced menu properties' */ function cor_advanced_menu_properties() { ?> <script> jQuery("h5:contains('Show advanced menu proper... | Removing the advanced menu properties | wordpress |
Let me explain — Until now, I have been using NextGen Gallery, and since I have a redesigned website that has image.php template (gallery attachments page), I would like to use Wordpress' built-in gallery feature instead. Here's the problem — I can't forever continue to monitor if NextGen Gallery plugin is working as i... | Konstantin Kovshenin from Automattic built a small WP plugin hosted here at GitHUB , which does pretty much exactly what you are asking for. It does not seem to solve the whole migration as it works only for <code> [nggallery] </code> shortcodes, but anyone can fork it and add some more lines to solve the rest, right? | Is it possible to import NextGen Galleries into Wordpress Galleries and convert embeds in all posts? | wordpress |
I'm trying to compare the permalink with a url and then output stuff depending if they match. At the moment I have the code below. On the page it's visibly showing that the permalink and the url (i.e $company) match yet it's outputting "don't show news articles". Where am I going wrong? <code> <p>permalink of cur... | I think my brain nearly exploded with this, solved the problem using the relationship field and lot's of loops: <code> <h2>Latest News</h2> <?php $link = get_the_title(); ?> <?php $portfolioloop = new WP_Query( array( 'post_type' => 'news' ) ); ?> <?php while ( $portfolioloop->have_post... | Comparing permalink to url | wordpress |
I have enabled the excerpt feature for pages in my wordpress theme - <code> add_action( 'init', 'my_add_excerpts_to_pages' ); function my_add_excerpts_to_pages() { add_post_type_support( 'page', 'excerpt' ); } </code> This has enabled the excerpt box when adding or updating pages through the admin area, which is what I... | Because I am very particular about how to do things in Wordpress when it comes to looping, I couldn't help but want to post a better way to do the above loop in your question as seeing the way you've done it looks like a lot of unnecessary work for yourself. You already answered your own question but for the sake of be... | the_excerpt() not showing manual excerpt for Pages | wordpress |
Okay, I quite often see people talk about child themes and the reasons for using them instead of modifying the existing theme, but they all seem to center around the idea that if the parent theme is updated all changes will be lost. When I've created sites in the past, I have always made a duplicate of the starting the... | Child Themes are useful for users who mainly want to make style changes to their Theme, but don't want - or know how - to maintain the underlying code. Grokking PHP/WordPress Theme Development is an entirely different thing than grokking CSS. Child Themes are also useful for users who want to implement minor functional... | Child Theme vs Duplicate Theme Renamed | wordpress |
I have a wordpress site hosted on a godaddy server running apache. My experience is on windows iss so this might be an easy question but I can't figure it out. I want to allow urls at my site like: http://my.site.com/biz/Jordan 's_place/jordan/ The problem is two fold. 1) If I enter: http://my.site.com/biz/Jordan 's_pl... | Wordpress will strip off special characters, since they can cause issues when writing to the database. It's best practice to avoid using special (reserved) characters in URLs, as they can and will break when passing them around. Case in point, see your own post and the cutting off of the URL after the '. | Allow single quote in URLs | wordpress |
I'm currently designing a musician's wordpress theme, and am looking to create a user-controlled dynamic gig list. It doesn't have to have a link to any event pages, just a simple "where, when, with who" kind of thing. I've done this before using PHP, but am wondering what the best way to do it IN WORDPRESS would be. I... | Create a custom post type named Gig and WordPress will take care of the UI creation, then all that is left for you is to add a metabox with the fields you want(date, venue, about). here is a simple step by step: First register your gig post type: <code> //register your custom post type gig add_action( 'init', 'register... | Best way to create list of gigs for Wordpress theme? | wordpress |
Been hitting my head against a wall for a couple weeks... I'm working on modifying a geotagging Wordpress plugin called Thesography. I have notified the developer of my past enhancements, and they are OK with it because this plugin is licensed under the terms of the GNU General Public License. Currently the plugin will... | Get all Images: <code> $all_images = get_posts( array( 'post_type' => 'attachment' ,'numberposts' => -1 ) ); foreach ( $all_images as $img ) echo $img; </code> Some notes: You can use <code> extract </code> to make your code shorter: <code> extract( $image['image_meta'], EXTR_SKIP ); echo $latitude; </code> Use Y... | How to extract specific image meta for all images? | wordpress |
I'm using Settings API and I can't get checkboxes to work, if they're set to "false" they're not even being $_POST and that's the point. stackexchange-url ("Stephen Harris & Chip Bennett explained it"), but I believe their way is not simple enough (especially for me, not PHP-guy at all). Do I REALLY need a few cust... | If the setting in question is <code> $setting </code> , and is a checkbox type, you validate it like so: <code> <?php $valid_input[$setting] = ( isset( $input[$setting] ) && true == $input[$setting] ? true : false ); ?> </code> In this case, <code> $input </code> is the form data passed to the validation ... | Settings API - easiest way of validating checkboxes? | wordpress |
Recently, I imported all my post from Blogger, so all the images showing in the post currently reside on Blogger's server. I want to import/put all those images to my server and automatically change each link for each image. Since there are so many images and so many post I can not go one by one individually. Please gu... | What Chip said; the native importer tool (look in Tools > Import) should have imported everything. But if it didn't, and you already have the rest of the content, you can run this plugin to bring over all your images: http://wordpress.org/extend/plugins/cache-images/ Best of luck! | Host Images from Link | wordpress |
I'm trying to insert a shortcode as the last item in a menu but it results in creating the <code> <li> </code> but then throwing the shortcode output elsewhere, outside of the list. It also removes the closing <code> <li> </code> for that menu item? In functions.php (as per Jared's answer below).. <code> &l... | The problem is the fact that you are trying to echo something into a string, <code> echo </code> should only be used to output something, so simply change the following line: <code> $items .= '<li class="myclass">' . echo do_shortcode('[shopping_cart]') . '</li>'; </code> To this: <code> $items .= '<li c... | Inserting a shortcode into a genesis menu? | wordpress |
A friend of mine just noticed that their site wasn't displaying pages that had a lot of content. For some reason they are just blank, and if he removes some content from the page it will display again. The 10,000 character mark seems to be the threshold - anything above and it goes blank. I played with his templates an... | I ran into this problem a year or so ago, and found a fix here . Open PHP.INI in a text editor of your choice (normally you can find php.ini in your php install dir) Change the recursion limit to 200x normal, that is, set: <code> pcre.recursion_limit=20000000 </code> Change the backtrack limit to 100x normal, that is, ... | Content over 10,000 characters won't display with the_content() | wordpress |
I'd like to post my Instagram photos to my WordPress blog. I cannot use one of the many existing Instagram plugins, though, because those plugins simply post the images on my blog but they are still hosted by Instagram. I'd like this to be a batch process that will actually upload the Instagram photo to my WordPress me... | You'll probably have to do your own integration, but here's how I would approach it: Grab an Instagram PHP wrapper: http://www.mauriciocuenca.com/blog/2011/02/instagram-api-implementation-in-php/ OR http://instaphp.com OR https://github.com/cosenary/Instagram-PHP-API Authenticate via an admin option page Iterate throug... | Posting Instagram Photos Automatically | wordpress |
I have the following code: <code> if (themedy_get_option('product_gallery')) { add_action('genesis_post_content', 'themedy_product_images', 1); } function themedy_product_images() { ?> <?php global $post; $images = get_children( array( 'post_parent' => $post->ID, 'post_type' => 'attachment', 'post_mime_t... | Here are the functions you need to be aware of: http://codex.wordpress.org/Function_Reference/get_post_thumbnail_id http://codex.wordpress.org/Function_Reference/wp_get_attachment_url http://codex.wordpress.org/Function_Reference/wp_get_attachment_image_src http://codex.wordpress.org/Function_Reference/wp_get_attachmen... | Displaying a featured image (only img url) as the img src? | wordpress |
Is there a way to place multiple image galleries in a single post? Please note that: I would only like to use Wordpress' built-in gallery function, and not something else, like NextGen gallery. I know that I can group images in a post using <code> [gallery include="23,39,45"] </code> or <code> [gallery exclude="21,32,4... | No, because galleries are defined as being all the images attached to a single Post. Therefore one Post cannot have multiple galleries because that goes against the definition of what a "gallery" is. Your method #3 will be as close as you can get, however you don't have to use Pages specifically. You can use Posts to s... | How To Put Multiple Image Galleries In A Single Post? | wordpress |
Every time I use <code> the_post(); </code> in my theme code, the following is echo'ed into my pages: <code> <style type="text/css"> <!-- .formTitle { font-size:20px; font-weight:bold; margin-bottom:10px; } .formDescription { font-size:16px; margin-bottom:15px; } .formElement { margin-bottom:15px; } .formEleme... | You can view the actions and filters being used in your plugins and themes. I'm assuming something is hooked into <code> the_post </code> action somewhere. Dumping the following globals give you a peek behind the curtain here. <code> global $wp_actions, $wp_filters; </code> Once you identify the source, you either queu... | the_post(); prints out style text into my HTML? | wordpress |
My main problem is around the title. In my index.php, I have specified a title tag and inserted the following: <code> <?php wp_title(); ?> | <?php bloginfo( 'name' ); ?> </code> My problem is the it is only printing the blog "name" - wp_title() prints nothing i.e. This is what is being printed from the abov... | The title is empty at the front page in WordPress. Yes, that sucks. Just put the separator into <code> wp_title() </code> : <code> <title><?php // separator, print immediately, separator position wp_title( '·', TRUE, 'right' ); bloginfo( 'name' ); ?></title> </code> This prints out just the blog name ... | Empty title on front page/Home | wordpress |
is it possible to create an alphabet pagination? as well as alphabet order of a query post??? I can't a solution on this based on the regular queries. I would appreciate any help, thanks in advanced. UPDATED* * * Well since apparently this hard to understand, I will explain myself better. I'm looking for a way to query... | i wrote about something similar recently, maybe it could be helpful to you: http://www.kathyisawesome.com/424/alphabetical-posts-glossary/ it was based off of my answer to this question: stackexchange-url ("How to build a directory with indexes in Wordpress") the answer includes both my original posts_where solution an... | Create pagination and order according to alphabet | wordpress |
So I recently figured out how to change my blog page to display excerpts by changing the <code> <?php the_content(); ?> </code> to <code> <?php the_excerpt(); ?> </code> in my <code> index.php </code> file. I am using a custom child theme and unfortunately had to edit the parent twenty eleven <code> functio... | filtering the_excerpt() If you <code> remove_filter( 'get_the_excerpt', 'wp_trim_excerpt' ) </code> and add your own <code> get_the_excerpt </code> filter you can do this. The default filter ( <code> wp_trim_excerpt() </code> ) can be found on line 2023 of <code> /wp-includes/formatting.php </code> if you want to just ... | Show Video in Excerpt | wordpress |
I am creating a child theme for the first time, and sort of learning as I go. I am having an issue with the way videos are showing up on a mobile phone with my child theme, but not with my parent theme. I'm wondering what is going on. On my child theme the videos show up large when viewed on a mobile device (http://wpd... | This question depends entirely on the Theme in question, and how it handles CSS. For a Theme that uses only a single <code> style.css </code> file, obviously, you only need to import <code> style.css </code> . For a Theme that links other stylesheets in the document head (they shouldn't be doing this; instead, they sho... | Do I only need to import style.css for a child theme? | wordpress |
Does a website slow down or under perform in any way with a large number of widgets installed? | Put simply: not inherently. If you have a widget that does NOTHING at all...like, literally you add it and there's no code for the widget outside of registering it, you'll see SUCH a small performance hit from adding it that you would need to be looking at <code> microtime() </code> numbers to notice anything. That sai... | Does the number of widgets installed affect website performance? | wordpress |
WP 3.3.1, Suffusion 4.0.2 I am trying to figure out how to make my front page display only the most recent post marked sticky. I can't find how to do this in the documentation. What I'm trying to do is use a combination of future post publication dates and expirations (via the Atropos plugin) to control what shows up o... | If I'm understanding you correctly, you want to show only the most recent sticky post only on the front page. I had the same issue a month or two ago, and got some fantastic help from the community here at WordPress Answers. The solution is to run two loops in your index.php file. One to pull only the most recent stick... | How to make my front page display only the most recent sticky post, plus usual widgets? | wordpress |
I need to build several highly customized WordPress instances beyond look and feel changes. For example, in one of the instances, any categories with children need to display in its own dropdown on the post edit page. I can not use multi-site setup as each instances may need to be highly customized. I would also like t... | As mentioned before, never, ever, modify wordpress core files. It is a maintenance nightmare and a security risk, and very, very bad practice. During development the only area you need concern yourself with is the wp-content folder, specifically plugins and themes. Put post type registrations, url rewrites, custom taxo... | How to manage multiple wordpress project with shared code base | wordpress |
Is it possible to print two different url's from the same featured image/thumbnail? So i have set up my image size.. <code> add_image_size( 'full-size', 460, 9999 ); add_image_size('fixed-height', NULL, 75, false); </code> I need to pull the url of these two images sizes into the post like so.. <code> <li><img... | no problem to have 2 or more post thumbnails of different sizes. but what is the "ref" attribute ? do you mean "rel" ? anyhow - example from the : codex <code> <?php if ( has_post_thumbnail()) { $large_image_url = wp_get_attachment_image_src( get_post_thumbnail_id(), 'large'); echo '<a href="' . $large_image_url[... | Show Multiple Size URL of one Featured Image/Thumbnail? | wordpress |
it's a catalog website for different product. I need a function that will get the category of the selected product, and get all the product from that category Let see an example. A table, is in wood category and kitchen. So when display table, under the table i like all the other kitchen product listed as well as all t... | You can use <code> WP_Query </code> 's <code> tax_query </code> to do this. You would want the args (just on the <code> tax_query </code> , I'll leave the rest up to you, you have the documentation) to look something like this: <code> 'tax_query' => array( 'relation' => 'OR' array( 'taxonomy' => 'category', 'f... | Get post related on category | wordpress |
I am using custom field on wordpress admin posts page by adding the following code and then trying to sort the posts based on post views but the sorting does isn't working. Here is the code I have added in functions.php: <code> add_filter('manage_posts_columns', 'posts_column_views'); add_action('manage_posts_custom_co... | The <code> posts_column_register_sortable </code> function, hooked onto <code> posts_column_register_sortable </code> returns an array with names of sortable columns as keys and their corresponding value what to sort by (e.g. 'post_title' etc). In your case you've given it 'post_views' to sort by, which doesn't exist a... | Making post views as sortable | wordpress |
In one of my form input, the options are a list of posts. I can use the loop to get the posts, but, getting things from database table is faster, right? I see plugins sometimes use db directly, sometimes use loop. I'm confused. | In general I try to avoid custom SQL queries as much as i can and use the native WordPress functions but in some cases its much better/faster to use custom queries. if the case is just get a list of posts the you can use the WP_Query or get_posts which will work almost as fast as a custom query (as long as you don't ne... | Use Loop or direct database query? | wordpress |
Morning all, I'm trying to work out why the commenting system thinks .au, .ca and a couple of other international email address are being treating as invalid. Any ideas? | WordPress’ internal email validation is very weak. I’ve written a plugin some time ago to catch most cases where WordPress fails: Extend Email Checks . It uses PHP’s <code> filter_var() </code> . But there are some edge cases, where it doesn’t work good enough. Give it a try. | Comments system doesn't like International domains | wordpress |
is there a way for a registered user in Wordpress to have in his author page an option to delete his account along with his posts without going to dahsboard? I need a front-end option in a form of a button for user to be able to delete his profile :) Thank You in advance for Your help guys! | take a look at <code> wp_delete_user </code> , all you need to do is pass the author's id and his posts will be deleted along with its account. | Front-end delete account in Wordpress | wordpress |
I am reading the source of a plugin (gallery to slideshow plugin) to make it behave like i want and it is using an action <code> add_action( 'the_posts', array( &$this, 'have_gallery' ), 10, 1 ); </code> I want to know what those extra parameters (10,1) mean but i cant find the documentation of this action. Please ... | those parameters aren't unique to the_posts, they're parameters for the add_action() function <code> add_action( $tag, $function_to_add, $priority, $accepted_args ); </code> the 10 is just the default priority and 1 is the default number of accepted arguments. since they're both default, you don't really need either. h... | where is the documentation for add_action() parameters? | wordpress |
I am doing projects for clients and sometimes an update messes a lot. So, can we leave error messages and get rid of new updates notifications in wordpress admin side? Thanks! | Try this: http://www.vooshthemes.com/blog/wordpress-tip/wordpress-quick-tip-remove-the-dashboard-update-message/ which seems to work good for 2.9- versions <code> //Copied from the above referenced article remove_action('wp_version_check', 'wp_version_check'); remove_action('admin_init', '_maybe_update_core'); add_filt... | Is it possible to get rid of admin new updates notifications? | wordpress |
i know this is a bit of a weird question but its a real time saver so if you got any ideas (even partial) i would really apreacate them :) Ok... so i am using wordpress built in interface to capture and disply remote website images... here is the shortcode i am using.. <code> /******************************************... | EDITED ANSWER Forget every thing i said before. Here is what i have found the following In php to generate a website thumbnail, you cant do it natively with php's built in functions, so you have to call an external service or program to do it for you. Since wordpress is basically php , this fact still holds true. You c... | Store Snapshot created via wordpress to use with lightbox | wordpress |
I have created a page with some text in it using this page-about.php as a template; page-about.php contains the basic: <code> <?php /* Template Name: About us */ get_header(); ?> <div id="primary"> <div id="content" role="main"> <?php while ( have_posts() ) : the_post(); the_content(); endwhile; ?&... | You created a specific page template for a page called 'about' but your page is called 'About Us'. Try creating a page named 'About' or renaming your file to page-about-us.php. Also use the cleaner formatting involving new lines: <code> <?php /* Template Name: Example Page */ get_header(); ?> </code> You're also ... | Page template anomaly | wordpress |
My post has only one category. The following code: <code> $categories = get_the_category(); </code> gives me this result: <code> Array ( [0] => stdClass Object ( [term_id] => 22 [name] => Style Guide [slug] => style-guide [term_group] => 0 [term_taxonomy_id] => 22 [taxonomy] => category [descriptio... | I'm guessing you're referring to the <code> [category_count] => 2 </code> when you say "saying that I have two categories"? If so, you should understand that category_count is not the number of cateogries that this post has, but rather it is 'the number of uses of this category (also stored as 'count')' - see get_th... | Why is get_the_category() saying that I have two categories? | wordpress |
<code> <div class="menu"> <ul> <li class="page_item page-item-15"><a href="link.html">XXX</a></li> </ul> </div> </code> Where "XXX" I want to put The reason I want to do it is that I'm coding top menu and I want to display a picture on hover of the link. It would be like ... | When using <code> wp_nav_menu </code> you can pass arguments to it which help you style the output, look at: <code> $container </code> Whether to wrap the ul, and what to wrap it with. Allowed tags are div and nav. Use false for no container e.g. container => false . <code> $container_class </code> the class that is ap... | How to add div to top menu itiem | wordpress |
I'm writing a module for remote login into another WP site via my plugin's admin. This is the code I'm using on the sender side: <code> <?php add_action('init', 'connect'); function connect() { //I submit the username via a form in my plugin admin page if(isset($_POST['username']) && $_POST['username'] != ''... | Buddy, you what you are doing is correct but just that you need a redirection as well because the code thats executed before this login function is assuming that the user is not logged in, so here is a code that will work: <code> function auto_login(){ if(isset($_GET['auto_login'])&&$_GET['auto_login']=='1'){ $... | Remote login with only the username not working | wordpress |
I'd like to attach files that aren't on the list of supported file types. In this case I'd like to upload files from the media manager that have the .RWP extension (which is used to package files in the Train Simulator 2012 game). | You can hook the upload_mimes filter to accomplish this: <code> add_filter('upload_mimes', 'wpse_43657_upload_mimes'); function wpse_43657_upload_mimes($mime_types){ $mime_types['rwp'] = 'application/octet-stream'; return $mime_types; } </code> | White-list file types for media upload | wordpress |
I've been trying to get the featured image of a post to be displayed outside of the loop for all the image thumbnails. That way, the featured image (of a product) is displayed in large and the thumbnails just below it. All the images in the (product) post are set in their own gallery of images. Please see comment in co... | UPDATED First, let's create a new image size. We could update one of the existing sites, but we'll just add a new one for experience sake. Open up your functions.php file and add the following: <code> if ( function_exists( 'add_image_size' ) ) { add_image_size( 'new-size', 500, 500, true ); // Cropped add_image_size( '... | How do I display the featured image from an image gallery using a reference in code? (example within) | wordpress |
Migrating question: How would I structure a MySQL query to move the value from one meta_key to another meta_key? eg: I have an old meta_key of "guest_sort" associated with "posts" to "tf_exhibitor_sort" under the post type "exhibitor_listing" I've already moved the posts from the original post category over to the post... | So, friend came up with a script for this. You put it in your root folder of your instal and it flips the values from one meta key to the other. I thought I'd share it in case anyone else need it. <code> <?php // Functions function db_connect($host,$db,$user,$pass){ if(@mysql_connect($host, $user, $pass)){ @mysql_se... | Move value from one meta key to another | wordpress |
I am in the process of migrating my site out of Wordpress and I need to filter the registration and/or login process so there is a separate database field that holds the user password in a hash that can be easily used on a non-WP site. How can I go about this? | It is possible to write code to grab the user's password on login and write it out in a different format to a different location. Over time, you would thus accumulate the passwords in a different format than WordPress itself uses (it makes use of the excellent PHPass library for password storage). To do this, you'd mos... | Convert user passwords to MD5? | wordpress |
I'm aware that WooCommerce is a fork of jigoshop, and there was some controversy, however now that both have had releases since their divergence, how do they differ in features and direction? | I won't comment on all features, but I will say take a look through the changelogs for WooCommerce , our blog , and our public GitHub repository to get an idea of the features we've added, what we're currently developing, and the over-all direction we're taking with WooCommerce. A few of the features we've added to our... | Jigoshop and WooCommerce differences | wordpress |
I have installed buddypress, I don't see any errors or success message when a person updates their profile details. Also for some reason it only seems to update admins details, a normal user/subscriber, cannot update its on profile. has anyone come across this? help please. | I managed to use <code> $bp->template_message </code> this was a bit tricky but then I had to go to bp-xprofile-screens.php just under line 77 I added <code> unset($is_required[1]); </code> to remove the username update, (as this does not need changing) :) hope someone else, may find this useful. | buddypress edit profile | wordpress |
I'm creating a child theme for the first time and I had a few questions regarding code added to header. In a non child theme there is certain code I add to my header.php file such as google analytics, google webmaster tools, buy sell ads, Facebook open graph, etc.... How do you do this in a child theme? Do you create a... | I would hook into the <code> wp_head </code> action. I would place this in a plugin so as to abstract it from your presentation layer. This allows for scalability and changing of themes. This also prevents any analytics collateral damage if a step is missed in migration from one theme to the next. <code> add_action('wp... | How to add code to Header.php in a child theme? | wordpress |
This is probably pretty simple, but... I want to use the WP function antispambot not on get_the_author_email but on a value in a field I added to User Profile called publicemail . Everything I've tried throws a php error. This is the antispambot usage shown in the WP docs: <code> echo antispambot(get_the_author_email()... | As the Codex states for the <code> antispambot() </code> function: Return Values (string) Converted email address. You have to do one of the following: <code> echo antispambot( $curauth->publicemail ); // OR... print antispambot( $curauth->publicemail ); </code> So your full example would look like the following:... | Use of antispambot with $curauth-> email | wordpress |
I added a "company" field to member profiles via s2member plugin. However, this field is not included in the "member" search. For instance, when I search on the name of a company (when I know the company name I'm searching for is part of a member's profile info), the search displays "no results". How do I make added pr... | Fields added by S2Member are probably stored in wp_usermeta, while BP's member search searches over data stored in BP's xprofile tables. Probably the most straightforward fix is to use a BP profile field for your 'company' data. If you've already got member data in there, you'd have to write a script that moves (or cop... | Alter BuddyPress member search to include search on added profile fields | wordpress |
I currently have the following query: <code> $args = array( 'post_type' => 'post', 'orderby' => 'title', 'order' => 'ASC', 'posts_per_page' => 10, ); $my_query = new WP_Query($args); while ($my_query->have_posts()) : $my_query->the_post(); ?> </code> This returns all the posts that are published. H... | You can add post_status to your query, the string 'any' will return all posts no matter the status, or you can use an array to just grab those you want. <code> $args = array( 'post_type' => 'post', 'orderby' => 'title', 'order' => 'ASC', 'post_status' => 'any', 'posts_per_page' => 10, ); </code> http://c... | WP Query to get all posts (including in draft/pending review) | wordpress |
I have a custom post type "career_opportunities" with a "responsibilities" textarea box: <code> <p><label for="responsibilities">Responsibilities</label></p> <?php wp_editor( "", "responsibilities", array( 'textarea_name' => 'responsibilities', 'tinymce'=>true )); ?> </code> The prob... | In regards to the comment @ungestaltbar posted on your question, this is what they meant. You are storing the <code> $_POST </code> data into variables but then not using them, rendering them useless. This won't solve your issue but I wanted to clear that up. :) Alternatively, you can see exactly what is getting passed... | How to save TinyMCE fields on Wordpress custom post type? | wordpress |
Since 3.1 WordPress support multiple taxonomy query. The question is : If I have a two taxonomy query, e.g: <code> http://localhost:8888/site/?lot-term=australia&story-type=note </code> how can I determine which template to be used for the query? On the first try, it loads taxonomy-lot-term.php, but after I re inst... | I'm not sure if this the best method, and I would like to hear some other suggestions! This will alter the template to some pre-defined template if two or more taxonomies are being queried. You can hard-code the taxonomies to check or use <code> get_taxonomies </code> : <code> /* * Checks to see if more than one of (ce... | How to choose which template to be used for multiple taxonomy query? | wordpress |
Since 3.3 we can enqueue scripts conditionally right in our shortcode functions, but when I tried to do this with some PHP class (uses <code> session_start() </code> in the <code> __construct() </code> function) as you can guess it gives me the <code> headers already sent </code> error. The problem is (this is using th... | I ended up solving this myself, but with help from @Bainternet (checking if shortcode is present in the post content). What I did was created a variable in my class called <code> facebook </code> , where I store the PHP SDK class. I used the <code> wp </code> hook to start the Facebook class if a few things are set and... | Conditionally loading Facebook PHP SDK in shortcode | wordpress |
It's been talked many times that Wordpress outputs some really bad code for the built-in gallery function. This is the core code responsible for the gallery output (in /wp-includes/media.php): <code> function gallery_shortcode($attr) { global $post; static $instance = 0; $instance++; // Allow plugins/themes to override... | Like it was mentioned before removing the shortcode and re-adding it is not the compatible with other plugins modifying galleries so instead you use the <code> post_gallery </code> filter hook and the same code from the <code> gallery_shortcode </code> function but with your own modification for example, I've commented... | How to manually fix the WordPress gallery code using PHP in functions.php? | wordpress |
I am developing a WordPress plugin that allows a user to insert image maps on the image from the WordPress default image editor. I want some JavaScript for it so that when user selects some area on the image it returns the coordinates of the selected area to use within the area tag. | I would suggest looking at this StackOverflow post - stackexchange-url ("Image Map Editor") - particularly the top answer's recommendation: imgAreaSelect . imgAreaSelect is a jQuery plugin for selecting a rectangular area of an image. It allows web developers to easily implement image cropping functionality, as well as... | Get coordinates of selected area to use in image maps | wordpress |
I want to replace get_author_link() and get_the_author_meta($feld) with something equivalent to point to the author of the current post Buddypress user profile page and retrieve a specific profile field from his Buddypress page ie, I just want to show a link to the post user profile and a biography from one of his BP p... | For an author's profile link, use <code> bp_core_get_user_domain( $user_id ) </code> to get the URL, and <code> bp_core_get_userlink( $user_id ) </code> to get an HTML link element, including display name. For the xprofile data, use <code> xprofile_get_field_data( $field, $user_id ) </code> <code> $field </code> can be... | How to get a buddypress user profile link and a certain user profile field for the current post author? | wordpress |
Good evening. :) Well, my mother is currently using a wordpress installation for her day to day blogging. Often, a post consists of some text and a few images, which are displayed via the very nice flexslider script . Usually, when the post is ready, I handle the flexslider part. However, I'm not always around, so post... | Just take a look at the <code> RW_Meta_Box </code> library to add a drag and drop interface to add images as post meta data. That's the most easiest approach, plus it uses the new »WP Pluploader«. For more details take a look at stackexchange-url ("this answer") on how to customize it and read a little in the TenderApp... | Upload multiple images and insert them into custom html code | wordpress |
I installed theme-my-login and after playing with it decided it wasn't for me. I logged out my dashboard, went to log back in and now my wp-admin returns a 404 error - what do I do? | Well you could have tried this: try checking your <code> functions.php </code> and <code> wp-login.php </code> file:- try to see if there is some blank spaces at the end -(after <code> ?> </code> ) | wp-admin returns 404 | wordpress |
I changed post_title, post_contents, and post_name to allow for utf by changing collating sequence to: utf8_general_ci Then using add new post, I type for the title three Hebrew ALEFs. The post_title is in Hebrew in the database, but the post_name has this value: %d7%90%d7%90%d7%90 According to Charmap, ALEF has a hex ... | it's the URL encoded version of your text. <code> <?php echo urldecode('%d7%90%d7%90%d7%90'); ?> </code> outputs: <code> אאא </code> <code> post_name </code> is the slug, so the characters have to be URL-safe. | database columns: post_title vs post_name | wordpress |
I know I can use the Template Hierarchy to set up custom theme pages for terms inside a category, like these: <code> mysite.com/category/tech/ // category-tech.php mysite.com/category/blog/ // category-blog.php mysite.com/category/featured/ // category-featured.php </code> <code> category.php </code> does not seem to w... | There is no default rewrite to a template for a category or taxonomy landing page. You are correct, that this can be done by creating a custom template and applying it to a page. | How can I set up a category "overview" page? | wordpress |
I have a music player in my theme that generates its playlist from a javascript file that looks like this <code> var myPlaylist = [ { mp3:'track url goes here', title:'title here', artist:'artist', } { mp3:'track url goes here', title:'title here', artist:'artist', } etc... ]; </code> How can I query the media library ... | Welcome to WPSE marctain! Edit There are some critiques on using the guid but no one of the commentators managed to edit this answer to a better one, so I'll do it. Yes, using guid is a bad idea in the long run, I knew that and I should have pointed that out, I didn't, it was a mistake. I'm sorry, it was a quick and di... | How can I list URLs of all audio files within my media gallery? | wordpress |
What I am trying to do is modification of this function on codex http://codex.wordpress.org/Function_Reference/count_user_posts Check the title adding post type support bottom of the page. The function is: <code> function count_user_posts_by_type($userid, $post_type='post') { global $wpdb; $where = get_posts_by_author_... | here is a quick solution to get the post count any kind of filtering you want <code> function custom_get_user_posts_count($user_id,$args ); $args['author'] = $user; $args['fields'] = 'ids'; $ps = get_posts($args); return count($ps); } </code> since this function uses get_posts you can filter and use anything that you c... | Count user posts by user ID, Post type and Post status | wordpress |
I installed the WP Issuu plugin on a site and tried to use <code> do_shortcode() </code> to render the shortcode in the template file. Strangely it doesn't work, although it does for the <code> [gallery] </code> shortcode. I.e. this works: <code> echo do_shortcode('[gallery link=file]'); </code> But this doesn't work: ... | WP Issuu plugin doesn't use the shortcode API. So you can't use it like a regular shortcode. The plugin is a filter for the_content, that's why your solution did work. If you want to solve this (use do_shortcode) you have to rewrite the plugin so it uses the shortcode API. | Trying to display short code content in template file with do_shortcode() | wordpress |
I want to update my plugin and have proper feedback, like the WordPress update/upgrade mechanism. How is this effect done? Essentially I have a script I want to run that has lots of processing, and with each run through the loop, output another line to the screen. Is this done with the output buffer? | Yes, WordPress uses output buffering for displaying these messages. There's a nifty function you can use within your loop called show_message() which utilizes wp_ob_end_flush_all(); <code> function show_message($message) { if ( is_wp_error($message) ){ if ( $message->get_error_data() ) $message = $message->get_er... | Output data like WP's plugin installer/updater | wordpress |
Please help with menu registeration: I have followed this guide (http://codex.wordpress.org/Navigation_Menus) step by step. Added the following code to functions.php: <code> function register_my_menus() { register_nav_menus( array('header-menu' => __( 'Header Menu' ) ) ); } add_action( 'init', 'register_my_menus' );... | You don't need to add any action to register your Nav Menu. Here are some quick steps for you to get your Wordpress Nav Menu to work... Register Nav Menu <code> if (function_exists('register_nav_menu')) { register_nav_menu('header_menu', 'Header Menu'); } </code> Define and Use Nav Menu in your Theme: Usually we place ... | register_nav_menus() won't register menus | wordpress |
I am creating a menu manually and trying to include the search form. this is taken from the Wordpress Docs "Building a simple menu list" at http://codex.wordpress.org/Function_Reference/wp_get_nav_menu_items . I have added an additional <li> element before completing the menu and added the search form. <code> // ... | this might be the cause: The $echo parameter is ignored when searchform.php is present. There is a issue in the WordPress Trac concerning this. from the codex: http://codex.wordpress.org/Function_Reference/get_search_form#Notes | get_search_form() doesn't appear to take parameter into account | wordpress |
All, I've got two wordpress pages. One wordpress page displays a form to do some registration stuff for the website. The second wordpress page actually processes the data and inserts it into a custom MySQL table that I have. I'd like to use the nonce functionality inherit to Wordpress. The user doesn't have to be a Wor... | Nonces are not tied to the admin interface. This codex page explains them very well. Essentially, you add : <code> <?php wp_nonce_field('name_of_my_action', 'name_of_nonce_field'); ?> </code> in your form (this creates a hidden input field containing an one-time-use token). And where you're doing the form process... | Using nonce external of WP Admin | wordpress |
I think I've got this figured out and I'd like to make sure I'm not missing anything obvious. My goal is to prioritize a list of results by custom posts with attachments. So, I have a query returning say 60 results and, of those 60, 40 have attachments. I'd like those to show first, then continue with the posts that do... | Surprisingly, Wordpress does not make it very straightforward. Even though lots of people have had similar questions on the wordpress.org forums, I believe yours is unique in that you want to keep the order and sort. This is by no means quality code, but does exactly what you're looking for. <code> class WP_Query_Custo... | Sorting By Custom Posts With Attachments | wordpress |
I cannot get the <code> comments_popup_link </code> to display with the posts retrieved by the foreach loop. Only the title and permalink are displayed. Any idea why the comment link is left out? <code> <?php if(count($ids)){ echo '<div id="tab-news" class="tab-all"><a id="link-news" class="link-all" href="... | the <code> comments_popup_link() </code> function will only work when used within the_loop ; a 'foreach' loop using post Ids is not the same. you could try to build your own link, based on this function: <code> get_comments_number( $id ) </code> . | Loop not displaying comments_popup_link | wordpress |
I'm looking for a way to create a parent authors page and then use the <code> author.php </code> for the individual author pages. I've been out of the loop (no pun) for a couple months and am wondering the best way to do it. | First, Explaining Loops You're dealing with two kinds of "loops." The first is a loop in PHP, the second is a loop in WordPress. Loop in PHP kaiser gave you some code that will generate a list of authors on your site. You can iterate through this list and print information on the screen. <code> // Fetch an array of aut... | Authors Page : A page of authors | wordpress |
The add from media tab for wordpress is super slow on my local. It takes at least a full minute for the modal box to load content when I click that tab. I am guessing it is because I have 65 pages of images and WP is loading all 65 pages. Is there a good plug-in or a hack out there to help speed up content loading when... | Found: The issue was the Media Library Categories plugin. | "add from media library" tab is super slow | wordpress |
I would like to create a dynamic WordPress menu using <code> wp_nav_menu() </code> divided over four lines or rows as the static website . I think I should either force the menu to do this using CSS and width limitations or PHP. I do think PHP is needed as certain menu items will be followed by images before the menu c... | So, In your place I would go for Dynamic Sidebars because of the control over Widgets is much more easily achieved. But if you still want use WordPress Navigation Menus to do it, to control the output the way you want you need to extend the Class <code> Walker_Nav_Menu </code> , take a look at a usage for the Walker ex... | How to create menu spread over four lines including images | wordpress |
I created a page for my custom post types. The code can be viewed on Snippi: http://snippi.com/s/e8852rx I'm trying to insert paginate_links, but for whatever reason it's simply not showing up. Here is the paginate_links code (this code works on normal archive.php files): <code> <?php global $wp_query; $big = 999999... | The following works for me (I've removed all the formating / custom post meta). I would add, its not clear why you need to use a page with a custom template, and don't instead create a template called <code> archive-portfolio.php </code> which is used for a custom post type's archive pages (see template hierarchy) <cod... | Paginate Custom Post Type Page | wordpress |
My homepage has 1 featured post, followed by 4 posts stacked 2 on 2, like this: The featured post is only shown on the first page so the second page shows the older posts stacked 2 by 2 as above. However, I'd like to be able to change the layout on the second page, showing the posts in full width and length. Any way to... | To load override WordPress' choice of template you can use <code> template_include </code> filter and then use the <code> locate_template </code> to return the the template file path (if it finds it). The file-name passed to <code> locate_template </code> must be the name of the template file name (which should be in y... | Different layout on second page | wordpress |
I'm brand new here and I'd like to start off by asking about WP frameworks. I've seen quite a bit out there, so I'm confused about what to choose for my site. So here are a few questions: What is the advantage of a framework in the first place? Specifically, what are the advantages of installing frameworks such as Woo,... | The advantage of using a framework is two-fold: If using a theme framework to build a regular theme, it can give you a head start by giving you mature code (in most major frameworks, anyway) that you can use as a base for your customizations. This gives you more control of the theme framework code but also creates a bi... | Back to the basics: What's so great about a framework? | wordpress |
What is the recommended way to approach the follow issue? I have to create two pages. On one page I will have a small form where users will be able to register themselves (with or without photo). On the other page, I will show all the users' info entered on the previous form. For the admin section, I just need to have ... | The following code creates a new role. In fact is simply clones the subscriber role, so if you are not using that role currently, you may as well just use that. The following function need only be run once (it run's when a user is 'admin side') <code> //Creates a custom role called 'my_new_role'. //Run this once then f... | How to create and retrieve data from a special registration form? | wordpress |
I look up a custom post field value in header.php, and store it in a global variable. In most of my template files, the includes go like this: <code> include header ...do a bunch of stuff include sidebar include footer </code> I can not persist the variable into the footer.php file... is there any way to do this so tha... | You'd have to declare it first above those includes and globalize it within header or footer before getting or setting the value. however- in the specific context you're speaking of- getting a custom field value, it's only retrieved from the database on the first call, then cached, so subsequent calls won't hit the dat... | persist a variable set in header.php all the way down to footer.php | wordpress |
I've found this helpful snippet to make a delete post link on the front-end: <code> <?php if (current_user_can('edit_post', $post->ID)) echo "<a href='" . wp_nonce_url("/wp-admin/post.php?action=delete&amp;post=$id", 'delete-post_' . $post->ID) . "'>Delete</a>" ?> </code> What I am wondering... | There isn't, by default, a 'publish' link because of the way WordPress handles publishing posts. ' publish ' is not consider an action in the same way ' delete ' is, instead you save the post, with all its data, including its post status. To get round this you can create your own action handler. In order to avoid poten... | Modify front-end delete button to publish pending posts | wordpress |
From my previous question stackexchange-url ("How to create and retrieve data from a special registration form?") I would like to know how do I list in the backend all users that were assigned to a custom role? Is it possible to put them in a separate admin page? | User queries There is a <code> WP_User_Query </code> , analogous to <code> WP_Query </code> for posts: <code> $wp_user_search = new WP_User_Query( array( 'role' => 'editor' ) ); $editors = $wp_user_search->get_results(); </code> Usually this returns an array of row objects from the user table: <code> echo '<ul... | How do I list in the backend all users that were assigned to a custom role? | wordpress |
Im loading post into a content area via ajax but the latest post is the only one that loads, any one encounter this and manage to fixed it, if so please enlighten me. <code> <div class="content"> <?php $args = array('posts_per_page' => 1); query_posts($args);?> <?php while ( have_posts() ): the_post()... | OK, so you're not using AJAX (you didn't share any Javascript here, so I may be confused as to what I'm looking at) but this line: <code> <?php $args = array('posts_per_page' => 1); query_posts($args);?> </code> indicates you are setting the number of posts to be displayed to just 1, hence the "posts_per_page"... | Notting but the latest post content keeps on being loaded | wordpress |
One thing that's never been clear to me (especially since I haven't submitted a plugin to the repository) is how a plugin's unique "ID" (slug) is generated (i.e. this list). Is it a choice by the author at the point of SVN submission, or by a moderator? Is it the sanitized plugin name (title)? Is it the <code> plugin_b... | When submitting a plugin, the slug becomes the sanitized plugin name, as submitted. The "Name" of the plugin can change after this, but the slug remains the same forever more. When WordPress needs to check for a plugin update, it gets all the header information of the plugin and the directory name that the plugin is in... | Plugin SVN & update API - how are plugins identified? | wordpress |
I have a website which has a static front page and a blog page where all the blogs are displayed. I am using my own theme and have created some custom meta boxes that display content in a sidebar based on the return value from <code> $post->ID </code> . The interesting behaviour I am getting is that <code> $post->... | consider to use: <code> $postspage_id = get_option('page_for_posts'); </code> and then change the rspective line in your code to: <code> $leftSidebar = get_post_meta( $postspage_id, '_my_meta', true ); </code> from: http://www.blog.highub.com/cms/wordpress/wordpress-front-page-posts-page-id/ | ID for posts/blogs page | wordpress |
Is there a way to make a dashboard contact form widget? I just simply want to have it there so users can give feedback directly from their dashboard. | Yes. You can do this by adding a dashboard widget with a contact form function that uses AJAX to submit the form. <code> function myplugin_dashboard_widget() { ajax_contact_form(); } function myplugin_add_dashboard_widgets() { wp_add_dashboard_widget('myplugin_contact_widget', 'My Plugin Contact Form', 'myplugin_dashbo... | Dashboard Contact Form | wordpress |
I have two cpt's, events and reports, they both share the taxonomy locations, I have my taxonomy-locations.php, but that is showing reports & events for location, I just want to show reports for location. Can someone help me out with how this query should go? Thanks | Before the loop in your <code> taxonomy-locations.php </code> file, <code> global $wp_query; $args = array_merge( $wp_query->query, array( 'post_type' => 'report' ) ); query_posts( $args ); </code> You could, alternatively, modify the query using an appropriate hook (this would be the most effecient method) - but... | Limit taxonomy results to a single cpt | wordpress |
I creating a custom footer navigation in wordpress. I looked all over the wordpress documentation and still haven't found anything. So, what I'm trying to do is add an "|" in the navigation like this: Home | Link 1 | Link 2 | Link 3 | Contact I know there's a way in CSS, but I know this is generated by wordpress so I'm... | I figured out a way to do this and without using the wp_nav_menu. Here's the code to do this and hope it might help other (Note: You need to create a menu in the admin panel to have this work). <code> <p> <?php $items = wp_get_nav_menu_items("footer"); $count = count($items); $i = 0; foreach($items as $item): ... | Separator for custom nav menu | wordpress |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.