question stringlengths 0 34.8k | answer stringlengths 0 28.3k | title stringlengths 7 150 | forum_tag stringclasses 12
values |
|---|---|---|---|
I'm trying to add a column to display the post_id from the wp_postmeta table. I would like to display it in the admin posts list. Here is my code: <code> add_filter( 'manage_edit-movie_reviews_columns', 'my_columns' ); function my_columns ( $columns ) { global $post; $columns['id'] = 'ID'; return $columns; } add_action... | You haven't set <code> $post_id </code> so there is no reason is should display. If you have debugging enabled as you should when you are working, you would have spotted the error immediately. What you need to do is: <code> add_action( 'manage_posts_custom_column', 'populate_columns' ); function populate_columns( $colu... | How do I create a post_id column, for admin posts list? | wordpress |
I just moved my WordPress website to a new domain & server. Everything seems to work fine except for installing new plugins. When I'm trying to install a new plugin, it's still trying to access the upload directory of the old server. The error I get is: <code> Warning: touch() [function.touch]: Unable to create fil... | In <code> wp-config.php </code> under the different salts there was a line, which I missed because it was directly under the different salts. <code> define('WP_TEMP_DIR', '/home/oldserver/domains/olddomain.be/public_html/website/wp-content/uploads'); </code> Obviously that needed to be changed to the new server path as... | Plugins try to install in old location | wordpress |
So I am using the customizer in my theme which have tabs in the page utilizing jQuery UI Tabs. When I load up the customizer, it would the sidebar accordion would be sluggish and the preview page would duplicate the content and the tabs would not render correctly. This is very strange and it does not produce this issue... | It turns out this is indeed a bug. http://core.trac.wordpress.org/ticket/23225 | Issue with WordPress native theme customizer function and jquery ui tabs | wordpress |
I'm display a dropdown list of custom post types in wordpress. This first block of code uses WP_Query <code> $houseQuery = new WP_Query( array( 'post_type' => 'house', 'order' => 'ASC', 'post_status' => 'publish', 'orderby' => 'title', 'nopaging' => true, 'tax_query' => array( array( 'taxonomy' => ... | Amusingly, the codex for wp_dropdown_pages includes this: It is possible, but not confirmed, some of the paramters for the function get_pages could be used for wp_dropdown_pages. This must be at least partly true as I assume your use of <code> post_type </code> as an argument is successful. That being the case, give <c... | wp_dropdown_pages with tax_query clause | wordpress |
I have a wordpress site and I want to create a normal php file. If I put it anywhere in my wp-content folder, I always get a page not found error when I try to access it. For example, I create a file: json.php, and I put it in the wp-content folder and try to acess it like that: www.example.com/json.php, but I get the ... | For example, I create a file: json.php, and I put it in the wp-content folder and try to acess it like that: www.example.com/json.php, but I get the error. That is because the path is wrong. If you put the file in your theme the path to the file is <code> http://example.com/wp-content/themes/your-theme-name/your-file.p... | Where can I create a normal php file? | wordpress |
I'm attempting to make a list of categories bound to a custom taxonomy, but using the featured image of the first post in each category. Getting the categories was simple enough, but when I try to query for the post thumbnail I keep being presented with the details form the most recent post in the first category fetche... | tax_query takes an array of tax query arguments arrays (it takes an array of arrays) but you are using only single array. The correct code is as following. <code> <ul class="product-categories"> <?php $categories = get_terms( array( 'produkter' ), array( 'hide_empty' => false, ) ); foreach( $categories AS $... | How to get first post in a category of a custom taxonomy | wordpress |
I am using <code> get_delete_posts_link($postid) </code> to let users send their posts to the trash from the frontend. Now I'm trying to replicate the same functionality for them to "untrash" or restore the posts as well. <code> get_delete_posts_link($postid) </code> seems to generate a URL like this: http://mysite.com... | From your comment above, I believe you're running into issues with the <code> _wpnonce </code> piece of the puzzle. Looking at the code in <code> /wp-admin/post.php </code> , it appears that the <code> untrash </code> instruction is checking for a valid WordPress nonce, and not getting one. This might do the trick: <co... | Add frontend "Restore" link | wordpress |
I want to hide a few custom image sizes from the media uploader: The following code (stackexchange-url ("posted here")) works only for the default image sizes: <code> function remove_image_sizes($sizes) { unset($sizes['image-name']); return $sizes; } add_filter('image_size_names_choose', 'remove_image_sizes'); </code> ... | Using <code> unset </code> and <code> intermediate_image_sizes_advanced </code> will work but only on images uploaded after the function is added. To change it for existing images you need to regenerate them using a plugin ( in essence deleting that image size) or just hide that option from being visible. Tested on 3.5... | Hide custom image sizes from media library | wordpress |
I need to know if there exists a script or plugin that will add a button the "Settings > Media Settings" that will rebuild all thumbnails to match the current media size settings. The problem this seeks to solve is when the site owner decides he/she would like different thumbnail and featured image sizes after having u... | I install Regenerate Thumbnails on pretty much every single website I build. It does exactly what you need and I've never had a single problem with it. You can either resize them all at once in bulk through a tools submenu, or you can do individual ones in the media library. | Plugin or script to apply updated media settings to all featured images | wordpress |
I was having the following problem: I created a child theme, it was 'correct', technically. It even worked and displayed the proper changes, and when I navigated to sub-pages (ie not the home page), the child theme's effects seemed to vanish. | I scoured the code in the parent theme for any clues, I found none. The one clue I found was that the 404 page worked as expected, which tipped me off that something was up with the page-templates. To resolve the issue, I opened a post, changed the page template to another one (for example "contact form"), updated, the... | Child theme only loads on home page | wordpress |
I've been managing an Wordpress install for several months now without issues. This morning a user notified me that they could not log in to the admin page via /wp-admin. I was not able to login from my primary computer, but found that I could login from my mobile device and laptop intermittently (sometimes it works, s... | This was due a brute-force attack on the Wordpress install (according to my host). | Wordpress admin loads erratically "connection reset by peer" | wordpress |
As the title says, I have a multi-site setup and the apperance is customized with child themes. The main site: themainsite.com Secondary site foo.com When you look into the source code of foo.com, you see some URLs referencing to the mainsite. Such as: <code> <link rel="stylesheet" href="http://www.themainsite.com/w... | I fixed it with changing the multi-site setup from sub-folders to sub-domains. | Multi Site Setup, Child Themes, Getting Style Sheet Directory | wordpress |
I would like to move my large php functions out of the index or template files and into the function.php file. Would it be something like this? <code> function grab_code(???) { ??? .= '<div>some HTML-PHP code I monkeyed together</div>'; return ????; } add_filter('???', 'grab_code'); </code> Then in the temp... | If you move the function and the add_filter function to the functions file, the you don't need to echo the function after. If the function doesn't involve using add_filter then you could echo out the function in your template file. Placing it in the functions.php file, will run on every page/post load unless specified ... | Adding code to the function file | wordpress |
I'm creating some custom rewrites using the code below. Everything works fine, as far as urls such as this: example.com/reviews/showname Tells my theme to use the special archive page and passes the parameters I need. The problem I run into is with pagination. Wordpress generates the links properly: example.com/reviews... | You can try these rules: <code> reviews/([^/]+)/page/?([0-9]{1,})/?$ reviews/([^/]+)/?$ </code> It's informative to check out the active rewrite rules with: <code> function show_rewrite_rules( $rules ) { if(is_admin()) echo "<pre>".print_r($rules,true)."</pre>"; return $rules; } add_filter('rewrite_rules_ar... | Custom Rewrite Problem | wordpress |
I have all the CSS classes set to display images in a custom portfolio theme. I am allowing for images of different sizes and proportions (landscape, portrait, etc) to be tiled next to each other and to be responsive (like the images here: http://studionudge.com/ ). My problem is getting the images attached to posts (a... | It looks to me that those images, along with their <code> divs </code> , have been added directly into the editor. So, it's probably being updated by a developer, or at least someone HTML savvy. I'm not sure what you mean by 'meta boxes'. A meta box is basically any collapsible box within the WP admin interface. If you... | Adding different classes to different images depending on size for fine control of image layout in posts | wordpress |
Each post has an ID and I would like to know how they were assigned. Is there a pattern? Why are the ID's not being incremented by 1 every posts? It would be easier..My ID's go from 9867, to 9869, to 9864, etc.. I can't seem to find a pattern. I could use "The Loop", but I'm doing that from another site. I want to incl... | Each auto-draft gets its own ID, each revision, each nav item, page, custom post type … The actual ID of a post should be irrelevant, this is really just needed for the database and ugly permalinks. You cannot get the last 30 items by inspecting the post ID only. Install a stackexchange-url ("REST API") on the other si... | Post's ID pattern? | wordpress |
I'm working on airsoft website using woocommerce. One of my client's needs is to prevent a user to register if his name or mail is in a blacklist (I don't know yet if I'll use a csv file, a json or a simple array). So I have to execute some validations before insert the user to the database. But I didn't succeed in fin... | If you examine the wp_insert_user() function, you can see there are a myriad of filters and actions that are called throughout the process. The first is a filter called pre_user_login on the username. Line 1304 of wp-includes/user.php: <code> $user_login = apply_filters('pre_user_login', $user_login); </code> You could... | Hook before inserting user into database | wordpress |
I want to display the number of comments a particular post has, so i thought i'd use comments_number, however when i use this the comment number gets printed outside of the span it's supposed to be contained within. I tried using get_comments_number too, but that instead displays nothing at all. The code below has been... | <code> comments_number </code> doesn't return the number of comments, it echos it out. As the codex clearly states : Use <code> get_comments_number() </code> to retrieve the value. | comments_number display outside specified span | wordpress |
In <code> main.js </code> , I have a script, which is sending an ajax request to <code> script.php </code> . <code> $.ajax({ type: "POST", url: "wp-content/themes/roots/script.php", data: registerdata, success: function(result) { alert(result); } }); return false; </code> <code> script.php </code> validate some data an... | To answer your question directly, yes, <code> $wpdb </code> is "auto loaded and set up to global by WordPress" but by loading <code> wp-content/themes/roots/script.php </code> directly you are skipping over the WordPress boot process and loading the file exactly as if WordPress did not exist. That is why the normal Wor... | No access to global variables? | wordpress |
I have a large number of users with Editor Capabilities that help to go through the post submissions. This is my current setup for this role: As you can see, they are allowed to <code> edit_posts </code> and <code> edit_others_posts </code> but they cannot <code> edit_published_posts </code> . This means that they can ... | This is actually not hard. To add a new capability, call <code> WP_Roles->add_cap() </code> . You have to do this just once, because it will be stored in the database. So we use a plugin activation hook. Note to other readers: All of the following code is stackexchange-url ("plugin territory"). <code> register_activ... | Allow Editors to edit pending posts but not draft ones | wordpress |
I'm currently working on a WordPress site and whenever in the admin I go the Appearance > Menus page I get the following error: <code> ErrorException: Runtime Notice: Declaration of Walker_Nav_Menu_Edit::start_lvl() should be compatible with that of Walker_Nav_Menu::start_lvl() in wp-admin/includes/nav-menu.php line 20... | From <code> class Walker_Nav_Menu </code> : <code> function start_lvl( &$output, $depth = 0, $args = array() ) </code> Your child class must use the same signature: three arguments, the first one passed by reference. Every difference will raise the error you got. | Walker_Nav_Menu exeption | wordpress |
One of the most popular Wordpress plugins listed on the Wordpress plugins database got malicious code injected into it recently (April 2013): http://blog.sucuri.net/2013/04/wordpress-plugin-social-media-widget.html A similar thing happened in 2011: http://blog.sucuri.net/2011/06/wordpress-plugins-hacked-understanding-t... | The security of plugin updates via .org really falls on the shoulders of WordPress to provide a secure repository and method for plugin authors to safeguard assets. Since 2011 they have improved the system for notification on plugin changes, so plugin authors are notified when their code is altered, this is a good chan... | Protecting against malicious code in Wordpress plugin updates | wordpress |
Is there a way to query for the first three recent posts and then change how they display on the front page? I want the first three posts of my blog to show differently than the rest of them i.e. they will have full images, and my other posts will just have thumbnail previews. Thanks for any help in the matter. | You can style the first 3 posts differently without querying them separately, you just need to check where you are within the loop while outputting each post via the built in <code> current_post </code> var. <code> while( have_posts() ): the_post(); // are we on the first page and outputting one of the first 3 posts? i... | Query for first 3 posts to change the look and feel | wordpress |
i am using the <code> [multigallery] </code> function and I was wondering if there is a way to use the function to call attachments from another post. For example if i was writing a post about taylor swift and I wanted to include attachments from another taylor swift post using the multigallery shortcode how would I do... | You can try this function instead of your <code> multi_gallery_shortcode() </code> : <code> function multi_gallery_shortcode($atts, $content=null) { extract( shortcode_atts( array( 'pid' => 0, ), $atts ) ); //format the input $pid = intval($pid); // construct a post object dependent on the input value if($pid>0){... | Showing a different gallery in a seperate post | wordpress |
I retrieve the date of an actor by selecting the date. <code> 'data_nasterii' </code> is the name of the custom field. <code> <?php $data = get_field('data_nasterii'); echo date("d/m/Y", strtotime($data)); ?> </code> If i do not select anyting, I'd like to return: <code> N/A </code> for the actor birthday. How ca... | I'm not certain what an empty <code> get_field </code> returns, as it's from a plugin. However, assuming it provides <code> FALSE </code> or an empty string: <code> <?php $data = get_field( 'data_nasterii' ); echo ( $data ? date( "d/m/Y", strtotime( $data ) ) : 'N/A' ); ?> </code> | How can i retrive a text from a custom field | wordpress |
I'm trying to setup upload for for attachments for my custom post form. At first I add to my <code> form </code> tag <code> enctype="multipart/form-data" </code> For testing purposes I have two upload forms, but in future I'm gonna implement only one form and use jQuery to append as many forms as I want. <code> <fie... | May be you are not returning correctly from function, Try this, <code> function insert_attachment($file_handler, $post_id, $setthumb=false) { // check to make sure its a successful upload // changes start if ($_FILES[$file_handler]['error'] !== UPLOAD_ERR_OK) { return __return_false(); } // changes end require_once(ABS... | Custom image upload | wordpress |
I am using the plugin Connections in my website. Now I created a page exclusively for this, so the directory listing has to be only shown if the page is "Directory" and it has to be shown in center. Currently the plugin is shown in sidebar. How can I solve this issue? | I found this function which can help u. The key is to change the handle, in this case is contact-form-7. This code snippet will prevent contact-form-7 script from loading except in contact page. <code> add_action( 'wp_print_scripts', 'my_deregister_javascript', 100 ); function my_deregister_javascript() { if ( !is_page... | Show plugin only on a specific page | wordpress |
I am customizing the WP avatar (to fit a grid) and do not want the avatar customization to show on the admin bar drop down or in the dashboard or on the site (when the admin bar is visible). I have excluded the avatar change from the dashboard using this code in functions.php: <code> function foo_change_avatar($class) ... | In the <code> WP_Admin_Bar::add_menus() </code> class method you will find the actions: <code> add_action( 'admin_bar_menu', 'wp_admin_bar_my_account_menu', 0 ); add_action( 'admin_bar_menu', 'wp_admin_bar_my_account_item', 7 ); </code> and the two corresponding callbacks are using <code> get_avatar() </code> . To prev... | Exclude admin bar from showing avatar customization | wordpress |
I have a custom field who's content I would like to output as a ul list. The custom field contains words that are separated with a spaces between. I'm trying to use this code here but it's not working. <code> <?php $list_items = get_post_meta($post->ID, 'idid'); if($list_items){ $list_items = explode(" ", $list_i... | You are using <code> get_post_meta </code> incorrectly. As you use it, it will return an array - you cannot explode an array. See the codex on get_post_meta() ; If you pass <code> true </code> as the third parameter, this tells the function to return a string. So, <code> $list_items = get_post_meta($post->ID, 'idid'... | Output custom field as ul list | wordpress |
Is there a way to display the WordPress register form on a custom page the way one would use <code> <?php get_search_form( $echo ); ?> </code> for a search form? If not how would one go about creating such a template? I would like to do this without Ajax btw. Any pointers/ideas are very welcome! | Here is a function I've Used Before: <code> function registration_form_wpa95139(){ if (is_user_logged_in()) return; ?> <div class="Registration"> <div id="register-form"> <div class="title"> <h1><?php _e('Register your Account'); ?></h1> <span><?php _e('Sign Up with us an... | Custom Registration Template/Page | wordpress |
This is the scenario: I have multiple pages that all have a custom field named "Location" Those pages all have child-pages with the custom field of "size_m2". What I want is to do a normal meta_query to list all pages with let say "size_m2 > = 55", but only if the parent page have "Location == Stockholm". Do i need to ... | Your problem is you have: <code> foreach post where A is true, that has a child where B is true </code> Which is actually: <code> foreach post where A is true that has a child where B is true </code> So this is not something you should be doing in 1 query. Instead you would need to do n queries where n= parentposts+1. ... | Query posts based on parents attribute | wordpress |
The below code is part of Keyring Social Importer, and it imports my Tweets from Twitter and posts them as individual blog posts on my Wordpress.org install. I was wondering how I could make it set the featured image of all of the blog posts it creates to something. Currently it just imports my Tweets as publishes them... | The quickest and dirtiest way to do this is to add one line to the <code> insert_posts() </code> function, just before the <code> $imported++; </code> line: <code> } add_post_meta( $post_id, 'raw_import_data', json_encode( $twitter_raw ) ); // NEW LINE (change 1001 to the image ID): set_post_thumbnail( $post_id, 1001 )... | Adding featured image to posts created by a plugin | wordpress |
When I click on a category now, it looks like.. Category Archives: MyCategory first post second post third post.. I want to customize these landing pages for special categories, add text, pictures, html. How do I do that, easiest way, w/o plugins. There might be a file to be cloned, like content-category-mycategory.php... | Here is the Template Hierarchy , which gives you an overview of the different approaches. You could create for each category an individual PHP file: either <code> category-{CATEGORY ID}.php </code> or <code> category-{CATEGORY SLUG}.php </code> . Or you could use a single file <code> category.php </code> in which you d... | Customized landingpages for categories | wordpress |
I"m trying to replace the string "Something Nice will show up here" in the block of codes below with WordPress loop but it doesn't seem to be working. I'd like when Link1 is clicked on, let the post with the ID "intro-paragraphs" show. Any ideas on how to do that properly? <code> <?php $longString = "Something Nice ... | You can't execute PHP code from within a string. You can however define a function that executes code and call that function within your if clauses. <code> function dz_slick_longstring() { $query = new WP_Query('category_name=intro-paragraphs'); if($query->have_posts()) : while($query->have_posts()) : $query->... | Conditional Content Display | wordpress |
So I have created this widget which pulls a number of posts. And the query is being cached via transients. But I need the transient to be deleted whenever a post is saved so the query can be refreshed. Have a look at this code snippet. <code> add_action( 'save_post', 'delete_transient' ); function delete_transient() { ... | Use a widget cache and forget the actual number of active widgets. In your widget add this to your method <code> widget() </code> : <code> public function widget( $args, $instance ) { // get the cache $cache = wp_cache_get( 'UNIQUE_WIDGET_IDENTIFIER', 'widget' ); if ( !is_array( $cache ) ) $cache = array(); if ( ! isse... | How to delete cached transients from a widget instance properly? | wordpress |
I am trying to make it so that I can output to the console in PHP. I have already installed FireFox with the FireBug and FirePHP addons. I downloaded the 'FirePHPCore Server Library' from here and I uploaded it into 'wp-content/themes/Jupiter/includes' (my theme is called Jupiter). Then, from within the loop of a templ... | I use it including the file (Match you actual file location): <code> require '../../FirePHPCore/fb.php'; </code> and then call by using <code> fb( $variable, 'Message Title'); </code> Be sure that you've installed and activated the FirePHP addon on Firefox. There's also a WordPress plugin for FirePHP , but I've never u... | Using FirePHP with WordPress | wordpress |
I have created a wordpress page that will output product details of a specific product from amazon: <code> wordpress/product?asin=123 </code> I'm just using the product page as a template and it really contains nothing. I'm just adding a filter to the content to put some contents into it. I'm also using the wordpress s... | Either deactivate the filter from the SEO plugin for that page with <code> remove_filter() </code> or use a later priority argument like this: <code> add_filter( 'the_title', 'ecom_title_filter', PHP_INT_MAX ); add_filter( 'wp_title', 'ecom_title_filter', PHP_INT_MAX ); </code> | Dynamically generate meta tags and titles for a wordpress page | wordpress |
I am trying to place a shortcode inside another shortcode within a page template, however the various attempts I've made seem to not do anything. Here's how my code looks now - <code> <?php echo do_shortcode('[shortcode]' .$shortcode2. '[/shortcode]');?> </code> I've also tried these - <code> <?php echo do_sho... | Have you tried setting the output of the first do_shortcode inside the second call? <code> $output = do_shortcode('[first_shortcode]Some content[/first_shortcode]'); echo do_shortcode('[second_shortcode]'.$output.'[/second_shortcode]'); </code> | How to use shortcode inside of shortcode in theme | wordpress |
In my theme, I have the WooCommerce plugin installed and would like to rename the " Catalog " tab, located under the WooCommerce > Settings submenu page. Am I able to do this from my <code> functions.php </code> file so that I'm not directly modifying the plugin itself and if so, how? Thanks. | Yup, there's a filter for it: <code> woocommerce_settings_tabs_array </code> : <code> add_filter( 'woocommerce_settings_tabs_array', 'wpse94969_settings_tabs_array' ); function wpse94969_settings_tabs_array($tabs){ $tabs['catalog'] = __('Products','your_textdomain'); // or whatever you fancy return $tabs; } </code> Thi... | WooCommerce Tabs | wordpress |
I want to disable changing password option for all my subscriber users. Is it possible by doing any code tweak or something using any plugin? If someone has any idea or plugin knowledge to do this then appreciated. | You can try <code> if( current_user_can( 'subscriber' ) ) { add_filter( 'show_password_fields', '__return_false' ); } </code> see also http://wpengineer.com/2285/disable-password-fields-for-non-admins/ http://adambrown.info/p/wp_hooks/hook/show_password_fields | Is it possible to block subscriber users to changing its password? | wordpress |
I want to remove the website field from the user contact info. I use the following to remove the AIM,Jabber and Yahoo IM . But I am not able to use this to remove the website. Someone please help. <code> function remove_contactmethods( $contactmethods ) { unset($contactmethods['aim']); unset($contactmethods['yim']); un... | Since the website field is hardcoded in the <code> user-edit.php </code> page and not part of the <code> _wp_get_user_contactmethods( $profileuser ) </code> you can try to remove it with jQuery: <code> function remove_website_row_wpse_94963() { if(!current_user_can('manage_options')){ // hide only for non-admins echo "... | Removing "Website" Field from the contact info | wordpress |
I am getting the following error when I try to access my Wordpress website. It was working quite fine previously. Could anyone help me on this. No configuration file found and no installation code available. Exiting... | In Wordpress there will be a default wp-config.php file and I think this has been missing from your package. Please Check if it is there, else create a new one with file name wp-config.php and Place the following code in it with appropriate Database Credentials. <code> <?php // ** MySQL settings ** // define('DB_NAM... | No configuration file found and no installation code available. Exiting | wordpress |
I am trying to use the following code to check for my custom field for a value of ZERO to then display my div <code> <?php $mp_price_sort = get_post_meta('mp_product_price'); if ($mp_price_sort == '0') { ?> <div><?php echo do_shortcode('[shortcodes]'.$mp_buy_button.'[/shortcodes]'); ?></div> <... | You are using get_post_meta incorrectly, so it is returning FALSE every time. As PHP equates '0' and FALSE, your div will always be displayed. The correct syntax for get_post_meta is: <code> <?php $meta_values = get_post_meta($post_id, $key, $single); ?> </code> where $post_id is the only required argument. | IF Custom field value equals ZERO | wordpress |
I'm trying to restrict how many items you can associate with a post so in my save function I have: <code> add_action( 'save_post', array( $this, 'save_custom_items_data' ), 10, 2 ); public function save_custom_items_data( $post_id, $post ) { if(count($related_items) > 5) { // display error message here but the page ... | Short of doing some jQuery validation, I think the only option is <code> wp_die() </code> . <code> add_action( 'save_post', array( $this, 'save_custom_items_data' ), 10, 2 ); public function save_custom_items_data( $post_id, $post ) { if( count( $related_items ) > 5 ) { wp_die( 'Error, 5 items max.', 'Error', array(... | displaying an error before update_post_meta | wordpress |
I've got a small issue with my archive.php. I was trying to set up an If statement that displays a certain category and sub categories with a different layout & sidebar based on my theme options. I've placed a small bit of code in the start of my archive.php in order to set these options based on if the post is in ... | Firstly, do you have DEBUG set to TRUE in wp-config? Not loading further than the header may well mean there's an error that isn't displaying. Set it to True to see the error. Secondly, you are using for in_category on an archive page - which I believe would only apply to the first post on the page. This may not make a... | Archive.php, and post_is_in_descendant_category | wordpress |
So, I ran into an interesting issue while adding some admin menu bar links today. When adding links to a parent menu using something like: <code> // Add the parent menu $wp_admin_bar-> add_menu( array( 'title' => 'Testing MENU', 'href' => false, 'id' => 'parent_id' )); // Add the child menu $wp_admin_bar-> add_menu( ar... | You are not declaring an 'id' key. Without one, the id will default to a sanitized version of the 'title' value - hence your overwrite. Declare a unique id element, and you should be golden. That said, add_node is now the preferred method of achieving this. | Question about how global $wp_admin_bar works | wordpress |
I have the following function which I use to show the author name,author avatar and the author biography in a div. I need to show the title of the latest post by the author along with this. Can anyone help? <code> function ajaxified_function() { $response = new WP_Ajax_Response(); $id = $_POST['author_id']; $auth_name ... | You can get the latest post of an author adding the following code to your function: <code> $latest_post = get_posts( array( 'author' => $id, 'orderby' => 'date', 'numberposts' => 1 )); // Since get_posts() returns an array, but we know we only // need one element, let's just get the element we need. $latest_p... | Show the title of the latest post by author | wordpress |
I was using the entire template in the plugin, but I would like to use get template part, so that I can reuse the header and footer in the original template. The code is like this: <code> add_filter( 'page_template', 'template_reg' ); function template_reg() { if ( is_page( ourdoctors_single_pg() ) ) { $page_template =... | Yes, <code> get_template_part </code> will always look in the theme. It uses <code> locate_template </code> which is hard-coded to use <code> STYLESHEETPATH </code> and <code> TEMPLATETPATH </code> I don't know exactly what you mean about using a "partial template", but if you mean "can I include part of a PHP file?" t... | How to use get_template part in the plugin? | wordpress |
One of the things that my plugin does is creates a number of SQL tables as part of a versioning function (that is run under the admin_init hook as I couldn't find a better wordpress way of doing things). I call the initialisation script as part of the setUp routine and theorectically should be dropped as part of the te... | The unit tests transform all <code> CREATE TABLE </code> and <code> DROP TABLE </code> queries to <code> CREATE TEMPORARY TABLE </code> and <code> DROP TEMPORARY TALBE </code> , respectively. So in your <code> tearDown </code> the query will attempt to drop temporary tables with those names, but not the actual tables. ... | Plugin development with unit tests | wordpress |
For every website project, i make the wordpress admin custom for the client. Right now, i want that the client only has access to add subpages. I have a main navigation on the website. I want that the main navigation is fixed, so the client can not add pages to the navigation. But the client can add subpages to the cur... | <code> wp_list_pages </code> simply lists pages. It isn't a menu and doesn't use the navigation menu APIs. For what you want you'd need to do several queries to find the subpages of those page IDs, so in your case 4 queries, and you'd need to do 4 wp_list_pages calls, and a manual query to get the top level pages. This... | Access for adding subpages but not for pages | wordpress |
One of my clients has installed a theme where when a visitor enters their username and email to register as a new user they get shown a link to download a custom report file. This was working fine on my clients test installation, but now they've converted the site to a live site the download link doesn't show and inste... | The difference between the two is that the test site has pretty permalinks enabled and the live site doesn't. If you look at the URL, the issue becomes apparent, this is not a valid URL/query string: <code> http://www.veredor.com/?page_id=140?register=true </code> If you change the second <code> ? </code> to an ampersa... | Why is this page using the homepage template and not the one it should? | wordpress |
Based on the current page, I'm listing the links of all pages which belongs to the parent ancestor. However when I'm accessing a grandchild, the top parent page will gone from the links hierarchy. This is what I have tried: <code> <?php // display the sub pages from the current page item if($post->post_parent) { ... | <code> <?php $parent = array_reverse(get_post_ancestors($post->ID)); $titlenamer = get_the_title($parent[0]); $permalink = get_permalink($parent[0]); if ($post->post_parent) { $ancestors=get_post_ancestors($post->ID); $root=count($ancestors)-1; $parent = $ancestors[$root]; } else { $parent = $post->ID; }... | List all subpages hierarchically based on the currently viewed page, top ancestor levels included | wordpress |
I have a plugin that has input form, I have decided to check submitted data with akismet. I do have API key, WP comments are filtered correctly... here is, what I found: http://www.binarymoon.co.uk/2010/03/akismet-plugin-theme-stop-spam-dead/ problem is, that <code> $response </code> is always empty - I have tried to <... | The problem is the globals <code> global $akismet_api_host, $akismet_api_port; </code> are not available everywhere. I suggest calling your function in the "init" hook ... <code> add_action('init', 'myAkismetInit'); function myAkismetInit() { var_dump ( bm_checkSpam('') ); } </code> Check out the Akismet API documentat... | Check spam in custom form - akismet | wordpress |
I would like to rename the "Add Media" button (just above the post editor interface) to be "Add Images". I can't seem to find the appropriate filter for this. There seems to be a filter that has now been deprecated but I can't figure out what the new method is. The legacy filter was <code> media_buttons_context </code>... | The button text being a translatable string, you can make use of the gettext filter: <code> function wpse95025_rename_media_button( $translation, $text ) { if( is_admin() && 'Add Media' === $text ) { return 'Add Images'; } return $translation; } add_filter( 'gettext', wpse95025_rename_media_button, 10, 2 ); </c... | Rename "Add Media" Button To "Add Images" | wordpress |
I want to store some Twitter API data in WordPress. After every hour, I want to fetch new data from Twitter, and update only if the data is successfully retrieved from API (sometimes the API gives error, so in that case I want to keep using the old data). So in that case should I use <code> set_transient </code> or <co... | A transient is not like a <code> wp_cron </code> job in that they don't update themselves when a set time has elapsed. A transient will update when an attempt is made to access the data. If you actually do need an approximately hourly update you will need to use <code> wp_cron </code> , though in practice it may not ma... | Should I use set_transient or update_option? | wordpress |
In my menu area of the word press admin I have access to place links in both the h "main menu" and the "footer links" <code> register_nav_menus(array( 'main_nav' => 'The Main Nav', 'footer_links' => 'The Footer Links' )); </code> In the Header: <code> wp_nav_menu(array('menu' => 'The Main Nav')); </code> In th... | The correct way to get a specific menu is the <code> 'theme_location' </code> parameter: <code> wp_nav_menu(array('theme_location' => 'main_nav')); wp_nav_menu(array('theme_location' => 'footer_links')); </code> | Header links also appearing in the footer | wordpress |
I've registered custom rewrite rules and <code> query_vars </code> to use for displaying a list of events based on ISO date format. For example when a user requests the URL, <code> http://site.com/by-date/2013-04-04/ </code> , my <code> query_var </code> is the date portion and I'd like to display a list of events who'... | Instead of trying to display all the matching events on your <code> by-date </code> page, you could try to display through <code> ?post_type=event </code> like this: <code> function rewrite_rule_by_date() { add_rewrite_rule('by\-date/([0-9]{4}\-[0-9]{2}\-[0-9]{2})$', 'index.php?post_type=event&event_date=$matches[1... | Changing the meta_query of the main query based on custom query_vars and using pre_get_posts | wordpress |
I have a site with more then 10.000 posts and images, its classipress site. I need somehow to show all images from posts that are on pending status, and who havent expired(post meta). This is the code I came up with and that is working: <code> function cb_dash_images(){ $args = array('post_type' => 'attachment', 'nu... | I don't have the data to test so the code below may be wrong. <code> add_filter('posts_search', 'set_is_tax_to_true' ,10,2); function set_is_tax_to_true($search,$query){ $query->is_tax = true; } $args = array( 'post_type' => 'attachment', 'posts_per_page' => -1, 'post_status' => 'pending', 'post_parent' =&g... | Better wordpress attachment query then this | wordpress |
How would you make a meta box sit above all other meta boxes at all times in a custom post type? For example: <code> add_meta_box ( 'aisis-meta-id', 'Mini Feeds Information', array(&$this, 'aisis_mini_feeds_info'), 'mini-feed', 'advanced', 'high' ); </code> Create a meta box, how ever it only appears after ALL othe... | Change <code> advanced </code> to <code> normal </code> , this will at least move it up above some others. However, there's no guarantee you get the top spot, because a user can still drag and drop metaboxes around, or a core metabox or one added by another plugin might believe it is more important than yours. There's ... | Custom Post Type Meta Boxes | wordpress |
I have a page, outside the loop, that display a media attachment with some basic info about it (title, uploaded date, etc). I have the attachment ID available to me via a form submitted before the page loads. What I need to do is secure the page by making sure that only users who have uploaded that file have access to ... | Back in the day I wrote a function to check for that (you can put it in functions.php and call it from your page): <code> public function check_if_user_is_author($user_id, $post_id) { global $wpdb; $res = $wpdb->get_results($wpdb->prepare("SELECT * FROM " . $wpdb->posts ." WHERE ID = %d AND post_author = %d LI... | Get author ID with attachment ID | wordpress |
I would like to know is there any way/Plugin to limit the the post number of a category? And whenever user publish new post in that category then the category release the old post automatically? Like this: Category A, Category B, Category C Here Category A is limited which can hold only one (specific number) post. Now ... | My understanding is that you want to set number of posts limit on your categories, so that each category will have specified number of posts. After a very long time I am trying to answer a question on WordPress SE, so I hope I will make sense. Explanation Categories does not have meta data, so you are going to need you... | Category that can hold only specific number of post | wordpress |
I'd like to be able to check if the twentytwelve theme is active. I know if I was checking for an active plugin I'd do something like: <code> $active_plugins = apply_filters( 'active_plugins', get_option( 'active_plugins' ) ); if ( in_array( 'plugin-folder/plugin-folder.php', $active_plugins ) ) { //do stuff } else { a... | You can use <code> wp_get_theme </code> : <code> <?php $theme = wp_get_theme(); // gets the current theme if ('twentytwelve' == $theme->name || 'twentytwelve' == $theme->parent_theme) { // if you're here twenty twelve is the active theme or is // the current theme's parent theme } </code> Or, you can simply ch... | How to check if a theme is active? | wordpress |
Hi I have two JavaScript elements for logging into and create an account. They both overlap each-other when the div id is clicked and I need them to hide when the other id is clicked and vice versa. <code> <script type="text/javascript"> jQuery(document).ready(function(){ jQuery('#sign-in').live('click', function... | Since you want them to alternate the easiest would be to use <code> show() </code> and <code> hide() </code> rather than <code> toggle() </code> , since you don't actually want to toggle the visibility if the login is clicked more than once, you want it to always show the #login and hide the #create. Also note that the... | Javascript 2 elements dependent onclick .toggle | wordpress |
I originally was going to post a question on how I would go about ranking a list of authors by the amount of post views from all of their posts combined. But I luckily found a solution here: stackexchange-url ("List users with the most total posts view") This is the code I'm using from that page, except I tweaked it a ... | First you can replace <code> 'posts_per_page' => '10000000000' </code> with <code> 'posts_per_page' => -1 </code> to remove the limit. If you want to show the user rank, you can add a <code> $rank </code> counter in the foreach loop: <code> $rank=0; // output the result: user, total postview count, latest post fo... | Show individual author rank from query of cumulative post view count for all authors | wordpress |
I am trying to get all the IDs in my navigation and convert it to a string so that I can use it with <code> wp_query </code> to get the pages that are only listed in the nav. The code to get the IDs: <code> $menu_name = 'primary'; if ( ( $locations = get_nav_menu_locations() ) && isset( $locations[ $menu_name ]... | Menu items are stored in the <code> posts </code> table with a <code> post_type </code> of <code> nav_menu_item </code> . So, what you are returning is the ID of the menu item itself, not what it points to. The page/post ID that the menu item refers to is stored in the <code> postmeta </code> table, with a <code> post_... | Get page IDs from nav items | wordpress |
I am building an LMS type system in WordPress, controlled by Custom Post types. The post type is called Lessons (with a slug of courses) and it has one custom taxonomy (category) called courses. The domain url structure shows right now as domain.com/courses/lesson-name, I want it to become domain.com/courses/[course-na... | Change your rewrite to add the course query var: <code> 'rewrite' => array('slug' => 'courses/%course%') </code> Then filter <code> post_type_link </code> to insert the selected course into the permalink: <code> function wpa_course_post_link( $post_link, $id = 0 ){ $post = get_post($id); if ( is_object( $post ) )... | Add category base to url in custom post type/taxonomy | wordpress |
i want to remove all html tags from content like <code> <p>, <br>, <img>, <a> </code> i <code> tried strip_tags() </code> also tried <code> $content = get_the_content(); $content = apply_filters('the_content', $content); </code> but not working for me. any reliable solution ?? | The WordPress function, at least the one I tend to use, would be <code> wp_filter_nohtml_kses </code> . That should remove all of the HTML, but you need to be careful not to put some HTML back by running <code> the_content </code> filters on your HTML-less string. I am not sure why <code> strip_tags </code> didn't work... | How can i remove all html tags from get_the_content()? | wordpress |
Ok so I am using the [multigallery] function and it works fine, but one thing I want to add. Here is the code that I am using for the multigallery in my functions.php file <code> function get_random_gallery_images(){ global $wpdb,$post; $ids = ""; $counter = 0; $number_of_posts = 6; $args = array( 'post_type' => 'at... | You can try <code> function multi_gallery_shortcode($atts, $content=null) { extract( shortcode_atts( array( 'pid' => 0, ), $atts ) ); //format input $pid = intval($pid); // construct a post object dependent on the input value if($pid>0){ // query a post object $pobj = get_post( $pid ); }else{ global $post; // cur... | Adding Image Count to Multigallery | wordpress |
So apparently I am now allowed to do the following in the admin, ON my theme options page and only ON my theme options pages: <code> public function load_admin_jquery(){ if(isset($this->_options['admin_jquery_version'])){ wp_deregister_script ( 'jquery' ); wp_register_script ( 'jquery', 'http://ajax.googleapis.com/a... | All other scripts running on that page depend on the correct jQuery file shipped with WordPress: admin bar, jQuery-UI or other plugins. Note that loading external resources is not possible in all setups, so your options page would not work in these cases. To use scripts that needs <code> $ </code> use <code> $ = jQuery... | wp_deregister_script was called incorrectly | wordpress |
I have a CPT registered that is called <code> lessons </code> with a custom taxonomy (category) that is called <code> courses </code> . I want the <code> /courses </code> page (archive-courses.php?) to display the individual courses (i.e. "online marketing", "paid advertising") and not the individual posts (lessons). W... | If you'd like to list the individual courses, i.e. the taxonomy terms, you'd use neither <code> WP_Query </code> nor the WP standard Loop . Instead, make use of the <code> get_terms </code> function to retrieve the courses. It returns an array of term objects (if the taxonomy does exist and has terms matching the funct... | Have a Custom Post Type index page display taxonomy items instead of posts | wordpress |
I am helping my father with his WordPress website. It has over 1,700 posts with TITLES IN UPPERCASE. We'd like to change these to "Title Case" in the database (possibly using this PHP script). The WordPress "To Title Case" plug-in changes the case at the template level - we'd like to change it at the database level. Wh... | Updating the posts <code> $all_posts = get_posts( 'posts_per_page' => -1, 'post_type' => 'post' ); foreach ( $all_posts as $single ) { wp_update_post( array( 'ID' => $single->ID, 'post_title' => to_title_case( $single->post_title ) // see function below )); } </code> Converting a string to "Title Case... | How to change the case of all post titles to "Title Case" | wordpress |
Within a loop, that otherwise works fine, <code> the_time() </code> is giving me a date and time about 25 days and a few hours ahead of the actual date. For instance, if I post today, it lists it as "April 30th, 2013" (today is April 6th, 2013). I can't for the life of me figure out why it's doing this. A couple things... | if I post today, it lists it as April 30th, 2013 (today is April 6th, 2013). Your using a lowercase t in your date format string . <code> t Number of days in the given month 28 through 31 </code> On Line 92: <code> echo get_the_time('M-t-y \a\t g:ha' , $id); </code> I think you meant to use d or j instead. | the_time() returning wrong date/time (way in the future) | wordpress |
I found stackexchange-url ("this answer"). It saved my day, but could you tell me how to display featured image of the post with the following code? When I'm using <code> <?php echo $cpost->post_thumbnail('thumbnail', array('class' => 'alignleft')); ?> </code> An image does not show up... Code below: <code>... | <code> get_posts </code> fetches an array of <code> WP_Post </code> objects (see the return values of <code> get_post </code> for a complete list of object properties). In your above code snippet, you are iterating over said array with a <code> foreach </code> loop. Inside it, you are currently attempting to use a non-... | Custom Loop, Match Category with Page: How to display post featured image? | wordpress |
I have three separate WP_Queries on a page. Each of them return custom post type items that have a certain checkbox checked and then display one of those randomly. The checkbox has been added using Custom Metaboxes and Fields for WordPress . <code> <?php $front1_args = array( 'post_type' => 'work-item', 'meta_key... | Found a fix. Apparently CMB doesn't use integers while saving values to database from custom checkboxes, but rather adds an <code> on </code> string when a checkbox is checked. Also when a previously checked checkbox is unchecked, the corresponding row isn't removed from <code> wp_postmeta </code> table, but remains th... | Cache issue with WP_Query and custom field filtering | wordpress |
I'm loading a stylesheet and a <code> style </code> into the header using functions.php. This works but the stylesheet is being presented below the <code> <style> </code> . I need to order the stylesheet above the <code> style </code> block. <code> /*---------------------------------------------------------------... | You should not be outputting anything on the <code> wp_enqueue_scripts </code> hook, just enqueueing. Move your css output to a function hooked to <code> wp_head </code> with a lower priority than 8, which is when the enqueued styles are printed in <code> wp_head </code> : <code> function folio_enqueue_css() { wp_enque... | Ordering stylesheet above using functions.php | wordpress |
I am trying to figure out if there is a way to add a link or button that will open the media manager/library on the front end of the site? I don't need to select images for insert or to select images as featured, I simply want to allow my users to upload and edit their media within the library without having to go the ... | Virtually all the core files and scripts that WordPress uses for displaying the media library are within the <code> wp-admin </code> folder, plus it uses various admin-only hooks, so using this on the front-end is pretty much out of the question. It's not difficult to allow users to upload to the media library from the... | Link or button to open the media manager from frontend | wordpress |
I am curious as there are three function for loading files in plugins: <code> plugin_dir_path() </code> and <code> plugins_url() </code> , along with <code> plugin_dir_url() </code> So as a plugin developer, which would you use for loading php files? the main example shows: <code> plugin_dir_path() </code> - but if one... | Return values of the three mentioned functions 1. <code> plugin_dir_path( __FILE__ ) </code> returns the servers filesystem directory path pointing to the current file, i.e. something along the lines of <code> /home/www/your_site/wp-content/plugins/your-plugin/includes/ </code> This can be used for loading PHP files. 2... | When would I use either function for plugins? | wordpress |
I am a designer for a website, which I had a developer build in wordperss for me. Each time a new page is created, it is automatically added to my menu bar. Is this something the developer has built into the code, or is it something I can turn off? | There are two major things you need check for to resolve this. If your site is using the WordPress menus, then under Appearance | Menus is a checkbox that if ticked will automatically add all new top-level pages to the menu. Unticking that box will stop the behavior. If you check that area and no menus are defined, the... | Automatically Generated Menu pages | wordpress |
I'm using a dropdown menu on my Wordpress page which shows all the pages. If you hover over it, the subpages of that particular page are shown. Say I have five pages that each have a couple of subpages. Is it possible to show the subpages on the same page as the page itself and have the dropdown menu link to the sectio... | <code> get_children </code> is the most straightforward way to get "attachments, revisions, or sub-Pages". So... <code> $children = get_children(array('post_parent'=>$post->ID)); if (!empty($children)) { foreach ($children as $child) { echo '<div id="child-'.$child->ID.'" >'; // content formatted however... | Link to subpages on the same page | wordpress |
I'm trying to customize the aspect of a single format post, in my case is "Link". I've added a different color background so they look different, editing the CSS as this: <code> .format-link .entry-content { padding: 0; font-style: italic; background: #d7b5b5; //sfondo rosa } </code> So they look like this: http://www.... | Well, first, it's a pure CSS question. Second, <code> padding </code> is what you want to use. Just change <code> padding: 0; </code> to whatever you like. I just used FireBug to hack a padding of 1em into your code, and it worked like a charm. // Edit However, it is not just <code> .entry-content </code> but also <cod... | Post interior margin in twenty eleven theme | wordpress |
I've got a WordPress cron job that sends an email periodically and saves the timestamp when it was sent as an option, and I'd like to display a date on a settings page. Something like, "The last email was sent on 'x'". I'm on the west coast of the US, so our time is currently seven hours off of UTC. My expected output ... | I know I'm three months late, but the function you want here is <code> get_date_from_gmt() </code> . The function accepts a GMT/UTC date in <code> Y-m-d H:i:s </code> format as the first parameter, and your desired date format as the second parameter. It'll convert your date to the local timezone as set on the Settings... | Converting timestamps to local time with date_l18n() | wordpress |
The My Sites admin page only has links to the sites’ dashboards and production pages which is of limited value. I am trying to figure out a way to add a more useful links to them like New Post , Drafts , and Comments in order to make the page a practical central administration location (that way, I don’t have to use a ... | <code> function my_sites_links($links, $a, $b, $c) { global $user_blog; $user_blog->userblog_id; } </code> | Adding (blog-specific) links to “My Sites” admin page | wordpress |
I'm trying to get a post's mp3 attachments working with the jplayer plugin (with playlist addon). I have it working for a set number of attachments, but am failing to find a dynamic solution for any number of attachments. Currently, the mp3 attachment urls and titles are fetched and added as attributes to the '.jp-play... | Have a look at <code> wp_localize_script </code> for passing php data to javascript. A pseudo-code example: <code> $tracks = array(); foreach( $mp3_attachments as $mp3_attachment ): $tracks[] = array( 'mp3' => $mp3_attachment['filename'], 'title' => $mp3_attachment['title'] ); endforeach; $wpa_track_data = array(... | Problem adding MP3 attachments to a jPlayer playlist | wordpress |
I'm trying to make a Wordpress function and currently I have this in my functions.php file: <code> function find_my_image($content) { if(is_single()) { if (preg_match('#(<img.*?>)#', $content, $result)){ $content .= '<p>Image has been found</p>'; } else{ $content .= '<p>Sorry, no image here!<... | You need to return content from filter function. <code> function find_my_image( $content ) { if( is_single() ) { if ( preg_match('#(<img.*?>)#', $content, $result ) ){ $content .= '<p>Image has been found</p>'; } else{ $content .= '<p>Sorry, no image here!</p>'; } } return $content; } add_... | How to stop filter from running on the index.php page? | wordpress |
I need to load a completely different theme for my categories. My search came up with <code> switch_theme </code> function but it changes the theme permanently while I only need the theme change only occur on my category pages. Then I found stackexchange-url ("this"). <code> add_filter( 'template', 'my_change_theme' );... | Ok, after some consideration and tinkering I could get it to work. The reason it wasn't working was because the needed procedures for loading a template kick in long before the the parser gets to <code> functions.php </code> of the theme. So to overcome this I had to bring the code into the plugins' section. By creatin... | How to load a different theme for categories? | wordpress |
I developed a custom plugin which rewrite some content of my posts, but when i move a post to trash, the action hook 'save_post' is triggered and the post is not deleted. A simplified version of my code : <code> add_action('save_post', 'rewrite_post', 10, 2); function rewrite_post($post_id) { remove_action('save_post',... | It's probably easiest to just check the post status within your function. Untested: <code> add_action( 'save_post', 'rewrite_post', 10, 2 ); function rewrite_post( $post_id ) { if ( 'trash' != get_post_status( $post_id ) ) { remove_action( 'save_post', 'rewrite_post' ); $title = preg_replace( '/\_/', ' ', get_the_title... | Action hook 'save_post' triggered when deleting posts | wordpress |
I want to insert post programatically so here is the code to add one: <code> global $user_ID; $new_post = array( 'post_title' => 'My New Post', 'post_content' => 'Lorem ipsum dolor sit amet...', 'post_status' => 'publish', 'post_date' => date('Y-m-d H:i:s'), 'post_author' => $user_ID, 'post_type' => '... | The post thumbnail is just saved as post meta with the key: <code> _thumbnail_id </code> . So after you insert the post and get the post id, you can set the post meta for that post. The <code> $thumbnail_id </code> is just the ID of the image you'd like to set as the thumbnail, up to you since I can't tell from your qu... | Adding post thumbnail in programatically inserted post | wordpress |
I am building a wordpress theme for personal use. I am facing a challenge for the first time and I really don't know how to achieve what I want. The website's header structure is: FIRST LINE: logo / SECOND LINE: custom jquery slider / THIRD LINE: navigation menu. What I want to do: When someone clicks the link to go to... | To add a custom hash to the end of each URL added through the menu backend is easier said than done. You could build a custom walker . Or you could try to hook in the <code> walker_nav_menu_start_el </code> filter and edit just that, perhaps like so [ nav-menu-template.php ] : <code> add_filter( 'walker_nav_menu_start_... | New Page Position | wordpress |
I have a page on my wordpress site that has some fields to be filled by visitor. On the click event of 'submit' button, all the details filled by visitor should be mailed to the wordpress admin. I got to know how to stackexchange-url ("Send automatic mail to Admin when user/member changes/adds profile") but i don't hav... | I could not really work out with the ajax with plugins things. Not so good with it still. :( So i simply used the function <code> get_bloginfo('admin_email') </code> to obtain the admin's email address. Using <code> mail() </code> function, the mails are sent to the obtained email address on click of the button. | Send mail to wordpress admin | wordpress |
I am writing a plugin that upon activation, it creates a few new pages. On these pages, I want to disable the comments option. I am adding the new pages via the code below: <code> $page['post_type'] = 'page'; $page['post_status'] = 'publish'; $page['post_author'] = 1; $page['post_parent'] = 0; $page['post_title'] = 'Te... | As per the documentation : <code> $page['comment_status'] = 'closed'; // allowed values: 'closed' or 'open' </code> | How To Disable Comments On New Page | wordpress |
I am new to all child-theming things and trying to override an array value which is declared in one of the php files. I also don't want to override the whole php file, because it has many other functions in that file that I don't want to duplicate. How can I do this? The <code> maintemplate-somefile.php </code> : <code... | I don't know exactly how your themes-- parent and child-- are constructed but the child theme's <code> functions.php </code> loads before the parent's . So, if this template is included via <code> functions.php </code> changes you attempt to make in the child <code> functions.php </code> to that <code> $Icons </code> a... | Extending arrays in parent theme without completely overriding the files | wordpress |
Can anyone tell me how to get all the users who have author privileges by querying the DB in WordPress and order them by number of posts written by them. I use the following query to get all the users from DB: <code> $authors = $wpdb->get_results( "SELECT ID, user_nicename from $wpdb->users ORDER BY display_name"... | Unless you want to retrieve custom data from the database, you will hardly ever need to make use of the <code> WPDB </code> class (or its global object, respectively). Though it is obviously possible to do things that way as well. Just for the sake of completeness, if you had a reason to not use a more abstract functio... | Getting all the users who have author privilege | wordpress |
The 'Leave a Reply' section at the end of my posts are not displaying after changing to the 'The Morning After' theme. Comments and reply sections are displaying when I revert to the Twenty Eleven theme. I have tried re-installing the theme but it is still not working. Example post at: http://richashworth.com/testing/ | After the kerfuffle of logging in and acquiring the theme, I got to the code: <code> $comm = get_option( 'woo_comments' ); if ( 'open' == $post->comment_status && ($comm == 'post' || $comm == 'both' ) ) { comments_template( '', true ); } </code> Your comments are not showing because in the woothemes settings... | Comments not displaying after changing theme | wordpress |
I am showing <code> details of all the authors including the avator, Name, Description in my blog </code> . When I click on the <code> OPTIONS TO CONNECT </code> link a <code> lightbox </code> will open and I need to <code> show those details(which I mentioned above) inside the lightbox including the title of the lates... | You will want to implement that using AJAX. Read these two articles from the Codex for further information about integrating Wordpress with some AJAX action: AJAX AJAX in Plugins Just to give you a head start, you will want something like this: Client-side (Javascript) <code> $(element).click(function() { var data = { ... | Showing Author Information and Latest Post by author in lightbox when clicked on the name of the author | wordpress |
I am wanting to update the meta_key in the database to reorder postmeta from the frontend. I'm using jQuery UI drag and drop to move items into an order, I can update the values but the meta_key is not so easy. My meta_key and values are like this: add_task_0_assigned => value add_task_0_complete => value add_task_1_as... | I don't have time for a detailed reply but some ideas: 1) Use arrays in the front end. Make your input ID's like <code> add_task_assigned[] </code> and <code> add_task_complete[] </code> - these appear as arrays in the back end. It's not great practice, but it works. 2) Use an array in the backend. Store the meta as <c... | updating meta_key from the frontend | wordpress |
I am using the technique described here stackexchange-url ("Seperating Custom Post Search Results") and here stackexchange-url ("posts_groupby problem") to seperate my search results and group them by post type. This means I have the following code. In functions.php <code> add_filter('posts_orderby', 'group_by_post_typ... | What kind of control do you want exactly? There are, for example, plugins that provide a UI through which you can order posts by various parameters. If you just want to order them all by one parameter that will not change, you can simply add it to your query (since stackexchange-url ("you can order by multiple conditio... | How to order separated Custom Post Search results | wordpress |
I have a client who has requested a WP based portfolio where they will present their projects and clients, filtered by categories and tags. They also wish to filter all projects done for a particular client. I decided to use regular posts for the projects, but I'm unsure as to what would be a good setup for clients. My... | It sounds like you need both clients and projects to have "post-like" capabilities, meaning that using a taxonomy for clients wouldn't make much sense. In this case, I would highly recommend the amazing "Posts 2 Posts" plugin by Scribu, found here: http://wordpress.org/extend/plugins/posts-to-posts/ The plugin allows y... | Structure for projects and clients | wordpress |
I try to fetch all products for a given category managed by the wp e-commerce plugin, but the code I use is not looping all the products returned. All the code is a sort of API to look for products and return them later to an extern application with JSON. First , this is all the code I use: <code> $catid = $_REQUEST['c... | The default number of posts for WP_Query is stackexchange-url ("ten posts per page"). Try adding <code> 'posts_per_page' => -1 </code> to your <code> $wpec_args </code> : <code> $wpec_args = array( 'post_status' => 'publish', 'post_type' => 'wpsc-product', 'posts_per_page' => -1, 'wpsc_product_category' =&g... | Code not looping over all products of a given category | wordpress |
I would like to add a container around the default [gallery] output. I don't want to modify any core files, and add unusual lines to my functions.php. How to do that? What's the most elegant method? | Well, since you don't want to edit core files (which is absolutely fine, and unnecessary) and also don't want to do it by means of PHP (meaning <code> functions.php </code> , for instance), here's a jQuery approach: <code> $('div[id^="galleryid-"]').wrap('<div id="SOME_ID" class="SOME_CLASS" />'); </code> BTW, yo... | How to add a div around the default gallery output | wordpress |
I have a single email field form on a static, 1 page html website which upon submitting, I would like it to pass the entered email to a WordPress install to use as an email for a new account. The html website and the wordpress website are on different domains. Can WordPress handle this without a custom plugin? I have t... | Sure WordPress can. But ... do you really want to do this? It could be a bit risky. OK, you want to do it, let's start with it. At first you need a php file where you send the data to. Let's assume your submission form is on www.domain-send.tld and your WP install is on www.domain-receive.tld. You have to create a php ... | Create WP account from an external email form submission? | wordpress |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.