question stringlengths 0 34.8k | answer stringlengths 0 28.3k | title stringlengths 7 150 | forum_tag stringclasses 12
values |
|---|---|---|---|
I want to retrieve the default value of Post per page (the value that is set in settings-> reading. I've looked around and so far I've only found ways to query it. problem is i dont want to change what was set i just want to retrieve it for pagination purposes. i thought of using <code> $something->post_count. </cod... | It's saved in an option: <code> $default_posts_per_page = get_option( 'posts_per_page' ); </code> You can see the keys and values of all available options by manually entering the admin url: /wp-admin/options.php Edit Total number of posts: <code> global $wp_query; $total_posts = $wp_query->post_count; </code> | How can i retrieve default post per page value? from settings-> reading. And total number of posts? | wordpress |
I am working on a simple search form widget, with a built in autocomplete capability (You can download the current version here). The plugin is working, but I am currently rewriting all the code using OOP. One of the problems I came across was the fact the a Wordpress Widget is already a part of the WP_Widget class. I ... | You can simply put your init code within the constructor of the class. For example: <code> class myWidget extends WP_Widget{ function myWidget(){ // Init code here } function widget( $args, $instance ) { // The widget code wp_enqueue_script(...); wp_enqueue_style(...); } // Over methods... } register_widget('myWidget')... | What is the correct way to build a widget using OOP | wordpress |
In a nutshell, my question is "How do I convert the absolute path of the executing script, e.g., <code> /home/content/xx/xxxxxxxx/html/wp-content/plugins/MY_PLUGIN_DIR/MY_PLUGIN/MY_PLUGIN.PHP </code> or <code> /home/content/xx/xxxxxxxx/html/wp-content/themes/MY_THEME/functions.php </code> to the absolute URL?" <code> h... | Call get_stylesheet_directory_uri() for the current theme, or get_template_directory_uri() for the parent theme of a child theme, and append your file paths to that. <code> $url = get_stylesheet_directory_uri() . '/images/my-icon.png'; $url = get_template_directory_uri() . '/images/my-icon.png'; </code> Edit: To determ... | What is the correct way to convert the absolute path of the executing script to a URL, in WordPress? | wordpress |
I have Wordpress installed to mydomain.org/blog, and everything works fine and dandy from my computer (localhost). However, when I connect to the blog from another computer, the theme (Twenty Twelve) disappears and it's all plaintext. I have not tried to install any other themes. Help? Edit: URL upon request is http://... | What I had done was in the WordPress Admin page, under Settings > General, I had put <code> localhost/blog </code> for the <code> WordPress Address (URL) </code> . Changing this to the public URL of my site fixed the problem. | My theme is not showing up on any other computers | wordpress |
Should I use the function <code> add_filter </code> In my plugin's <code> init </code> action hook or just the in the main plugin script? Since sometimes I found people is using filter all over the place and if I put in the <code> init </code> hook, it would be too late for some case. Are there any general advice on th... | <code> add_filter() </code> and <code> add_action() </code> are available before any plugin is loaded. So you can use both in the first line of your plugin or theme. For readability I recommend to group action and filter registrations at the very top of your main file: in a plugin, the file with the plugin header in a ... | Where is the best place to use add_filter | wordpress |
I'm trying to develop my WordPress skills a little. I've previously moved some of my functions.php that I use time and time again into a must-use plugin. I'm now trying to make that Object Oriented - with limited success. The code below is an excerpt of my overall code. The first section works perfectly, reducing the e... | this: <code> add_action('wp_dashboard_setup', array( $this, 'tidy_dashboard') ); </code> is getting added on the <code> wp </code> action, which is too late. Hook it to <code> admin_init </code> or in your constructor. | Object Oriented Plugin not working | wordpress |
I have a list of posts from a category as seen here in this example . The problem is, if you scroll down to the bottom and click older, you'll see that the posts on the page have not changed at all, how ever the url has changed. Can some one tell me whats wrong with the following code that generate this? <code> functio... | Don't use <code> query_posts </code> in the template. If you delete that line, your template will paginate correctly. If you want to alter the main query, use the <code> pre_get_posts </code> action. Currently, your query overwrites the default main query, and you don't set any pagination parameters within the query, s... | Pagination not working properly | wordpress |
I'm creating a plugin. I'm receiving the following error (WP 3.5): <code> Fatal error: Call to undefined function wp_set_password() in \path\to\plugin.php on line 18 </code> Line 18 consists of simply: <code> wp_set_password( 'newpass', $user_id ); </code> This is located in the main plugin file, and all other code has... | When your plugin loads, pluggable functions aren't loaded yet, in fact a lot of stuff is not loaded yet, this what actions are for. Hook your function to an action, like <code> plugins_loaded </code> or <code> init </code> , when the WP environment is loaded and initialized: <code> add_action( 'init', 'wpa80246_init' )... | Undefined function wp_set_password | wordpress |
Below is a functions.php code for wp_link_pages which allows pagination and previous/next links to be displayed. It also wraps each pagination link in a span class called "classlinks". I need to change the default "Pages:" before the pagination while maintaining the rest of the code. My attempts removed the ability to ... | Add, right after the declaration of the global vars, e.g.: <code> $args['before'] = '<p>Hello world: '; </code> | Unable to Change "Pages:" Before WP_LINK_PAGES | wordpress |
I have this function which gives me <code> IDs </code> and <code> titles </code> of all <code> child pages </code> of a given <code> parent ID </code> . <code> function getPageChildren($page_id) { $my_wp_query = new WP_Query(); $all_wp_pages = $my_wp_query->query(array('post_type' => 'page')); $page_children = ge... | <code> sort_column </code> is not a valid parameter for <code> WP_Query </code> . You want <code> orderby </code> . <code> sort_order </code> is also not a valid parameter. It should just be <code> order </code> . <code> $all_wp_pages = $my_wp_query->query( array( 'post_type' => 'page', 'order' => 'ASC', 'orde... | Set order of returned items in the WP_Query() class/function | wordpress |
Is there a way to allow attachments with wordpress comments? I know of a paid plugin that allows this but I was hoping for someone to point me in the correct direction that's future proof and doesn't rely on plugins. Ideally I would want the attachment to be connected to the post itself so we could query all the attach... | Here is my suggestion: Just download this Comment Images plugin. As of now it only support images. But upload work with all file types. So just make a little tweak like this. So it will display attachment link. Replace line 245 from <code> $comment->comment_content .= '<img src="' . $comment_image['url'] . '" alt... | Add an attachment feature to comments | wordpress |
I want to create a "photography" custom post type which uses attachment's same edit/upload panel. Exact same panels usage for "attachment" post type but with "photography" name. Is it possible? | It seems its impossible with WordPress 3.5 at the moment. I opened an idea for it: http://wordpress.org/extend/ideas/topic/custom-attachment-type Support if you like idea please. | Custom Attachment Type | wordpress |
What is the best way create a plugin that is translation ready? It doesn't have to be translated from the beginning but it has to be easily translatable so fellow developers from different cultures can participate to the localization process of the plugin. | 1. Write with localization in mind Don't use <code> echo </code> or <code> print() </code> to produce text output, instead use the WordPress functions <code> __() </code> and <code> _e() </code> : <code> /** Not localization friendly */ echo "Welcome to my plugin"; // OR print("Welcome to my plugin"); /** Localization ... | How to make a WordPress plugin translation ready? | wordpress |
What I want : the array of posts returned by creating <code> $query = new WP_Query($args); </code> Why : to return specific content as a sort of API request in json format, ready to display on another site What I tried first : <code> foreach($query->posts as $post) { $post->post_content = apply_filters('the_conte... | There is a difference because you are not using <code> the_post </code> function in the first example. What this function does is it calls <code> setup_postdata </code> function, which sets up all the globals needed for other functions to work. You can call it manually, just at the beginning of your <code> foreach </co... | Why does apply_filters behave different inside and outside a loop? | wordpress |
I'm creating a helper class for simplifying the creation of an option page in admin that could conceivably be used in a theme, a plugin, or a mu-plugin. I'm trying to make the class as easy to instantiate as possible, so I plan on determining programmatically which of those three places the class is being instantiated ... | Unless you are working on WordPress core development you should not be writing anything but a: Theme Child Theme Plugin Mu-Plugin Drop-In For the last two see: http://hakre.wordpress.com/2010/05/01/must-use-and-drop-ins-plugins/ I am out on a limb a little bit here but I think that is the exhaustive list, with the firs... | Is there any other place - besides a theme, a plugin, or a mu-plugin - that an option page might conceivably be used? | wordpress |
I have managed to code tab system that fetches different categories and custom taxanomies on a home page and shows relative posts. Now, is it possible that when someone clicks on one of the posts in some specific tab, then the post's content can be shown in the tab itself, instead of taking the user to the single post ... | If you are using jQuery UI Tabs you can use AJAX to load the content. There is an example on the plugin page. UI Tabs is always part of a WordPress installation and registered already as <code> jquery-ui-tabs </code> . | Single Post in Tab/Slider | wordpress |
how can I create a widget out of a php code? It's just a disqus code that I would like to place in the sidebar. I could just paste the code in the widget section (my tag), but then I would not be able to change it's order with the other wigets. This is why I want to convert this code into a widget. | Here is a stand-alone answer. Building a widget to echo hard-coded PHP is trivial. <code> class PHP_Widget_wpse_80256 extends WP_Widget { function __construct() { $opts = array( 'description' => 'Display Some Hard Coded PHP content' ); parent::WP_Widget( 'my-hc-php-content', 'Some PHP', $opts ); } function widget($a... | Transform php code into a widget? | wordpress |
I got on the list to test a private beta of a plugin I'm using on a multisite network. The plugin authors have code in there to add a custom role. They have a bug that removes the ability to give a user any role except their one custom role. When I visit <code> ../wp-admin/network/site-users.php </code> , the "Add User... | User roles are stored in <code> wp_options </code> table. search for option name <code> wp_user_roles </code> in the <code> wp_options </code> table. Here is the function that adds the role in the database | Where are available Roles Defined in the wp_ database? | wordpress |
I would like to customize the layout of the admin section of WordPress. The thing is, whatever the layout I create, I'm very dependent of the default "fluid" layout of the admin. By fluid, I mean: when I resize the browser window, things tend to reorganize themselves in the admin section (in order to optimize space) an... | This is still to be confirmed but so far so good: What I did is open all the minified css related to the admin section and deleted theses parts <code> @media only screen and (max-width:xxx px){...} </code> whenever I found one. It seems to work and doesn't mess with anything else, as far as I know. Of course, this only... | Fixed layout for admin section | wordpress |
I have this code in my home.php, the very first post class does not get the class while the others do. Same thing when i move this code to functions.php. I get php errors when i remove the hook around it and just add the filter. <code> add_action('pre_get_posts', 'theme_add_post_class'); function theme_add_post_class()... | <code> function wpse80148_filter_post_class( $classes ) { if( is_home() || is_front_page() ) $classes[] = 'span4'; return $classes; } add_filter( 'post_class', 'wpse80148_filter_post_class' ); </code> | How to add a post class on every post. (on homepage) | wordpress |
I have some posts which do not have any category, by default, wordpress shows them under "Un categorized". Is there any way to stop this? I want those posts under the categories I have in metabox title (list of categories for meta tag, if I select some category, from metabox title, it should come under the selected cat... | All posts have to be associated with at least one category. It might be possible to bypass this requirement but probably doesn't worth the effort. If you really need to be able to have content without categories then you should create and use a custom post type , with which you can create and use custom taxonomies . It... | How to make posts being uncategorized | wordpress |
is there any way to change the default output when inserting a video into tinyMCE with Wordpress' default media manager. Currently it inserts it as a link, would it be possible to input it into the editor as an iFrame with all attributes intact. Thanks in advance! | Copy paste from my answer here but with iframe/video mime type added: stackexchange-url ("Alter image output in content") <code> function WPSE_80145_Mime($html, $id) { //fetching attachment by post $id $attachment = get_post($id); $mime_type = $attachment->post_mime_type; //get an valid array of video types, add any... | Make videos output as iframes not links | wordpress |
Hi Im trying to run 2 querys in the same query call. <code> // send the query global $wpdb; $commentQ = "SELECT * FROM $wpdb->comments " . $whereClause . $orderBy; $comments = $wpdb->get_results( $commentQ, ARRAY_A); </code> So far it works , but when i try to run 2 querys it fails. What I wanna do is i want to r... | If you are going to do this is SQL, use a subquery. <code> SELECT *, (SELECT meta_value FROM wp_commentmeta WHERE meta_key = 'your-meta-key' AND wp_commentmeta.comment_id = wp_comments.comment_ID LIMIT 1) as comment_author FROM wp_comments </code> Instead of the <code> * </code> , enumerate the fields you want but leav... | Wordpress SQL JOIN query | wordpress |
I have looked in here and across the internet but I can not seem to find an answer. Is there a way to change the values of the ratings. By Default it seems to be 0 to 10, but I can not find a way to modify this feature to something like 0 to 20 or something. Thanks. | See the function <code> link_advanced_meta_box() </code> in <code> wp-admin/includes/meta-boxes.php </code> : <code> <td><select name="link_rating" id="link_rating" size="1"> <?php for ( $r = 0; $r <= 10; $r++ ) { echo '<option value="' . $r . '"'; if ( isset($link->link_rating) && $link... | Change Rating range in Link Manager | wordpress |
I need your help as I am stuck and Google does not return anything, so I must be doing something obiusly wrong here, I just don't know what. Basically, I need color input in one of my custom post types meta and I am trying to use a new WordPress 3.5 colorpicker for that. I could simply find another script and use it, b... | I tried the following and it works: <code> function wpse_80236_Colorpicker(){ // you forgot this probably it's the bundled CSS wp_enqueue_style( 'wp-color-picker'); // wp_enqueue_script( 'wp-color-picker'); } add_action('admin_enqueue_scripts', 'wpse_80236_Colorpicker'); </code> Then your input: <code> <input name="... | wpColorPicker - problem with implementation to post meta | wordpress |
For each new post, I add <code> News </code> category. And I want to <code> delete this category </code> from each post after 7 days. I already know to "delete" the new category but how to run it every week ? | Did you try this plugin? http://wordpress.org/extend/plugins/scheduled-post-delete/ //// Sorry for my mistake, I understood you wrong. Try by pasting this in your functions.php: <code> function auto_cat_remove() { global $post; wp_schedule_single_event( time() + 604800, 'remove_news_cat_event', array( $post->ID ) );... | How to do some action weekly? | wordpress |
I've got this shortcode in my <code> functions.php </code> : <code> function amaranthe_buy_tickets( $atts, $content = null ) { extract(shortcode_atts(array( 'link' => '#', 'target' => '', 'variation' => '', 'size' => '', 'align' => '', ), $atts)); $style = ($variation) ? ' '.$variation. '_gradient' : '';... | It is the hyphen: Take caution when using hyphens in the name of your shortcodes. In the following instance WordPress may see the second opening shortcode as equivalent to the first (basically WordPress sees the first part before the hyphen): Rename your shortcode so the tag doesn't have a hyphen. | Shortcode content is empty | wordpress |
I've created a tiny AJAX plugin to count hits on my articles and bypass caching but it just isn't working and not throwing up any errors. Can you see what I am doing wrong here? <code> <?php add_action('wp_ajax_nopriv_LogHit_callback', 'LogHit_callback'); add_action('wp_ajax_LogHit_callback', 'LogHit_callback'); fun... | There is no PHP function <code> alert </code> , that's why your function throws an error and doesn't proceed with the rest of your code. You have to return something from the <code> LogHit_callback </code> function using <code> return </code> (or echo it with <code> echo </code> ) and then alert it with JavaScript, tha... | My AJAX API plugin isn't working | wordpress |
I'm just getting used to the WP Query and was hoping I could get some assistance on this. I've created a custom taxonomy (theme) and now want to display the latest post with one of these taxonomies on my front page as a top featured post. Now I can't really seem to work out how to get it to filter the query properly, m... | You have to use your object like this : <code> while ( $query->have_posts() ) : $query->the_post(); </code> | WP Query with custom taxonomy | wordpress |
I want to export my comments to Excel, PDF or Word. The format really doesn't matter, I just want them exported. I tried the Export Comments plugin, the standard one, but couldn't get it to work, I have to do it manually. Anyone can suggest something on this topic? | Option 1 As the article linked by stackexchange-url ("@MikeMadern") suggests: in your web host control panel, go to PHPMyAdmin select the table <code> wp_comments </code> select Export , configure the format further down in the same screen, select the Save as file and Go Option 2 Or , as the same article suggests, just... | How to export comments in WordPress? | wordpress |
I want to add a simple confirmation event to the Publish posts button, so when my client hits "Publish" it will ask him if he's sure, to which he clicks "Yes" or "cancel" and the post then publishes or doesn't. I'm new to WordPress...or at least I've only done theme and limited plugin programming. I did find the metabo... | You can hook into the post footer actions (based on stackexchange-url ("this answer"), not tested): <code> add_action( 'admin_footer-post-new.php', 'wpse_80215_script' ); add_action( 'admin_footer-post.php', 'wpse_80215_script' ); function wpse_80215_script() { if ( 'post' !== $GLOBALS['post_type'] ) return; ?> <... | How can I add a jQuery OnClick event to the Publish posts button? | wordpress |
I am trying to get all posts that belong to two or more taxonomies but I am failing... So here is the pseudo of what I have. taxonomy name = color-categories I have 6 created items under color-categories: red, blue, black, 2000, 3000, 4000 And each post will have 2 of those category combinations like (red,2000) or (blu... | Here is the way I think it should work: <code> $args = array( 'post_type' => 'item', 'post_status' => 'publish', 'posts_per_page' => -1, 'tax_query' => array( array( 'taxonomy' => 'color-categories', 'field' => 'slug', 'terms' => array('red', '2000'), 'operator' => 'AND' ) ) ); </code> So you qu... | How to WP Query custom multiple custom taxonomies? | wordpress |
I am having a very peculiar issue on a customer's server (vps). The code below works just fine on my servers. Basically, a specific unix timestamp is formatted correctly and as soon as wp_insert_post() is called, the dates adjust to GMT. For example: <code> echo "date_i18n of 1366495200: " . date_i18n('Y-m-d H:i', 1366... | If you do not pass a date to <code> wp_insert_post() </code> , <code> get_gmt_from_date() </code> is called. And look at that function’s content: <code> function get_gmt_from_date($string, $format = 'Y-m-d H:i:s') { preg_match('#([0-9]{1,4})-([0-9]{1,2})-([0-9]{1,2}) ([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2})#', $string, $... | After wp_insert_post(), date_i18n() and date() outputs are adjusted to GMT | wordpress |
I want to exclude some posts from the home page. So I want to use meta data, and filter all posts that are signed by meta_value=0. Like this: <code> $args = array( 'posts_per_page'=>28, 'meta_query' => array( array( 'key' => 'show_on_home', 'value' => '0', 'compare' => 'NOT LIKE' ) ) ); $query = new WP_Q... | WordPress 3.5 and up supports <code> EXISTS </code> and <code> NOT EXISTS </code> comparison operators. compare (string) - Operator to test. Possible values are '=', '!=', '> ', '> =', '<', '<=', 'LIKE', 'NOT LIKE', 'IN', 'NOT IN', 'BETWEEN', 'NOT BETWEEN', 'EXISTS' (only in WP > = 3.5), and 'NOT EXISTS' (also on... | How to exlude posts that have certain meta_value? | wordpress |
I'm building a store using Woocommerce and need to manage a large number of product categories. I would like to re-order them to appear in alphabetical order. However the drag and drop ordering system splits categories over several pages and I can't seem to find a way of editing the entire list rather or move items fro... | Under screen options on the Product Categories page, change the number of product categories to something big enough to get job done; drag and drop to order; change back to 20 or something manageable. | How to order categories in Woocommerce that are spread over multiple pages? | wordpress |
I'm developing a new website, but I can't quite figure out a solution to my permalinks problem. My main website is http://w3spine.com , I'm sending posts to my second WP installation at http://w3lol.com where I want posts permalinks to be consistent numbers like w3lol.com/50, w3lol.com/51, w3lol.com/52, etc. I cannot u... | I don't really have the time or will to write and debug the code to make this work, but I can point you down a path to how you might make this work. A word of warning: it's certainly not simple. You have to save the current number somewhere so you can retrieve and increment it every time a post is added, I would do thi... | Making posts permalinks consistent numbers | wordpress |
I want to make the default WordPress behave better. For instance, if I add categories such as: "best products", "good products" and more then the search should be able to account for those and return them higher in the results. I know there are some plugins which can improve the search query like to be able to search t... | You are really asking two questions: "How do I make the internal search work better?" and "How do I change the search form to give it more advanced functionality?" To change the behavior of the search I would say Relevanssi is the best plugin if you are trying to improve the "native" WordPress search behavior. The free... | Improved WordPress search functionality and search form plugin | wordpress |
I would like the comments of a post and the comment box to appear in the sidebar. How can I do that? | Yes, this is possible and actually a nice idea. Basically create a simple widget, and remove the calls to <code> comments_template() </code> from other parts of your theme. Example: <code> add_action( 'widgets_init', array ( 'T5_Current_Comments_Widget', 'register' ) ); class T5_Current_Comments_Widget extends WP_Widge... | Integrate comment system in the sidebar? | wordpress |
So I don't really know why I am having so much trouble with this, it seems like functionality in wordpress that should be a bit easier to working with. Anyhow I need to generate a menu system for a sidebar that looks like this (for a top level page): <code> <ul> <li><a>Sub-Page</a></li> &l... | So it turns out to be a bit easier than I thought: <code> <?php if ($post->post_parent) { $ancestors=get_post_ancestors($post->ID); $root=count($ancestors)-1; $parent = $ancestors[$root]; } else { $parent = $post->ID; } ?> <?php $args = array( 'depth' => 0, 'date_format' => get_option('date_form... | Listing Sub-Pages & Sub-Sub-Pages | wordpress |
I have built a plugin that displays a table using the WP_List_Table class. The table displays entries on which it's possible to apply a filter and some bulk actions. The problem is that is that when I click on the "filter" button or "apply bulk action" button multiple times, the _wp_http_referer paramater is added to t... | As the last commenter on that Q suggested, you should probably check for actions, remove the query args and redirect. Something like: <code> $doaction = $wp_list_table->current_action(); if ( $doaction && isset( $_REQUEST['SOMEVAR'] ) ) { // do stuff } elseif ( ! empty( $_GET['_wp_http_referer'] ) ) { wp_red... | How to remove _wp_http_referer from URL when husing WP_List_table? | wordpress |
I have some code that display's the titles of my child category posts on one of my pages: <code> <?php $parent = get_cat_ID("photos"); $cats = get_categories('child_of='.$parent); foreach ($cats as $cat) { echo "<ul>"; echo sprintf("<li><a href='%s'>%s</a></li>", get_category_link($cat-... | You can get a random post by category by using the following code: <code> query_posts( array ( 'showposts' => 1, 'orderby' => 'rand', 'cat' => $cat->term_id ) ); if ( have_posts() ) : while ( have_posts() ) : the_post(); ... </code> And then use get_the_post_thumbnail() to retrieve the post featured image: ... | Child Category Image | wordpress |
I have a fresh install of Wordpress 3.5 and WooCommerce 1.6.6 (WC from now on) and use the default Twenty Twelve theme. I added a Product to WC and when viewing that product and using the Debug Bar Template Trace plug-in I can see that the template <code> woocommerce/templates/single-product.php </code> is used. Howeve... | Comparing the markup generated by <code> page.php </code> when the cart is displayed, it seems that the content is generated by <code> cart.php </code> , similarly to loading a template part , so <code> cart.php </code> is actually used whenever the cart is displayed. | How is WooCommerce cart.php template supposed to be used? | wordpress |
I want to use the edit-tags.php search function with multiple term id's. For example, if i type into the searchbox something like this: #1245&6832, it should display these two terms in the results table(WP_Terms_List_Table). I tried to use the pre_get_posts action to get access to the query that is running for the ... | It's easy to implement. All you need is your own hook for <code> get_terms_args </code> filter: <code> add_filter( 'get_terms_args', 'wpse8170_get_terms_args', 10, 2 ); function wpse8170_get_terms_args( $args, $taxonomies ) { if ( !in_array( 'post_tag', $taxonomies ) ) { return $args; } $matches = array(); if ( empty( ... | Filter taxonomy terms using multiple id in the edit-tags.php | wordpress |
I have Wordpress installed in my root directory, so if you go to site.com you see the list of recent posts. What I want to do is to have the homepage show a static page instead showing recent news etc (I've figured out how to do this), however if someone goes to site.com/blog/, I want to show a list of the recent posts... | Create a simple page which is needed to be the homepage and another page on which you want to show your recent blog posts. Then go to Settings > reading and set <code> a static page </code> option in front page displays option. Then for the front page select box, select the new homepage and for the post page select box... | How to show the homepage on a different url, like site.com/blog instead of site.com? | wordpress |
To all newcommers the WP3.5 show the floating hint about new abilities of 3.5 version placed on top left coner of screen saying: We’ve combined the admin bar and the old Dashboard header into one persistent toolbar. Hover over the toolbar items to see what’s new. {close} after close-click the hint disapeare... | Dismissed pointers are stored as user meta, you can inspect this for yourself with: <code> $meta = get_user_meta( wp_get_current_user() ); print_r( $meta['dismissed_wp_pointers'] ); </code> In your case, the meta might be empty or damaged, to update dismissed pointers for ALL users on your blog, you could run this func... | How WP decide to show or not to show in admin panel the pop-up window with hint? Need a fix | wordpress |
I know similar questions have been asked dozens of times but I'm just not understanding how to display custom fields. I'm using woocommerce and want to display a custom field value on product pages. I add the custom field "current_promotions" and a value to a product, and have tried adding this to the content-product.p... | This should do it <code> <?php echo get_post_meta( get_the_ID(), 'current_promotions', true ); ?> </code> | Display custom field value on woocommerce product page | wordpress |
I have seen many snippets to display random post/posts on a page. Most of them provide a function or wp_query code to be directly placed where it is required. In the end they tell to create a template random.php and page with name RANDOM. So, when one wants to access that page, they can look for a link pointing as http... | What you are asking is how to redirect the visitor to a random post. Here you go: <code> <?php /* * Template Name: Random Redirect */ query_posts( array( 'showposts' => 1, 'orderby' => 'rand', ) ); if (have_posts()) : while (have_posts()) : the_post(); header( 'Location: ' . get_the_permalink() , false , 303 )... | Display random post on a page with post permalink in URL | wordpress |
I recently created a site and installed Jetpack and activated it, but it gives me the following error: Jetpack could not contact WordPress.com: register_http_request_failed. This usually means something is incorrectly configured on your web host. Failed to connect to 76.74.254.123: Permission denied | I was receiving an error similar to this on one of my past sites. Turned out that my host was blocking XML-RPC requests to remote servers. My solution: switch hosts (unless you're running on a VPS where you can configure your server). | Jetpack could not contact wordpress | wordpress |
This seems like it should be something that's really simple to do, however it's apparently not. I don't want tags to be links, but I want them to display in an unordered list, with each tag inside an <code> <li> </code> get_the_tags allows you to echo them without the associated link, but I have no idea how to wr... | This would do it... <code> <?php $posttags = get_the_tags(); if ($posttags) { foreach($posttags as $tag) { echo '<li>' .$tag->name. '</li>'; } } ?> </code> | Display tags in list without link | wordpress |
I have this JS function named as "myjsfunction()". <code> function myjsfunction() { jQuery('#html_admin_show').hide(); jQuery('#html_admin_edit').show(); } </code> One limitation is that I cannot edit the original JS function like to put some PHP tags, etc. How is it possible to call this JS function inside a Wordpress... | First, your callback must be PHP: <code> function myjsfunction_callback() { ?> <script>myjsfunction();</script> <?php } </code> Second, you can add multiple callbacks to one action: <code> add_action( 'myhelp', 'myjsfunction_callback' ); add_action( 'myhelp', 'mysecondfunction' ); </code> Now, you can... | Adding JS function as third parameter in do_action | wordpress |
I've seen a few questions similar to this but I can't find a solution to the issue I have. <code> <?php add_action('wp_ajax_nopriv_LogHit_callback', 'LogHit_callback'); add_action('wp_ajax_LogHit_callback', 'LogHit_callback'); function HitCount() { ?> <script type="text/javascript" > jQuery(document).ready(... | You are making a new request to the server and you appear to be loading a page that is not loading WordPress core functions. I'd need to see your <code> HitCount.php </code> to confirm this but I can't think of another explanation. Loading WordPRess files piecemeal is tricky and prone to breakage as core code changes. ... | I can't access wordpress functions from an ajax php call | wordpress |
I have a wordpress site, I downloaded it from live and configured it on local using xampp. When i click on any post, it redirects me to <code> localhost/xampp </code> instead of post page my .htaccess is like <code> <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteRule ^index\.php$ - [L] RewriteCond... | Your rewrite rule is wrong. The existing rule is for when the site is at root-- <code> http://localhost </code> . You site is at <code> http://localhost/highimpact </code> . The final rewrite rule should, I believe, <code> RewriteRule . /highimpact/index.php [L] </code> . If you go to wp-admin-> Permalinks, and save th... | Posts are being redirected to xampp home page | wordpress |
I'm looking to create a dropdown in the post edit screen which contains 3 already existing tags. What's the easiest way of doing this? Basically all I'm looking for is a simple drop down which adds one of the following tags to the post itself; 'beef-stew', 'pea-soup' & 'chili'. I'd also like 'beef-stew' to be the d... | I followed this handy guide and it worked a treat: http://shibashake.com/wordpress-theme/wordpress-custom-taxonomy-input-panels | Create custom taxonomy and Display in metabox dropdown | wordpress |
I am using wp 3.5 i have a custom post <code> (sp_product) </code> and also i have custom taxonomy. I want to remove that custom taxonomy filter column but i don't want to make <code> 'show_admin_column' => false </code> . I wanna unset from <code> $columns[''] </code> . How should i do that ? i also want to add som... | <code> function wpse_80027_manage_columns($columns) { // remove taxonomy column unset($columns['YOUR_TAXONOMY_NAME']); // add your custom column $columns['CUSTOM_COLUMN_NAME'] = __('Column Name'); return $columns; } add_filter('manage_edit-sp_product_columns', 'wpse_80027_manage_columns'); function wpse_80027_add_img_c... | Remove custom taxonomy column from my custom post type columns | wordpress |
I'm constantly reading stuff on the wordpress forum where people are making all mannar of customizations by modifying php or css files using the file editor. But aren't all those files generated? Don't these files get reverted when a change is made to the website through the wp-admin console or when wordpress updates? | Updates run for themes and plugins only if there is a registered update server. If you have a custom (child) theme, or a plugin not hosted on wordpress.org and without a custom update mechanism there will be no updates. In all other cases: Yes, you are right, the changes could be overwritten. But this is not the only p... | Is it safe to use the file editor to make customizations? | wordpress |
I have a function in a parent theme: <code> function cyberchimps_logo_icons() { ?> <header id="cc-header" class="row-fluid"> <div class="span7"> <?php if (function_exists('cyberchimps_header_logo') ) { cyberchimps_header_logo(); } ?> </div> <div id="register" class="span5"> <?php if ... | On the init action, remove the action calling their function and enqueue an action calling your (differently named) function, like this: <code> add_action('init', 'wpse_80107_init'); function wpse_80107_init() { // remove parent theme's header content action remove_action('cyberchimps_header_content', 'cyberchimps_logo... | How can I change a function in a parent theme via a child themes functions.php | wordpress |
I have recently decided to step into WordPress but I am needing to create a few themes for eCommerce that are currently built in Open Cart. My experience from eCommerce comes from Open Cart but I am completely new to using one for WordPress. After a few months of research I decided I would like to try and create my own... | WooCommerce is an e-commerce plugin and although it offers a great deal of filter hooks, function calls and theme support it's not technically a theme framework. Generally speaking WooCommerce will work with just about any theme right out of the box. But it does support customizing it's own pages/layout by copying it's... | Making custom woo themes | wordpress |
In Wordpress, when creating a page, it shows some options for Template under Attributes, such as: Default, Links, One column no sidebar, etc. Is there a way to add more custom templates to show up here? If so, how? | All you need to do is just create a new file in your theme root directory. This file must start with following code: <code> <?php /** * Template Name: No Sidebars */ </code> Name your file, for example, <code> page_nosidebars.php </code> and then WP will add <code> No Sidebars </code> template to available templates... | How to create a template for Pages? | wordpress |
When using WordPress Multisite with many sites, it would be nice to store them into categories. Site categories that is, not post categories. Maybe there is a way to use some kind of site meta / custom fields for sites? Is there one? How to use it? A plugin would be nice, or an example of a start, what hooks / function... | Answering to this Question, stackexchange-url ("Multisite: How to add Custom Blog Options to new blog setup form?"), I ended up doing a plugin that does exactly that: adds a blog meta field to give each site a Category. It's a simple meta field, meaning: no category tree. I just revised the code and updated. Available ... | How to structure Multisite sites into categories? | wordpress |
I've created a custom post type, <code> Local Pages </code> and two different taxonomies: <code> Locations </code> and <code> Services </code> . As of now, the custom post type works. However the urls are not pretty. They look something like: <code> http://domain.com/?localpage=%post_name% </code> Ideally, I'd like to ... | To achieve permalinks like <code> http://example.com/localpage/%post_name%/ </code> , you will need to set the <code> rewrite </code> argument when registering the custom post type: <code> $annoucement_args = array( ... 'rewrite' => array( 'with_front' => false ), ... ); </code> I don't think that using custom ta... | Creating custom post type and taxonomy archives and pretty URLs | wordpress |
I'm working on a WordPress project set up with MAMP on localhost. I try testing the site on internet explorer with VirtualBoxVM by browsing to my local ip. My problem is, wp_head() outputs absolute path's to css and js resources, so the VirtualBoxVM Browser tries to load http://localhost:[port]/wp-content/themes/twenty... | If I understand you, don't use 'localhost'. That only works if you are testing from the same machine that is running the server. (A virtualized machine counts as a different machine.) Give your server (the machine running the server) a static IP address-- something like 192.168.1.5-- and use that instead of 'localhost'... | How do I test my localhost WordPress project with VirtualBoxVM? | wordpress |
Is it possible to hook into the default Recent Comments widget to enable it to display comments for attachment posts? If so, how? | you can use the <code> widget_comments_args </code> filter to modify the default args of the recent comments widget: <code> function wpse80087_widget_comments_args( $args ) { $args = array( 'number' => 5, 'post_type' => 'attachment', 'status' => 'approve', 'post_status' => 'inherit' ); return $args; } add_f... | Enable Recent Comments widget to display comments on attachment posts | wordpress |
I use the wp for membership site. I use pages for the user log in, manage post, edit profile and etc. When I apply the default permalink structure, I found that the debug mode show this notice on every pages (not post page). <code> Notice: Undefined property: WP_Query::$post in /var/www/example/wp-includes/query.php on... | Finally I found what causing this problem, turns out it have to do with my pre_get_post hook. Because I using is_page to check the specific page, which is not appropriate. Here is what I did <code> function check_page($wp_query){ if($wp_query->is_page(array('1','2','3')) ){ //do something here } return $wp_query; } ... | Default permalink structure causing Notice: Undefined property: WP_Query::$post | wordpress |
I can not get colorbox fully loaded. I am trying to add color box to use in my plugin admin. I do not need it for the front end. I can get the css but can not get jquery.colorbox-min.js or the inline script to load in the <code> <head> </code> . Here is what I have: <code> /*--------------------------------------... | For the admin side, the two actions you want are <code> admin_enqueue_scripts </code> and <code> admin_head-(plugin_page) </code> . <code> wp_enqueue_scripts </code> and <code> wp_head </code> are only for the front end. | colorbox not loading in | wordpress |
I have a question. I need to have, in my archive.php file, a exclusion of a specific category. given what I have now, how would I make that happen? Here is the code: <code> <?php query_posts(array( 'post_type' => 'post', 'showposts' => 5 ) ); ?> <?php while (have_posts()) : the_post(); ?> <div clas... | You can add <code> category id </code> or <code> category slug </code> into arguments you are passing to <code> query_posts </code> : <code> <?php // category slug ('products') query_posts(array( 'post_type' => 'post', 'showposts' => 5, 'category_name' => 'products' ) ); ?> </code> or <code> <?php // ... | How do I remove a category from a wordpress loop> | wordpress |
I am currently in the process of building a responsive real estate WordPress theme and I'm figuring out how to properly add support for HiDPI screens. I decided to use a JavaScript solution Picturefill , which mimics the functionality of proposed picture HTML element . WordPress lets us create custom image sizes, and I... | I hadn't done this myself but I have How to insert image in Markdown syntax in WordPress stashed for later that shows how to customize markup of inserted image. It makes use of <code> image_send_to_editor </code> filter in get_image_send_to_editor() function. | Retina images - custom syntax for inserting images into post content | wordpress |
I am trying to augment a value to the <code> wp_user_meta </code> table, utilizing Gravity Forms. And I'm not having any luck. I had a version of this working on <code> gform_pre_submission </code> (though without the class-sniffing) but I want to do this after submission since there will be PayPal involved and don't w... | It looks like your code is testing to see where every field on the form has class 'payment_name'. If you instead only want to find one field with class 'payment_name', then you need to break out of the for loop once you've found that field. Also, strpos only returns <code> false </code> or an integer index into the hay... | gform_after_submission not working as expected | wordpress |
I am adding menu items with the code below, the menu items show up when clicked but they give damaged url's e.g for the top link when clicked <code> http://timothylhanson.com/bp/%3C?php%20return%20bp_loggedin_user_domain()%20?%3Eactivity/just-me/ </code> clearly this <code> <?php return bp_loggedin_user_domain() ?&g... | Your <code> <?php return bp_loggedin_user_domain() ?> </code> is part of a string therefor it is not executed. You should probably have <code> '<li class="myclass"><a href="'. bp_loggedin_user_domain() .'activity/just-me/">My Wall</a> ... </code> | Menu item added with "wp_nav_menu_items" gives "damaged" url | wordpress |
<code> meta_key=_jsFeaturedPost </code> <code> meta_value=yes </code> I have posts where some have meta keys/values and some don't. I would like to target the ones with the meta keys that have a value of 'yes' and add a CSS class to those posts so I can style them differently. Ideally, something like: if meta_value for... | The <code> post_class </code> filter is your friend. Just combine it with <code> get_post_meta() </code> . <code> function wpse80098_filter_post_class( $classes ) { global $post; if ( 'yes' == get_post_meta( $post->ID, '_jsFeaturedPost', true ) ) { $classes[] = 'my-custom-css-class'; } return $classes; } add_filter(... | If meta_value = 'yes', then add class? | wordpress |
I'm just trying to turn off the wp admin bar on one page, but this function removes it from every page. What am I missing? <code> <?php if ( !is_page('image-upload') ): show_admin_bar(false); endif; ?> </code> | You need to remove the (!) infront of the conditional, you can read about PHP-operators here . Now you simply say that if not on page "image-upload" remove the admin_bar.. Here is the working code: <code> <?php function wpse_80018_hide_admin_bar() { // If is on page "image-upload" // Remove the admin_bar if ( is_pag... | What is wrong with this code to remove wp admin bar from one page | wordpress |
On my homepage I am using a code to call different post type labels. Example: TV Series: "Once Upon A Time" Here is the code I use to call the label: <code> <a href="<?php echo get_post_type( $post->ID ); ?>"> <?php $post_type = get_post_type_object( get_post_type( $post ) ); echo $post_type->label... | You can do something like this: <code> <a href="<?php echo get_post_type( $post->ID ); ?>" class="<?php echo str_replace(' ', '-', get_post_type( $post->ID )); ?>"> <?php $post_type = get_post_type_object( get_post_type($post) ); echo $post_type->label ; ?> </a> </code> and in you... | Give each post type label a different color? | wordpress |
I'm thinking to use Contact Form 7 to create a simple enquiry form like : name, phone, email. This enquiry form will be displayed on every portfolio page. What I want to do is to retrieve also from the user the page title from where he submitted the enquiry, because I will have more than 50 posts and I don't want to cr... | Add a hidden field to the form like this: <code> <input type="hidden" name="page_title" value="<?php the_title_attribute(); ?>" /> </code> This will send the current posts’s title. | dynamic enquiry form | wordpress |
I used remove_shortcode('gallery'); ...the gallery is gone, but the shortcode is visible in the text. How do I remove sitewide? I've searched for sql queries, but no solution fixes my specific problem. | The short code is actually entered into then page or post content so disabling the short code processing prevents the gallery short code from being replaced with the gallery images but it doesn't affect the post content. The best solution is to add a new short code handler after removing the default gallery handles. An... | Remove [gallery] shortcode altogether | wordpress |
I am using <code> FORCE_SSL_ADMIN </code> in <code> wp-config.php </code> so everytime I upload a new image and inserted into the post, it is using SSL version e.g. <code> <img src="https://www.example.com/wp-content/uploads/2013/01/test.png" .. </code> My blog is using HTTP in the public side, so how to make the up... | You can define a function to remove the protocol and hook it to the attachment URL: <code> function wpse_79958_remove_protocol_from_attachment($url) { $url = str_replace(array('http:', 'https:'), '', $url); return $url; } add_filter( 'attachment_link', 'wpse_79958_remove_protocol_from_attachment' ); </code> Also consid... | How to make WordPress use protocol indepentent upload files? | wordpress |
Is it possible to sort product categories? I have a category with a lot of subcategories. On the category page all the subcategories is listed. Right now I can only change the order by drag and drop in the admin panel. But that is very time consuming with a lot of categories. Any way to change the order without using d... | Woocommerce stores 'order' metakeys in the table wp_woocommerce_termmeta. The mechanism it uses is the same as 'menu_order' for posts. Something like this should work: <code> $terms = get_terms('product_cat'); //sort $terms somehow $i = -1; foreach ($terms as $term) { $i++; update_woocommerce_term_meta( $term->id, '... | Woocommerce product categories order | wordpress |
I'm trying to feed checkbox values from a Gravity Forms form (which creates a new post) into an Advanced Custom Fields field. I've had a read around and found some info in a post (at the bottom of the question). Is this the correct way to do it? It's not inserting the multiple GF checkboxes into the ACF textbox. Should... | My situation to tackle this problem was a bit problematic because I wanted to use the GF Update Post plugin to let my users edit their post right after they submitted the content. With the above solution ACF does not write to the db and correct ACF fields (at least not for me). My solution: Create a ACF custom field gr... | Inserting Gravity Form checkbox values into Advanced Custom Fields | wordpress |
I am trying to return all posts that meet the following conditions: The category must be 63 OR the post must have a value associated with the meta key named 'android_link' My current argument array currently does not work because it is asking for both of these conditions to be met. Is it possible to change it so that o... | You can run two queries and merge the results: <code> $cat_query_args = array( 'paged' => $paged, 'order' => 'DESC', 'meta_key' => 'android_link', 'post_type' => array( 'post', 'app' ), 'cat' => '63', ); $meta_query_args = array( 'meta_query' => array( array( 'key' => 'android_link', 'compare' =>... | Implementing an OR statement to wordpress wp_query | wordpress |
If I configure <code> wp_nav_menu </code> function, I can put the "items_wrap" option to achieve a nice navigation given by Twitter Bootstrap, thus: <code> <ul class="nav nav-pills">%3$s</ul> </code> . But, how to configure the custom menu widget to do the same? I mean, for achieve <code> <ul class="nav ... | Filter <code> 'wp_nav_menu_args' </code> . <code> add_filter( 'wp_nav_menu_args', 'wpse_79901_nav_menu' ); function wpse_79901_nav_menu( $args ) { $args['items_wrap'] = '<ul class="nav nav-pills">%3$s</ul>'; return $args; } </code> | Make compatible custom menu widget for Twitter Bootstrap | wordpress |
I am somewhat familiar with the concept of packages in Java, but I'm new to Wordpress and PHP. In a template file such as <code> header.php </code> , what is happening when you include the <code> @package </code> notation? <code> <?php /* * @package MyTheme */ </code> | Those are PHPDoc tags. They are entirely for code documentation purposes. | What difference does it make including the @package annotation or not? | wordpress |
I have this issue ive been stuck with now. Its when i load a page that have a feed. I put the feed in wp-admin , this usually work with other feeds but not sure why its not working with this kind of feed. When i load the feed i get this error: [function.file-get-contents]: failed to open stream: Redirection limit reach... | The problem is most likely with the address you are trying to fetch, and it is extremely unlikely it relates directly to your code. You should check what url is being passed to file_get_contents to make sure it is the one you actually tried in the browser. If they are the same, it might relate to to other server doing ... | Aspx/Rss feed - failed to open stream: Redirection limit reached | wordpress |
Is this possible? I want to use Gravity Forms or another hook to somehow write to the END of a user_meta field - not overwrite it. For example... Before: <code> $purchase_history = get_the_author_meta('purchase_history', $user->ID); echo $purchase_history; ('Concert in the Park 01/12/2004') </code> After: <code> ech... | Use <code> get_user_meta() </code> : <code> $original = get_user_meta( $user->ID, 'purchase_history', TRUE ); echo $original . ' Pancake Breakfast 05/15/2005'; </code> To update the value use <code> update_user_meta() </code> : <code> update_user_meta( $user->ID, 'purchase_history', $original . 'Pancake Breakfast... | How to add to a user_meta field (append) | wordpress |
I've been going Bananas with this problem for hours trying to figure out what is wrong. I have this code, simple enough and used in a similar manner many times before: <code> <?php // Get the field: on_the_map $mb->the_field('date_calendar_item_not_available'); ?> <input type="hidden" id="date_calendar_item... | All I can say is when strange, WTF, moments happen like this, check your white-space or more appropriately 'delete' it. There was obviously a ASCII char that I couldn't see mucking the whole thing. | Strange problem with HIdden Input field and WPAlchemy | wordpress |
I have an array of image id's and i want assign them to the specific post: <code> foreach ($image_ids as $image_id) var_dump(wp_insert_post(array('ID' => $image_id, 'post_parent' => $new_post_id), TRUE)); </code> But there occurs error: <code> object(WP_Error)#252 (2) { ["errors"]=> array(1) { ["empty_content"... | Use <code> wp_update_post() </code> , not <code> insert </code> . <code> wp_update_post( array( 'ID' => $image_id, 'post_parent' => $new_post_id ) ); </code> | How to update post parent? | wordpress |
I am developing one project and in this project i have to display many photos albums related to each category name. Particular. <code> Photos [Custom page.Redirect to next sub-category with name {personal} ] sub-category Personal Photos sub-category Professional Photos ........ </code> I want all of content that i desc... | To keep it simple and unique I would use a custom post type combined with a custom taxonomy called "Photos". Registering a custom post type allows you to customize what the input is and the dashboard, along with making it easier to work with code wise, since it is separate from the default "posts". You can find a refer... | How to display many photo albums related to category | wordpress |
I have over 1500 posts I imported from Tumblr. While the images were imported into the gallery, I need to make sure there's a featured image for each. How do I make the images (12 per post minus 30 that don't have images) a featured image automatically? | You can run a script that will programmatically set the featured image for each post. You can use the first attached image for this. To get the attached images run a query for the posts and loop through each one and use get_children() setting the post_parent to the current post id in your loop. <code> $posts = get_post... | How to select featured images for 1500 posts? | wordpress |
I realize that this also pertains to PHP and MySQL in general, but the context and operation is within WordPress. Introduction I am currently developing a plugin that creates and saves data about exercises: It essentially lets me create workouts (select exercises and details about them), which are stored either as meta... | Custom table(s). WordPress posts are not structurally a fit for what you are doing. Trying to use them for this will result in a lot of unnecessary data processing and storage. But you need to think through your own database design and you need to be good with SQL or you will end up inefficient anyway. I am not convinc... | Handling large N data in WordPress | wordpress |
I've seen this convention pretty much everywhere, and, at times, it comes close to driving me nuts: <code> <?php //The loop ?> <?php while ( have_posts() ) : the_post(); ?> <?php the_content(); ?> <?php endwhile; // end of the loop. ?> </code> Where the <code> <?php </code> and closing <code>... | This is not recommended in any WordPress style guide, and I think it is a bad coding style. Beginners are using this style, maybe because it feels more like HTML … Unfortunately, the default themes are using this style way too often, so some beginners might think it is part of a code style. One disadvantage of this sty... | Why have on every line | wordpress |
Could someone please give me the Wordpress default navigation output, i've searched it around but havn't found it. I would like the example navigation to also include one sub-menu link. Or if someone could point me out to a link where i could find information about this and customizing, thanks. | wp_nav_menu is what you are looking for. Here are some examples . Using the depth parameter you can change the level of sub-menu. 0 leads to all levels. Ex. <code> <?php $defaults = array( 'theme_location' => '', 'menu' => '', 'container' => 'div', 'container_class' => '', 'container_id' => '', 'menu_... | Wordpress Navigation default output | wordpress |
This is my first wordpress plugin and I'm running a lot of trouble making it work, it almost work fine but I don't find a way to accomplish this specific thing. Basically I've my custom setting page for my plugin, it saves all with no trouble at all, but the question its, how can I can my other button (inside the same ... | You need a second <code> form </code> with <code> admin_url('admin-post.php') </code> as form action. Then you can hook into <code> admin_post_custom_action </code> to execute your action. Sample code: <code> add_action( 'admin_post_wpse_79898', 'wpse_79898_test' ); function wpse_79898_test() { if ( isset ( $_GET['test... | Trigger custom action when setting button pressed | wordpress |
Hi all I am newbie I need to know how to alert email or message while attempt login if success or if failure .That alert mail describe that login IP and date and time . Is it possible to do this following in wordpress. Thanks In Advance. | Successful log-ins trigger the action <code> wp_login </code> , failures <code> wp_login_failed </code> . Phone calls are not built-in, you need a separate plugin for that. Example with email: <code> add_action( 'wp_login_failed', 'wpse_79917_login_failed' ); add_action( 'wp_login', 'wpse_79917_login_success', 10, 2 );... | Alert Message through email or phone(Message) | wordpress |
I'm creating a front end posting form using <code> wp_insert_post </code> that asks a user for three basic fields: their first and last name and their email address. If the user is logged in I pre-populate the text fields and ignore them when submitting a form. If however the user is not logged in, my function checks t... | The header problem is actually this problem: Warning: mysql_real_escape_string() expects parameter 1 to be string, object given in /home/wp-includes/wp-db.php on line 885 Warning: mysql_real_escape_string() expects parameter 1 to be string, object given in /home/wp-includes/wp-db.php on line 885 You are getting those e... | How to use `wp_insert_user` & `wp_insert_post` simultaneously without `headers already sent` error? | wordpress |
How can I wrap the "show_post_count" between a div? (from the wp_get_archives()) Do I need to edit the function for that? Or could I do something like this with pseudo css? <code> <div class="post_count"> <a href="http://www.finsens.salescaredev.nl/2012/03" title="March 2012">March 2012</a>&nbsp;(... | You can style the post count differently via CSS with the given markup. It’s not very practical but by making use of the cascading nature of CSS, you could do this: <code> .post_count { /* styles for the post count number in parenthesis */ } .post_count a { /* styles for the link, be sure to override properties from th... | Wrap the "show_post_count" between div | wordpress |
In my plugin, I would like to add two buttons to Media Manager (to the left of "Insert Into Post" in "media-toolbar-primary" section), and connect a jQuery action to it. First one - The "Select All" button shoud allow to select all availabe images (only images), depending on option value selected (eg. All Media Items, ... | This block of code will add a button right next to the "Insert into post" one. When clicked, it will send selected images to WP editor, each wrapped inside your template HTML: <code> var wpMediaFramePost = wp.media.view.MediaFrame.Post; wp.media.view.MediaFrame.Post = wpMediaFramePost.extend( { mainInsertToolbar: funct... | Wordpress 3.5 Media Manager - add a button | wordpress |
I'm taking my first foray into plugin development and have got confused pretty quickly. I'm attempting to make a simple plugin that stores hex colours against terms, so you can assign a colour to a tag or category and then use that in a theme. What I cant figure out is how to get the term_id of a newly created or edite... | Use the action <code> created_term </code> . Its first parameter is the <code> $term_id </code> . It is called in <code> wp_insert_term() </code> in <code> wp-includes/taxonomy.php </code> after a term was successful created: <code> do_action("created_term", $term_id, $tt_id, $taxonomy); do_action("created_$taxonomy", ... | Getting term_id for newly created or edited term | wordpress |
Is there a way to know the total number of posts before the loop starts? I'm thinking in use two loops. The first will do the counting, while the second one will handle the content. However, I don't think this approach is 'elegant'. Any other solutions? | functions.php: <code> function wpse8170_get_posts_count() { global $wp_query; return $wp_query->post_count; } </code> index.php: <code> if (have_posts()) : echo '<h1>' . wpse8170_get_posts_count() . ' Posts Found</h1>'; while ( have_posts() ) : the_post(); //... endwhile; endif; </code> | Knowing the total number of posts before to get into the loop | wordpress |
When I wish my filter or action hook to override all others, I will assign it a priority of <code> 999 </code> . However, lately I have been seeing some people use extreme values for the priority, such as <code> 20000 </code> , and even <code> 99999 </code> Besides the fact that using priorities this high is ridiculous... | There are no limits and no performance penalties. To understand why, you need to understand how all hooks are stored in the WP ecosystem. First of all you need to understand where all hooks are stored and how they do it. All hooks for filters and actions are stored in global variable called <code> wp_filter </code> , y... | Is there a limit to hook priority? | wordpress |
A client of mine has been having trouble placing images on a page of her WordPress site. The page is to have an image (left aligned) with some text on the right, then another image with some text on the right, etc. Unfortunately when the text is shorter than its image, the following image is placed to the right of the ... | Here's the code to be added to <code> functions.php </code> . As a bonus I've included a shortcode for a horizontal rule <code> <hr> </code> : <code> function shortcode_hr() { return '<hr>'; } function shortcode_clearfix() { return '<div style="display: block; visibility: hidden; clear: both; height: 0;"... | Clearfix Shortcode | wordpress |
I am working on creating a plugin to help me with future development projects. I want to make sure what I am using best practices when I write it. My question is about the use of get_option in my plugin. I have setup an options page for the plugin and have set a couple options there. Is it better to check the option on... | Both ways are almost equal, the first will be slightly faster, because the callback is called only if the check equals to <code> TRUE </code> . Note you cannot test an option like this, unless the option name is really <code> 'my_option[option_1]' </code> . What you probably want is: <code> if ( $test = get_option('my_... | Where should I use get_option in a plugin | wordpress |
How can I trigger a message box to appear on the login form? I'l trying to get the little yellow notice bar to appear above the login form conditionally. The below code only print the content on the page (duh, I know). <code> add_action('login_head', 'login_form_message'); function login_form_message() { echo 'Custom L... | There's a filter to add messages there. You can sneak in messages that will than handled like an error message (without being one). <code> apply_filters( 'login_message', $message ); </code> Here's an example of this filter: <code> function wpse79920_login_msg( $message ) { return 'Hello User!'; } add_filter( 'login_me... | How to trigger a login form notice message? | wordpress |
A client site has been barred from using Paypal, so their WP-e-Commerce catalog/cart now has to use manual EFT bank payments to accept money from customers. A customer receives this banking information in their order confirmation email. When a customer makes an EFT payment through their bank website, they have the oppo... | In the wp-e-commerce admin, Settings -> Store -> Admin, you can customise the Customer Purchase Receipt (confirmation email) template to add this, e.g. <code> Please quote %purchase_id% as reference when paying by EFT. </code> There are a couple of hooks in wp-e-commerce that let you insert other data into the confirma... | insert order number into wp ecommerce order confirmation email | wordpress |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.