question stringlengths 0 34.8k | answer stringlengths 0 28.3k | title stringlengths 7 150 | forum_tag stringclasses 12
values |
|---|---|---|---|
I removed the categories column from "All posts" page by applying this code. <code> add_filter("manage_edit-post_columns", "my_post_edit_columns"); function my_post_edit_columns($columns){ unset($columns['categories']); return $columns; } </code> This code removed categories column. But still i see the categories filte... | I tested this and it works for removing the categories dropdown on the All Posts page: <code> add_action( 'load-edit.php', 'no_category_dropdown' ); function no_category_dropdown() { add_filter( 'wp_dropdown_cats', '__return_false' ); } </code> -- below: old answer when I misunderstood the question -- The code you post... | How to remove categories filter from wordpress admin? | wordpress |
For some reasons I need to degrade <code> wordpress </code> version of a site(I understand that it is not a good practice to do and I can fall into many troubles by doing so) but I still need to do it for some reasons. I want to degrade from <code> 3.0 </code> to <code> 2.9 </code> .I tried to upload the <code> wp-admi... | Like you said, downgrading would be a bad practice and is not at all recommended. Please make a backup of your DB before continuing, just to play safe. It looks like you've only replaced wp-admin folder. WP Updates are not limited to wp-admin. Try replacing wp-admin, wp-include and all those files in the root directory... | Reverting from a newer version of wordpress to an older version | wordpress |
I've got a string with post ID's: <code> 43,23,65 </code> . I was hoping I could use <code> get_posts() </code> and use the string with ID's as an argument. But I can't find any functions for retrieving multiple posts by ID. Do I really have to do a <code> WP_query </code> ? I've also seen someone mention using <code> ... | You can use get_posts as it takes the same arguments as WP_Query. To pass it the IDs, use 'post__in' => array(43,23,65); (only takes arrays). Something like: <code> $args = array( 'post__in' => array(43,23,65); ); $posts = get_posts($args); foreach ($posts as $p) : //post! endforeach; </code> I'd also set the post_t... | How do I get posts by multiple post ID's? | wordpress |
I have a weird issue after upgrading to WP 3.3. Currenty I have a Dreamhost dedicated server with WP 3.2. I've tried two times to upgrade to WP 3.3 and both times I had the same issue. First time, I tried to upgrade directly from the admin panel. Everything seems to be OK but all the updates against the DB perform erro... | Finally I found the problem. I was using the Cloudflare service. Something in the acceleration technology they are using does not works well with WP 3.3. I've disconected the service and everything works fine. Just warn everyone. Regards | Publish issue after upgrading to 3.3 | wordpress |
I have code like below (I removed all the uneeded HTML and stuff for this post). The code is for my author.php page. So it shows some author data at the top of the page then runs <code> rewind_post() </code> so it can show the post's by that user. The problem is for the admin, it is showing all the menu items as post i... | I found the problem, this function was causing the problem.... <code> function include_custom_post_types( $query ) { $custom_post_type = get_query_var( 'post_type' ); if ( is_archive() ) { if ( empty( $custom_post_type ) ) $query->set( 'post_type' , get_post_types() ); } if ( is_search() ) { if ( empty( $custom_post... | When I use rewind_post() it shows menu items in my loop | wordpress |
I found this example of a shortcode on the Internet: <code> function project_shortcode( $atts, $content = null ) { extract( shortcode_atts( array( 'class' => '', 'id' => '', ), $atts ) ); return '<div id="' . $id . '" class="' . $class . '">' . $content . '</div>'; } add_shortcode('button', 'project_s... | Don’t use output buffering. It is too slow and sometimes hard to debug. Use heredoc . Example: <code> $output = <<<MYUNIQUENAME <div>$foo <p>Some $bar</p> </div> MYUNIQUENAME; </code> | How to return multiples lines in a shortcode? | wordpress |
I have a need to set the <code> wp_postmeta </code> value (in table: <code> wp_postmeta </code> ) on every post that has a specific <code> term_taxonomy_id </code> (in table: <code> wp_term_relationships </code> ): Specifically: run a query against every <code> post_ID </code> that has <code> term_taxonomy_id </code> v... | I think I know what you mean, and if that is the case it's actually a straightforward operation. Firstly get all the <code> object_id </code> s from the <code> term_relationship </code> table. <code> $results = $wpdb->get_results("SELECT `object_id` FROM $wpdb->term_relationships WHERE `term_taxonomy_id` = 18"); ... | MySQL query to set wp_postmeta using term_taxonomy_id value | wordpress |
Basically going mad on this one. Been googling about for quite some time now to find an answer. Most hits are on year old posts. I tried to alter how TinyMCE initiates with "remove_linebreaks" set to false in functions.php. The thing is altering text, at least this little group of three paragraphs in two td-cells in a ... | This error was corrected when I installed the plugin TinyMCE Advanced and activated the option "Stop removing the <code> <p> </code> and <code> <br /> </code> tags when saving ...". | WYSIWYG eating up first p in td | wordpress |
I'm making a custom post type which is intended to be viewed by logged in users only, I've created a single-{postType}.php to override the default rendering and has included a logincheck in the top which redirects to the login page and back, after login. I've not enabled archive for my post type, so I imagine I don't h... | A simple filter on your post content can do this job easily. Lets try this code <code> function tp_stop_guestes( $content ) { global $post; if ( $post->post_type == 'YOUR_CUSTOM_POSTTYPE' ) { if ( !is_user_logged_in() ) { $content = 'Please login to view this post'; } } return $content; } add_filter( 'the_content', ... | Making custom post type visible for only logged in users | wordpress |
I need your advice! I have a small hobby website, it's a small music magazine, with all the content published by me. It's setup with an open source Wordpress Theme with my custom graphics and CSS. I want to turn it into something else now, and allow users to have the ability to be able to sign-up > login > and post art... | What you're asking for is part of core WordPress functionality. Simply assign the appropriate user role to new users. For example, the Contributor user role can draft - but not publish - new posts. Such posts then require someone with publish privileges to approve/publish them. To set the default role for new users, go... | Allowing users to Sign-up > Login > Post articles that need approval | wordpress |
I've created a plugin that calls a list of posts and grabs external API data. I am using get_posts to grab the list (because I need to feed the array of links into the API query) For whatever reason, any attempt at pagination either fails completely or loads the same posts. Since nothing I've done has worked, I've remo... | This is what ended up solving it (I'll include the relevant parts) <code> $total = wp_count_posts()->publish; $perpage = 10; $curpage = isset( $_GET['pagenum'] ) ? intval($_GET['pagenum']) : 1; global $post; $args = array( 'post_type' => 'post', 'post_status' => 'publish', 'order' => 'DESC', 'orderby' =>... | paginate posts on admin page | wordpress |
I have a set of variable set up, created with add_filter in my plugin functions file: <code> add_filter('query_vars', 'user_country_var' ); add_filter('query_vars', 'user_lat_var' ); add_filter('query_vars', 'user_lon_var' ); </code> This is then referenced by some code which I used to process the filters. This worked ... | As I said, I was just missing the declaration to use the global $wp_query, so it wasn't accessing my filters. Here's what worked incase it helps: <code> global $wp_query; // pull variable from url if (isset($wp_query->query_vars['country'])) { $this->user_country = $wp_query->query_vars['country']; } else { $t... | My class function is not seeing GET url paramaters | wordpress |
I have a wordpress network. All the contents in my network are user generated. All posts links are now dofollow. I want to change it to nofollow. My site uses plugin for custom fields. I removed the default description area. So i cannot use the_content function. I use custom fields for all. I tried many auto nofollow p... | Code Available here which is written by chrisguitarguy | Auto Nofollow attribute in custom field links. How? | wordpress |
I just set up a blog on Wordpress.com, and the problem is, if I write: <code> something something blah blah </code> That empty line in between doesn't show up! What can I do about this? | WordPress.com and self-hosted strips extra white space. But you can try forcing a new line with a nonbreaking space in between bold tags: <code> <b>&nbsp;</b> </code> | Newlines in Wordpress.com blog? | wordpress |
OK, seriously. I have a really modified index.php. The result: after the second paginated page, the page returns <code> Not found </code> and 404, while the posts are shown already. Can anybody tell me, what it happening? Working example with the problem: everything ok: http://petermolnar.eu/photoblog everything still ... | It's not correct solving of issue and it's not a bug. Here is explanation why it happens: "Pagination is calculated before you get to the template file that runs query_posts. The proper way to alter posts_per_page conditionally is to use the pre_get_posts hook to modify the main query." stackexchange-url ("stackexchang... | Page not found yet the posts are listed? | wordpress |
Anyone knows how to do so? What about if you want to edit the pics a little bit before pasting. I am using windows. | It should not be a lengthy process. Straight from the web: Right click > <code> Copy image location </code> WordPress: Add Media > <code> From URL </code> Editing a picture: Right click > <code> Copy image </code> Paste into your favorite photo editor (e.g. GIMP) Edit and Save WordPress: Add Media > <code> From Compute... | How to copy and paste a picture found on the web to wordpress easily | wordpress |
I am using LaTex from the JetPack plugin, which is similar but not identical to TeX for maths, for my WordPress blog where I post course work. How do I get the generated formulae to centre on the line so the equals sign lines up with the normal text that I have typed? to see what I mean please check this blog entry. he... | I haven't used that plugin, so I can't speak to whether there are any configurations that would help. However, I think your issue could be solved with a simple css rule: <code> img.latex { vertical-align: middle; } </code> would center all your LaTeX-generated images on the line they fall on. | Keeping LaTeX contents in line with non-latex text | wordpress |
I have a multi-site network, on one of the sites the access is restricted to registered users, and only an administrator can create users. I was asked to get rid of the confirmation email sent to new users, and I know you can select an option to add the user without sendind the email. The problem is, that option is onl... | Haven't really tested this, but WP actually uses this filter if you check the "noconfirmation" box, except that it does so only for super_admins, like you said: <code> add_filter( 'wpmu_signup_user_notification', '__return_false' ); </code> | how to disable user confirmation from administration? | wordpress |
I am having a weird issue lately, in the WP Admin panel, all my Post show up under Post and under Pages, they all link to the same article. If I create a new Post it shows up under Pages as well. I am running the newest stable version of WP, I have tried all my themes even the twentyten and twentyeleven themse, it stil... | I just wanted to post the solution here instead of deleting just in case this ever helps anyone else. The problem was this 1 small function I had tucked away in a setting file... <code> /** * change number of posts shown per page in admin area */ function admin_pagination(){ global $wp_query; $per_page = 5; $wp_query-&... | Post show up as post and pages | wordpress |
I'm trying to figure out how to create a wordpress role that grants the user the ability to only moderate all comments (including for posts that aren't there own). The only way I've been able to do this is by granting them the ability to edit other peoples posts, but I don't want to give them that much permission. Any ... | Justin Tadlocks Members Plugin is a great start. Create a new role and give them the permission of <code> moderate_comments </code> and you should be good to go. | Grant a person permission to moderate all comments on a blog without giving them the ability to edit other peoples post | wordpress |
I recently changed the base domain on my Wordpress website from http://www.fsdegrees.com to http://www.56degrees.co.uk . I would like to create various of 301 from old domain to new one, but for some reason I can still access pages using the old domain www.fsdegrees.com/blog I though it should come back with 404. I'm j... | I just did this on a client site. I set up my rules like this: <code> RewriteEngine on RewriteCond %{HTTP_HOST} ^(.*)fsdegrees.com [NC] RewriteRule ^(.*)$ http://www.56degrees.co.uk/$1 [R=301,L] </code> The first rule checks the incoming domain and verifies that it is the old domain. The second sends a 301 redirect and... | Two domains on one Wordpress Installation | wordpress |
I am assuming because I don't have a category template it is defaulting to the archive template, would that affect the outcome. it seems to output all the posts that have categories: http://www.tigerstudiodesign.com/category/branding/ this is source for archive page: http://pastebin.com/a5jxtBSe | this is the problem, starting at line 46: <code> $args = array( 'post_type' => 'post' ); $post_query = new WP_Query($args); if($post_query->have_posts() ) { while($post_query->have_posts() ) { $post_query->the_post(); //stuff endwhile; endif; </code> you're not using the original query for the page, which c... | category filter doesn't work | wordpress |
I am trying to change the header image every "n" second/minutes. Have looked at a number of solutions on the web and am at present using the PHP code fragment below available at http://ma.tt/scripts/randomimage/ : It still only changes the image on a page reload not every 'n' minutes. I have also seen the post at: stac... | To answer your question, in my opinion you would be way better using JavaScript. jQuery can be a great tool to do this. I would suggest installing the jQuery Cycle Plugin. into your theme. You can still load the images into your theme with PHP but if you want to change the image without needing to reload the page you'l... | Changing Header Image Every N Minutes/Seconds | wordpress |
Is there a way to add a RSVP form to a Facebook event in a Wordpress post? (let's assume I have a website linked to a Facebook application and I want to publish public events I have published on a Facebook page also on my website, letting people RSVP from Wordpress and only from my FB page) thanks | I'm also working on this right now, I'd love if you post your final solution once you get there. Here are two tutorials that may help you. http://www.masteringapi.com/tutorials/how-to-check-status-and-rsvp-to-facebook-events-using-graph-api-fql/61/ http://www.masteringapi.com/tutorials/how-to-create-facebook-events-usi... | RSVP form for Facebook events from a Wordpress post? | wordpress |
I have a working query that calls all my posts that have a certain meta value for one of two meta keys: <code> $term = $_GET['term']; $args = array( 'post_type' => 'some_cpt_name', 'meta_query' => array( 'relation' => 'OR', array( 'key' => 'foo', 'value' => $term, 'compare' => 'LIKE', ), array( 'key' ... | As with most questions involving OR clauses, the answer is the same: use a custom query or alter WP_Query using the 'posts_clauses' filter. | Get posts by meta data OR title | wordpress |
I wonder if possible to disable a widget that belongs to a plugin that is currently active w/o touching the plugin code. For sample, I normally use a code like this to disable wordpress widgets, <code> unregister_widget('WP_Widget_Text'); </code> Now, I want to also deactivate let's say for sample the widget called "Th... | You must use <code> widgets_init </code> hook with a high priority for example this will remove the default WP Widgets <code> function unregister_default_wp_widgets() { unregister_widget('WP_Widget_Pages'); unregister_widget('WP_Widget_Calendar'); unregister_widget('WP_Widget_Archives'); unregister_widget('WP_Widget_Li... | Disable a plugin's widget | wordpress |
I use the following code in my template. <code> <?php echo human_time_diff(get_the_time('U'), current_time('timestamp')) . ' ago'; ?> </code> It shows like 2 days ago, 20 days ago, 90 days ago. Is there a way to show 1 week ago instead of 7 days ago, 1 month ago instead of 30 days ago, 1 year ago instead of 365 d... | As far as I know that's as deep as wordpress can go, you will have to use php to get it into weeks/months/etc. You have 2 options: Use <code> human_time_diff </code> and create a function that just calculates the differences(pretty easy to figure out 7 days = 1 week, etc). I would honestly not use <code> human_time_dif... | Human time difference in months instead of days. How? | wordpress |
This might seem like a duplicate, but other questions I've found seem to be about exporting/importing Wordpress, as a 1 shot deal. My situation here is quite different; I'm looking for a method/plugin that would write in the posts as they are posted on another site. Here is a more detailed way to explain it. My client ... | Try FeedWordPress « WordPress Plugins | Add posts from other Wordpress blog to the current one | wordpress |
A new site I'm working on is looking good in the major browsers, mac and pc, but something's wrong when viewed on an iPad2 - specifically the background tiles. In this design I use one giant bg image for the homepage, and a slightly different version for all the rest of the pages. I have a header.php and and header-2.p... | As it turned out I learned something quite useful and should have stopped back to post the answer here. After quite a lot of searching I found 2 articles: http://www.teknocat.org/blog/web-dev...-scaling-quirk which linked to: http://www.defusion.org.uk/archives/...iphone-safari/ To summarize: there's a size-limit for b... | Background tiles not working in iPad2 but ok everywhere else | wordpress |
I would like to set thumbnails for each tag. I actually need two type of thumbnails. 16 x 16 and 90 x 90. 16 x 16 will be used infront of tag name like stackoverflow. 90 x 90 will be used in tag page as tag avatar. Is there any readymade plugin available? Can anyone help me? Thanks | There are several plugins that allow you to attach images to categories/tags/taxonomy terms. Try googling <code> taxonomy images site:wordpress.org/extend/plugins </code> (the last part restricts the search to the Wordpress plugin repository) and you'll find a variety of recently updated plugins, including: Taxonomy Im... | How to set thumbnail for each tag? | wordpress |
In a small plugin I’ve written to add an IP address column to the comments list I want to remove the avatars. In line 156 I tried to use <code> remove_filter </code> : <code> remove_filter( 'comment_author', 'floated_admin_avatar', 50 ); </code> Well … I know this function fails sometimes , but why does it fail here? M... | As usual with hooks this is issue of timing. your init function is hooked to admin load process, which works fine for most things; however in this specific case function is added to filter in constructor of <code> WP_Comments_List_Table </code> class, and object is created in <code> edit-comments.php </code> after admi... | remove_filter( 'comment_author', 'floated_admin_avatar' ); doesn’t work | wordpress |
I need a foreach loop inside "the loop" This is my current code (index.php) : <code> <?php if (have_posts()) : while (have_posts()) : the_post(); ?> <div><a href="<?php the_permalink(); ?>" title="<?php get_the_title(); ?>"> <?php the_title(); ?></a></div> <div><... | Why not just use <code> the_ID() </code> which will always be unique and won't require any extra code to be used. | Simple foreach loop help needed in wordpress "the loop" | wordpress |
This is how i registered my sidebar: <code> register_sidebar(array( 'name' => 'Post Sidebar', 'before_widget' => '<div class="widgetdiv"><div id="%1$s" class="widget %2$s">', 'after_widget' => '</div></div>', 'before_title' => '<div class="titlediv">', 'after_title' => '<... | <code> register_sidebar(array( 'name' => 'Post Sidebar', 'before_widget' => '<div id="%1$s" class="widget %2$s">', 'after_widget' => '</div></div>', 'before_title' => '<div class="titlediv">', 'after_title' => '</div><div class="widgetdiv">', )); </code> You will have ... | How to customize wordpress sidebar widget | wordpress |
I'm building a theme that display image according to a category. Exemple, There a Fashion section, which is a page. On that page I have uploaded photo related to fashion. Another page is Portraits, which display portrait photography and so on. On my home page I would like to display all the recent photo that I have upl... | You can achieve that in many ways , but providing that you use a relatively new wordpress, you should use the_post_thumbnail(). you define it in functions.php , like so : <code> add_theme_support( 'post-thumbnails' ); //thumnails set_post_thumbnail_size( 150,230, true ); // defaultpost thumbnails add_image_size( 'your-... | Fetching Image from other post/page with custom type | wordpress |
Or does this break the purpose of the nonce, which I admint I don't quite understand it? :) For example on two ajax requests that run on page load, or when something is clicked: <code> $.ajax({ type: 'post', url: 'admin-ajax.php', data: { action: 'foo', _ajax_nonce: '<?php echo $nonce; ?>' } }); $.ajax({ type: 'p... | The WordPress nonce creation function is to be called only on the <code> init </code> hook: Use the init or any subsequent action to call this function. Calling it outside of an action can lead to troubles. See #14024 for details. Since the <code> init </code> hook "runs after WordPress has finished loading but before ... | Can I use the same nonce for multiple requests on the same page? | wordpress |
OK, here's my setup: Custom post type called "issues" (for a magazine) Posts with custom meta field matching the post ID of the corresponding issue. When I'm on a single "issue" post page, I want to query all the related posts, and display them grouped by their associated category. I have the post query working, I just... | You could look at modifying the WP_Query with a SQL command to group them, but that's a bit beyond my current MySQL, however, I've always done it by running a foreach on the taxonomy itself with this http://codex.wordpress.org/Function_Reference/get_categories Here's some sample code: <code> <?php global $post; $cur... | Group WP_Query by category | wordpress |
In my single.php file I would like to have a conditional that checks for the category of the post and display certain images and layout. Here is what I have: http://pastebin.com/dy6TE1yr | Look at http://codex.wordpress.org/Function_Reference/in_category Example: <code> <?php if ( in_category('rabbis-weekly-commentary') ) : ?> <div id="inner_header"> <img src="http://www.ifcj.ca/ifcj_ca/images/elements/commentary_header.gif" border="0"> ... <?php elseif ( in_category('yaels-weekly-co... | Problems with my conditionals in single.php by category | wordpress |
I have added new fields on the user profile page. I want to display a message that says: "It's good ... or not" I couldn't find a hook in the WordPress codex. I don't want to use a plugin only my own code I want change this code : <code> <div id="message" class="updated"> <p><strong>Updated profile &l... | You will have to use a gettext filter as there are no hooks or filters associated with your request. <code> function custom_user_message($translation, $text){ if('Profile updated.' == $text){ $current_user = wp_get_current_user(); $foo_condition = ''; //Do some checking here for user custom field if(!$foo_condition) re... | Modify Notification Message When Profile Updated | wordpress |
I need to set a custom template for a custom post type with standard wordpress functionality like this: Creating_Your_Own_Page_Templates I found these: 1 - custom post template , 2 - single post template , but its not working for a custom post type and this works only for built-in wordpress posts. | I went through the same problem a few months back. After several different ways I finally found a way that worked. Try adding this to your themes functions.php file (be sure to replace both instances of portfolio to match the actual names you use) : <code> <?php add_action("template_redirect", 'your_cust_pt_redir');... | How do I set a custom page template for a custom post type? | wordpress |
Here is what I am thinking of trying to hide wp-content from the urls of files included in page source. defining the following in wp-settings.php <code> define ('WP_CONTENT_URL','http://example.com/myownfoldername'); </code> and adding this to <code> .htaccess </code> <code> RewriteRule ^myownfoldername/(.*) /wp-conten... | You don’t need a separate rule in your .htaccess. Add … <code> define( 'WP_CONTENT_DIR', 'YOUR_LOCAL_PATH' ); define( 'WP_CONTENT_URL', 'YOUR_PUBLIC_PATH' ); </code> … to your <code> wp-config.php </code> . Do not write into <code> wp-settings.php </code> . This file will be overwritten during the next update – never t... | hide wp-content from urls | wordpress |
I'm coding my author template. I want something like this <code> <?php if(Author filled about me)) { ?> <div class="title">About me</div> <div class="descwrap"> <div class="descinner"><?php echo about me; ?> </div> </div> <?php } ?> </code> I tried this code. But it... | <code> <?php if(!empty($curauth->description)) { ?> <div class="title">About me</div> <div class="descwrap"> <div class="descinner"> <?php echo $curauth->description; ?> </div> </div> <?php } ?> </code> This should work for you. It checks if the variable is em... | Author template help. How to check if field exists in the profile? | wordpress |
I know this type of question has been asked over and over, but I couldn't find a solution for my problem, so I hope you can help me. I am using WP 3.3. and I have created a custom table. Now I want to insert some data into it, but I can't get it working. This is my code: <code> global $wpdb; $table_name = $wpdb->pre... | When <code> $wpdb </code> method doesn't perform as it should it is likely issue with resulting SQL query (because of wrong input or something else). Follow <code> wpdb reference in Codex </code> for troubleshooting: enable database error display via <code> $wpdb->show_errors() </code> check what query is being form... | $wpdb-> insert not working in any way | wordpress |
My header looks like this. I chnaged my author base from "author" to "user" So the user profile url looks like this. http://example.com/user/username What is the php function to get this url. I'm using like this <code> <a href="<?php echo esc_url( home_url( '/' ) ); ?>user/<?php echo $current_user->user_... | For all author meta details you can use <code> the_author_meta </code> http://codex.wordpress.org/Template_Tags/the_author_meta <code> <a href="<?php the_author_meta('user_url', $current_user->ID);?>"><?php the_author_meta('display_name', $current_user->ID);?></a> </code> If its for user m... | What is the php function for "user's public profile" | wordpress |
Already searched on here and couldn't find question so forgive me if it's been asked. I'm trying to use dynamic images on a homepage so my client can maintain the images. I've seen tutorials where one person uses post_thumbnails while another uses custom fields. Do I need to create a post for each image and display pos... | If your page is a portfolio index, where each image is meant to relate to a post or page, then post thumbnails would be the way to go. If your page is simply a gallery page, and the images don't relate to any content beyond that page, then the best method would be to upload images as attachments to that page and output... | For homepage images (for small business website), is it better to use custom fields or post_thumbnail? | wordpress |
I'm building a menu for my website. The static is looking like this: <code> <nav> <ul id="menu"> <li class="item_1"><a href="#">Item 1</a></li> <li class="item_2"><a href="#">Item 2</a></li> <li class="item_3"><a href="#">Item 3</a></li>... | Use a stackexchange-url ("custom walker"), remove anything you don’t need and add your classes. Here is a walker I use to get a list with clean markup: T5_Nav_Menu_Walker_Simple. Your could also filter <code> 'nav_menu_css_class' </code> or <code> 'wp_nav_menu_items' </code> . But a walker class is easier to understand... | wp_nav_menu(), how to change class? | wordpress |
I have three different levels on articles, Level1, level2 and level3. In the main section of my homepage, I show all three types of articles, but I want the user to have the option to hide/remove Level3-articles. The Levels are saved in the database as a meta_value. Each post got its level as a class; <code> <articl... | JavaScript is your friend! More specifically jQuery is your friend. You can us wp enqueue script and do something like this: Add this to your themes functions.php <code> <?php function my_scripts_method() { wp_enqueue_script('jquery'); } add_action('wp_enqueue_scripts', 'my_scripts_method'); // ?> </code> Then ei... | Let visitors show/hide a type of content | wordpress |
I'm a database noob so I'm a little bit clueless as to how to make a scheduled post via a plugin. Basically, does WP provide a reference API that would allow a plugin to create a scheduled post, like a user can do through the dashboard? | There isn't really an API for it, because from usage perspective it is quite simple. If data passed to <code> wp_insert_post() </code> has <code> publish </code> or <code> future </code> value in <code> post_status </code> field and date in the future then it is inserted in database with that date and <code> future </c... | Does WordPress provide an API for scheduling posts? | wordpress |
Basically I have my own theme and my own settings page. In that settings page I have a textfield which contains a Welcome Text to show at the top of the website. Now, I want this theme to works with qTranslate. To make the content of this textfield multi-language, it would be easy just to let the user add the qTranslat... | http://www.qianqin.de/qtranslate/forum/viewtopic.php?f=3&t=9 You can use <code> _e(); </code> function to echo your variable and <code> __(); </code> to return your variable. Qtranslate hooks into these functions and translates following your input. | qTranslate with my own theme and settings | wordpress |
I have a hierarchical custom taxonomy which I can display using <code> print_r(get_the_terms( $post->ID, 'taxonomic_rank' )); </code> : <code> Array ( [46] => stdClass Object ( [term_id] => 46 [name] => Aplocheilidae [slug] => aplocheilidae [term_group] => 0 [term_taxonomy_id] => 53 [taxonomy] =>... | There are probably some better ways to do this but you can always do a three simple <code> foreach </code> loops. I wrote an example function that does the job well and should serve you as a good starting point: <code> function print_taxonomic_ranks( $terms = '' ){ // check input if ( empty( $terms ) || is_wp_error( $t... | Custom taxonomy, get_the_terms, listing in order of parent > child | wordpress |
i had been banging my head for almost a day but could not resolve it. i need to show one post from 4 xx categories here is my code <code> <?php $cat_args = array( 'orderby' => 'name', 'order' => 'ASC', 'include' => '44,45,46,51' ); $fcategories = get_categories($cat_args); foreach($fcategories as $fcategory... | I've checked this code localy, here is the working snippet: <code> <?php $cat_args = array( 'orderby' => 'name', 'order' => 'ASC', ); $fcategories = get_categories($cat_args); foreach($fcategories as $fcategory) { echo '<dl>'; echo '<dt> <a href="' . get_category_link( $fcategory->term_id ) .... | Problem displaying one post from each category | wordpress |
UPDATE It seems that it might be a problem with the, <code> $("#opening_time").datetimepicker(); $("#opening_time_end").timepicker(); $("#closing_time_end").timepicker(); </code> If there is a <code> datetimepicker </code> call before a <code> timepicker </code> then the <code> timepicker </code> doesn't work. I do not... | Figured out that I needed to have the right js dependencies declared. This code now works. Hope it helps someone else with the same problem. Key line <code> array('jquery-ui-core' ,'jquery-ui-datepicker', 'jquery-ui-slider') </code> Full `wp-enqueue' code: <code> function pbd_events_jquery_datepicker() { wp_enqueue_scr... | Timepicker-addon doesn't show - Datepicker works fine? | wordpress |
How do I check an array of $curauth user data? I need to check to see if one or more $curauth fields have data, and if so, print some html. This throws an array error: <code> <?php if ( !empty( array ( $curauth->facebook, $curauth->linkedin, $curauth->twitter))) { echo 'echo me if any $curauth info exists f... | Try <code> <?php if ( !empty( array ( $curauth->facebook ) ) || !empty ( array ( $curauth->linkedin ) ) || !empty( array( $curauth->twitter ) ) ) { echo 'echo me if any $curauth info exists'; } ?> </code> Note: This can be all on fewer lines, I've just put in additional line-breaks to make it all fit to ... | How to check an array of $curauth fields? | wordpress |
I'm using <code> wp_handle_upload </code> to allow users upload <code> .csv </code> files in the front end and it's working fine. I was wondering how can I limit this to only allow <code> .csv </code> files though since currently it accepts a wide variety of file types. According to the doc this should be possible by o... | Got it, looking at the source code I came up with this: <code> wp_handle_upload($file_input, array('test_form' => false, 'mimes' => array('csv' => 'text/csv'))); </code> To override the mime types just pass <code> mimes </code> as an array wit the key being the file extension and the value as the mime type. | How to set file type in wp_handle_upload? | wordpress |
I added slug input field in my custom post type and allow users to edit it at front end. Then, when insert post, I use this: <code> $wp_insert_post_args = array( 'post_status' => 'publish', 'post_type' => MY_POST_TYPE, 'post_author' => $this->creator_id, 'post_title' => $this->name 'post_name' => s... | If the slug exsit WordPress will add a number to the end. For example if you had two post named "test" you would get "test" and "test-1" Hope that helps | Is this the correct way to add post-slug input field? | wordpress |
When you activate a wordpress theme, it's always a hassle to find out which file to go to change things. Any idea how to simplify things? But on the other hand, considering the get_template_part functionality, this may be impossible. What do you say? | Hook onto <code> template_include </code> , set a global to note the template set by the theme then read that value back into the footer or header to see which template is being called for a given view. I spoke about this filter hook before in stackexchange-url ("get name of the current template file"), but go grab a s... | How do you find out which template page is serving the current page? | wordpress |
I want wp_link_pages (mutli-page posts) to display the page numbers, the word "previous" before those numbers, and a "next" after those numbers. It would look like this: Prev 1, 2, 3, 4 Next I'm attempting to do this without a plugin. Here's what I've tried so far, but it isn't working, it is only displaying numbers. <... | The function you're using, <code> wp_link_pages </code> ­Codex , does not have the feature you're looking for by default. However you can easily extend it by using a callback function, registered as a filter on that functions arguments: <code> add_filter('wp_link_pages_args', 'wp_link_pages_args_prevnext_add'); </c... | Paged posts - how to use numbers and next/previous links? | wordpress |
I have developed an educational courses database of several countries using several taxonomies. Country, institute, study level and some other are taxonomies. If user click on some country, all courses in that country will appear. How the result can be filtered (institute, study level etc) while remaining in the same c... | You could make use of <code> add_query_arg() </code> and <code> remove_query_arg() </code> here. For example http://yourdomain.com/?country=india&institute=pune-university would show results of Pune University in India. You could add <code> s=symbiosis </code> to search in the filtered results too. Basically this u... | Taxonomy search filters | wordpress |
I have a child theme in wordpress and one of the plugins I am using is called jigoshop. I made a copy of a few php classes from the plugin and placed them in my child theme folder. I want these clases to override the ones from the plugin folder. How would I go about doing that? Thanks!! | I'm assuming this is mostlikly a hiearcy problem. For example, your stylesheets load in the order of child theme then plugin. What you need is to load the plugin styles first then your child theme. You have a few options: Add the Css for your plugin manually after <code> wp_head() </code> in your <code> header.php </co... | How to override my plugin's php classes with duplicates that are in my child theme folder | wordpress |
I'm setting up a site using BuddyPress and I'd like to be able to give members the option to create new blog posts that are viewable only to members of the blog itself. I've found a couple of plugins (s2member, for example http://buddypress.org/community/groups/s2member/home/ ) that seem to do a great job of allowing t... | I'm not sure if this is what you're looking for but it has worked for me in the past: http://wordpress.org/extend/plugins/wordpress-access-control/ You may have to modify it to allow members to check the box but it's a start. | WordPress/BuddyPress plugin to allow users to create members-only posts | wordpress |
When I add lines 3 - 19 to the top of functions.php, then try to update image.php I get the error "Warning: Cannot modify header information - headers already sent" when I try to update my image.php. The code on lines 3 - 19 creates custom next/previous links for my image gallery and redirets the last one to a "more ga... | I've seen in the pastebin the problem and merged the whole code together again. Put this first part completely into your functions.php. <code> /** * Display previous image link that has the same post parent. * * @since 2.5.0 * Original version in /wp-include/media.php * @param string $size Optional, default is 'thumbna... | Functions.php Problem | wordpress |
I am trying to create a theme options menu item for my custom theme. However, when I add the following piece of code in the functions.php file... <code> add_menu_page('Page title', 'Asteria', 'manage_options', 'ThemeOptions', 'my_magic_function'); </code> It gives me the following error when clicking on the menu item..... | Theme Options should use the <code> edit_theme_options </code> permission, not the <code> manage_options </code> permission. The former is the permission intended for editing Theme options; the latter is the permission intended for editing site options. | Theme Options Menu Item - Permission Issue | wordpress |
This one might be a little tricky, but I'm looking for a way to make the Recent Comments widget on the wp-admin a bit more useful/action-driven. I'd like to be able to filter to only show the Pending comments (as those would require an action to them). I saw on line 45 of <code> wp-admin/includes/dashboard.php </code> ... | There doesn't seem to be a hook/filter available to control comments displayed in the widget. You might have to create new dashboard widget for this as new plugin or as part of themes function.php | Modify "Recent Comments" List in WP-Admin | wordpress |
hello guys im making child theme of melville and i wanna make a custom page with a static menu (as in not made with wp ) of my own and under it i wanna display the content and i use this <code> get_template_part('loop' ,'home-page') </code> where the home-page its name of my custom page and i do have the loop file in m... | According to the codex your file needs to be called <code> childtheme/loop-home-page.php </code> if you did just then <code> <?php get_template_part('loop' ,'home-page') ?> </code> you would call it loop.php not sure if that helps at all. Another thing is make sure your page is using your custom template file as ... | melville and its child theme | wordpress |
I have a site with a few custom post types, each with their own custom data, meta boxes & assets (stylesheets, images, JavaScript). Typically I'd hook onto <code> add_meta_boxes </code> to register all my meta boxes and <code> save_post </code> to handle the data, but in this case I'd like to wrap all the functiona... | Not really a complete answer, but since this question's become a ghost town I thought it was worth adding. <code> $post_type = get_current_screen()->id; // when on post.php or post-new.php </code> It's been around for a while, but with 3.3's much improved screen API I can see this opening a new world of easier, on-d... | Wrap meta boxes & data handling for specific post types in classes? | wordpress |
I am building a website using Thesis theme and am using Thesis Custom Loop API with custom WP_Query . When I do this on single page it doesn't show the comments form. How can I add a comment form on the single post page | Insert this code after the loop: <code> <?php comment_form(); ?> </code> | Thesis Theme Custom Loop | wordpress |
So it's quite obvious to how exclude certain categories from within a template, but I don't want to have to modify 4 templates so that they ignore a certain category. Is there a way that I can exclude a category from showing up within the "blog" set within the Reading settings? I'm assigning the blog to a Page named "B... | http://codex.wordpress.org/Function_Reference/is_main_query <code> add_action( 'pre_get_posts', 'foo_modify_query_exclude_category' ); function foo_modify_query_exclude_category( $query ) { if ( $query->is_main_query() && ! $query->get( 'cat' ) ) $query->set( 'cat', '-5' ); } </code> So it's quite obvi... | Functions.php: Exclude Category from "Blog" | wordpress |
I'm trying to add a class to anchor links of children element in wp_nav_menu both for pages and posts. Is there a way to modify the Nav Menu Walker and do so? Basically my custom walker looks like this: <code> class Main_Nav extends Walker_Nav_Menu { function start_lvl(&$output, $depth) { $indent = str_repeat("\t",... | I was able to add a "parent" CSS class to the anchor tag of menu items who have children by following this answer: stackexchange-url ("Add 'has_children' class to parent li when modifying Walker_Nav_Menu") Here's an example: <code> class Main_Nav extends Walker_Nav_Menu { /** * @see Walker::start_el() * @since ... | wp_nav_menu: check if the list item has children and add a class to anchor link | wordpress |
I've added some extra $curauth fields to the user profile page via ths method: <code> function change_contactmethod( $contactmethods ) { $contactmethods['twitter'] = 'Twitter URL'; // more $contactmethods go here return $contactmethods; } add_filter('user_contactmethods','change_contactmethod',10,1); </code> And they a... | Use the empty() check on them. <code> if ( !empty( $curauth->twitter ) ) { // do stuff } </code> This is best practice since empty avoids the property not existing error. | How do I use "if field exists" with $curauth? | wordpress |
I got a set of meta boxes on a custom post type. Two of them are simple input/text-type fields, that should have autocompleted input: A) Another Custom Post Type B) Users Now I have the problem that I need to somehow trigger the autocomplete event. So far I have this pretty simple definition: <code> jQuery( document ).... | Use jQuerys <code> getJSON </code> in the autocompletes source method and use WordPress' admin-ajax.php to handle the request, to avoid having to find wp-load.php (which may have been moved) and would load WordPress on every request. First of all: get the ajax url of your WordPress blog: This is simple: <code> admin_ur... | Ajax and autocomplete | wordpress |
If my hosting provider does not provide mod_rewrite mode. What thing will get effect on my wordpress? I bought a hosting, they claim they does not provide it. I have installed WP and the web is running. I dont know what features I am missing. The output of following command does not have mod_rewrite anywhere. <code> &l... | the <code> Redirect </code> directive is part of Apache's <code> mod_alias </code> , not <code> mod_rewrite </code> . <code> mod_rewrite </code> enables "pretty" permalinks, ie: <code> http://yourdomain.com/a-post-title/ </code> rather than "ugly" permalinks ie: <code> http://yourdomain.com/?p=99 </code> . WordPress wi... | What is the importance of mod_rewrite? | wordpress |
I'm new here xD I'm thinking of developing a plugin to allow users to block ANY spammy traces (IPs, Email addresses, Website URLs, phone numbers, phrases, etc etc) from those evil spammers. BUT, after some research, I've found that these evil idiots use random IP addresses, which means the plugin could result in blocki... | ...is there any other plugin out there that will do EXACTLY this Not a plugin, but yes - this is the standard behavior of the comment moderation system in WordPress. BUT if ANY user visits bob.com and posts a comment containing the blocked email, website url or any other blocked material, then the IP of that user will ... | Has anyone developed a anti-spam plugin to simply allow users to BLOCK whatever they wish to, but one that will also go easy on IP addresses? | wordpress |
I will be modifying a theme to add post types to it here soon. I know there are post formats and I realize I could make the behavior be whatever I want. However, I would like them to be used for how they were intended. So for instance, on a link type, if I click the title should it go the the item I linked to? If there... | Post Formats are merely a way to indicate to the theme how a post should be styled. So, ultimately, it's up to you. But I know how useless "it's up to you" can be ... so let me give you a couple of examples: WPCandy If you are knew to the WordPress community, you should start reading this site. It's a fantastic resourc... | What is the recommended behavior for the post formats? | wordpress |
Everyone on this forum has helped me tremendously. Thank you. I now have a page that functions the way I want it but my code seems to be cumbersome. To figure out a string to echo I have a long series of <code> if </code> <code> else if </code> statements that I can't figure out how to streamline. Here is the code in f... | This question probably belongs to stackexchange-url ("Code Review"). Anyway, you can fill your event properties inside an array, which you can iterate: <code> $events = array( 'opening' => array( 'time' => '...time here...', 'formatted_time' => '...time here...', 'label' => __('Opening:'), // or ucfirst($ty... | Too many if's and else if's ?? - Must be better way | wordpress |
I find the 3.3 Tooltips annoying when I'm upgrading many live and dev sites. How do I disable them via functions.php? Unenqueue wp-includes/js/wp-pointer.js ? | You could also remove the pointer script and style from their respective arrays just after they have been registered using this method. <code> // Remove javascript add_action( 'wp_default_scripts' , 'remove_pointer_script' ); function remove_pointer_script( $wp_scripts ) { $wp_scripts->remove('wp-pointer'); } // Rem... | How to disable 3.3 Tooltips? | wordpress |
I'd like to edit the front page posts query to be slightly more advanced. Right now it excludes all posts in the Featured category. I'd like it to exclude the first 5 posts (or first n posts, really), but include the rest in the results. Here is the current call: <code> <?php query_posts("cat=-".$GLOBALS['ex_feat'].... | I ended up asking this in a better way, and received an answer: stackexchange-url ("Add a special filter link to All Posts in admin") | query_posts - slightly more advanced query | wordpress |
What is the proper way to define the post date when submitting a post from the front end using wp_insert_post ( Trac )? My snippet now is publishing with the mysql time... <code> if (isset ($_POST['date'])) { $postdate = $_POST['Y-m-d']; } else { $postdate = $_POST['2011-12-21']; } // ADD THE FORM INPUT TO $new_post AR... | If you don't add a post_date then WordPress fills it automatically with the current date and time. To set another date and time [ Y-m-d H:i:s ] is the right structure. An example below with your code. <code> $postdate = date('2010-02-23 18:57:33'); $new_post = array( 'post_title' => $title, 'post_content' => $des... | Proper formatting of post_date for wp_insert_post? | wordpress |
Right now I'm using the following code in my sidebar, which grabs the first term connected to a post from a taxonomy called "peoples" and displays it along with a link and description. <code> <?php $taxonomy = 'peoples';$terms = get_the_terms( $post->ID , 'peoples' ); if ( !empty( $terms ) ) : foreach ( $terms as... | <code> function trunc($phrase, $max_words, $after = null) { $phrase_array = explode(' ',$phrase); if(count($phrase_array) > $max_words && $max_words > 0) $phrase = implode(' ',array_slice($phrase_array, 0, $max_words)) . $after; return $phrase; } </code> This function returns the input shortened if there ... | limiting characters shown in taxonomy descriptions | wordpress |
I was really excited to see the new functionality with the media manager in WP 3.3 (specifically drag and drop uploads and automatic file type recognition) But I was disheartened to see no relief in terms of the confusing manner in which WP continues to handle image overwrites (by appending a number to the image and cr... | There's another plugin out there worth checking out: Enable Media Replace This plugin allows you to replace a file in your media library by uploading a new file in its place. No more deleting, renaming and re-uploading files! | WP 3.3 > Still no option to enable automatic image overwrites? | wordpress |
I know this is a really newbie question, but I can't seem to get the loop to pull from the posts. all it is doing is pulling from the page itself. I made a template and added the loop to it. <code> <?php if( have_posts() ) { while( have_posts() ) { the_post(); ?> <h2><?php the_title(); ?></h2> &... | Because you're on a page, that's only going to display the query for that page. As such, you'd have to create a new query to bring in the posts you want. Replace your loop with this: <code> <?php $args = array( 'post_type' => 'post' ); $post_query = new WP_Query($args); if($post_query->have_posts() ) { while($... | simply loop through posts | wordpress |
I am currently working on creating an events section for a website. My original plan was to create a custom post type for Events and create a new post for each event. Then I would query the top five events on the home page. My problem is that I need to have sub pages/posts for each event. These pages/posts will need to... | when you create a custom post type, and make it hierarchical, it will behave like pages. so you can have sub events the same way you have sub pages. look at <code> register_post_type </code> function arguments here : http://codex.wordpress.org/Function_Reference/register_post_type#Arguments then use <code> wp_list_page... | Creating an Events Feed with Sub Pages/Posts for Each Event | wordpress |
If there is a WordPress plugin which updates rows in a custom table, but that update encounters a row lock, what happens? E.g. two users simultaneously fire an update on TABLE1, one setting AGE=1 and the other setting AGE=2: Will there be a row lock at all? Will MySQL handle this "gracefully" and one of the 2 updates s... | Strictly from a MySQL Point-of-View SHORT VERSION MyISAM Storage Engine Table locks Writes are first come, first serve Reads slow down writes from initiating InnoDB Storage Engine Row locks Transactions (non blocking) Deadlock may occur when updating indexes LONG VERSION If the underlying tables use the MyISAM Storage ... | How does Wordpress handle MySQL row lock errors? | wordpress |
I'm wondering what all the <code> wp_2_* </code> , <code> wp_3_* </code> , <code> wp_4_* </code> , and <code> wp_5_* </code> tables are in the database. Does anyone know what they are? Some of them in my example are from plugins, but what does the <code> wp_# </code> prefix mean? and why are there then duplicates for s... | Those are from a multisite install. The numbers represent the blog_id and the tables are created when you add a new site to your network. http://codex.wordpress.org/Database_Description#Multisite_Table_Details http://codex.wordpress.org/Create_A_Network#Step_4:_Installing_a_Network | what is the wp_5_posts table in the database? | wordpress |
I'm using WordPress as a customised CMS for my fishkeeping website. Currently I'm developing a Custom Post Type called species which produces an information sheet about a specific species of fish. With no intention of patronising anybody, just in case people aren't familiar with the classification of fishes, in the exa... | OK, I've made a few subtle changes which have helped me to solve the problem. Firstly, a function to change the Title of the post. <code> function custom_post_type_title ( $post_id ) { global $wpdb; if ( get_post_type( $post_id ) == 'species' ) { $genus = strip_tags(get_post_meta($post_id, 'genus', true)); $species = s... | Custom post types - non-visible title and how it affects URL | wordpress |
I am learning how to integrate superfish drop down menus in wordpress and i am following this tutorial http://kav.in/wordpress-superfish-dropdown-menu I am using this theme with superfish integrated http://kav.in/blog/wp-content/uploads/dload/axtra_with_superfish.zip Has anyone else successfully been able to make the m... | I finally solved it.I had to add menus under the appearance menu and worked perfectly. | wordpress superfish dropdown menu | wordpress |
I want remove some options in visual editor. How to remove them? For example i want to remove the following. Align left option Align center option Align right option More tag option Add media Toggle fullscreen Toggle spellchecker Show/hide kitchen sink strikethrough Please help me to remove them from my wordpress visua... | Try this plugin. It allows you to add/remove buttons on the visual editor -> http://wordpress.org/extend/plugins/tinymce-advanced/ | How to remove some options in visual editor? | wordpress |
I use wordpress for a private site where users upload files. I use the "Private WordPress" to prevent access in to the site if the user is not logged in. I would like to do the same to the files uploaded in the uploads folder. So if a user its not logged in they wont be able to access to : https://xxxxxxx.com/wp-conten... | Only checking if the cookie exists, is not much of a strict protection. To get a stronger protection, you can pass or "proxy" all requests to the uploaded folder (exemplary <code> uploads </code> in the following example) through a php script: <code> RewriteCond %{REQUEST_FILENAME} -s RewriteRule ^wp-content/uploads/(.... | How to Protect Uploads, if User is not Logged In? | wordpress |
i wonder if there is a good way to create a shortcode that retrives a remote website FAV icon... i found this: stackexchange-url ("ANSWER") and tried to create a shortcode using it but failed (since i sux at shortcodes!) A quote from the answer i linked up: <code> <?php $url = 'http://example.com/'; $doc = new DOMDo... | OK... as it sometimes goes i cant rest until i find a way and i found a way to get the fave icon to proeprly display using google :) its really simple: <code> // here i get my URL from my custom post type $directoryNoHttpUrl = get_post_meta( $post->ID, 'directory_url', true ); //here i clean the url from HTTP or it ... | how to create a fav icon shortcode? | wordpress |
When going to http://craigmdennis.com/articles/ Wordpress uses the index.php template. When you go to http://craigmdennis.com/2010/05/ Wordpress uses the same template (markup below) but shows the same posts. I have tried: Disabling all plugins - no change Changing the permalinks back to default Using an archive.php fi... | That's because you overrule the query. You have to put the original info into the query_posts like so: <code> <?php global $query_string; query_posts($query_string . 'posts_per_page=10&paged='.$paged); ?> </code> For more info look here: http://codex.wordpress.org/Function_Reference/query_posts#Usage_Note | wordpress showing all posts instead of date range | wordpress |
I've made my first theme and now I want to create different "profiles". These profiles are just independent CSS files that user can try. The point is, how to make these files to allow users to choose the color scheme through the admin panel? It is, I don't want to allow users to access to the file system, so they will ... | This article should answer your question: Add a style switcher to your wordpress theme The article that I have linked above explains and walks you through on how to add a stylesheet switcher to your admin panel for your theme. It walks you through on how to use and add options to your theme. This is particularly intuit... | How to make a theme with more than one CSS file? | wordpress |
I have a problem adding a custom script to my functions.php file: <code> add_action('wp_print_scripts', 'load_AJAX_URL__'); function load_AJAX_URL__() { wp_localize_script( 'ajax_URL', 'MyAjax', array( 'ajaxurl' => admin_url('admin-ajax.php') ) ); } </code> Why is not working? any ideas? | The function <code> wp_localize_script() </code> is used to send variables to a script that has already been registered and enqueued. Do you have a js file that has been registered and enqueued and has the handle of 'ajax_URL'? If not, then that explains why it isn't working. Also, ajaxurl is already a js variable that... | adding custom script to functions file | wordpress |
I've found tweaking some of the text in WordPress to be pretty easy by adding in the following function (in lieu of using a separate plugin): <code> add_filter( 'gettext', 'of_site_translations', 9999, 2 ); function of_site_translations( $translation, $text ) { if ( $text == 'Posts' ) return 'News Posts'; return $trans... | You could just rename the labels associated with that post type. <code> class News_Post_Type { const POST_TYPE = 'post'; public static function init() { $post_obj = get_post_type_object('post'); $post_obj->labels->name = __('News Post', 'textdomain'); $post_obj->labels->singular_name = __('News Post', 'text... | Dealing with variables with gettext function | wordpress |
I would wish to add a filter to <code> _e() </code> and <code> __() </code> functions. The filter is FilterTextOfEmail() . This will basically detect any emails and add anti-spam method to it. I assume, the function for filtering should look like: <code> function my_wp_text_email_filtering ($content) { return FilterTex... | The filter name is <code> gettext </code> , and you would add it like this: <code> add_filter( 'gettext', 'my_wp_text_email_filtering', 10, 3 ); function my_wp_text_email_filtering( $translated, $text, $domain ) { return FilterTextOfEmail( $translated ); } </code> The $text argument is there also in case you want to ac... | How to add filter to __() and _e()? | wordpress |
I want to search a post based on the date it was posted. Example, in the search box, I would place there November 22, 2011 and all posts during November 22, 2011 would be displayed. Im desperate on how to do this. Any help would be very much appreciated. I am using a theme and it's search.php goes something like this. ... | You can make a custom page template for this specific search page http://codex.wordpress.org/Pages#Creating_Your_Own_Page_Templates . Then set some $_GET variables (using a form with method GET). And do a custom query for these $_GET values: <code> $date_query = new WP_Query( 'year=' . $_GET['year'] . '&monthnum=' ... | Search a post using the date it was posted | wordpress |
Please forgive me if this doesn't make a whole lot of sense. Is there a way to list all the posts created under one custom post type (eg: Blueprints) in the edit screen of another (eg: Buildings) in a checklist (or similar) so that individual bluebrints can be associated with individual buildings? I hope that made sens... | if you are trying to make ralationship links between post types, the easiest way is to use the great "posts 2 posts" plugin by Scribu : http://wordpress.org/extend/plugins/posts-to-posts/ here is the documentation : https://github.com/scribu/wp-posts-to-posts/wiki hope that could help. seb. EDIT : Is there a way to lis... | List of all posts in one custom post type in the edit screen of another | wordpress |
I am adding tinymce edior with new <code> wp_editor() </code> function on theme option page. On submit the theme option sends data to <code> option.php </code> where it saves. But tinymce doesn't seem to convert the line breaks into <code> <p> </code> tags as we see in the post and pages from the edit page. Other... | If you want the contents of an option, variables, or anything for that matter to be treated like post content you'll need to call the post content filters. <code> <?php echo apply_filters( 'the_content', $your_var ); ?> </code> Your data is then treated in the same way as post content is, inline with the code sam... | Tiny MCE not adding p tag when saving theme option | wordpress |
I would like to check if the tag name is the title of a post. And load that post page instead of a tag page. I have post_type "Cities" and suppose that users will tag normal posts with city names. And when user selects a tag, I would like to check if a "Cities" post exists with this tag name. And show this post if it d... | Try the code from this article: http://shailan.com/2246/how-to-redirect-to-single-post-page-if-there-is-one-post-in-categorytag/ It checks <code> $wp_query->post_count </code> and redirects to the only article of an archive if there is just one. | Redirect Tag to Post with the same name | wordpress |
I have a var set in my header.php file: <code> $myBool = false; </code> and in page.php, I try to echo it: <code> echo $myBool; </code> But the variable is never set. This doesn't help either: <code> global $myBool; echo $myBool; </code> Does anyone know what the problem is? Note: I'm using a custom theme based on the ... | You need to globalize it before you set the value, so in your header.php <code> global $myBool; $myBool = false; </code> and then in your page.php <code> global $myBool; echo $myBool; </code> just make sure you page.php includes the header.php file either directly or by calling <code> get_header(); </code> | Variables declared in header not available in other includes | wordpress |
I am using this code to display description of a taxonomy. <code> <?php $my_taxonomy = 'institute'; $terms = wp_get_post_terms( $post->ID, $my_taxonomy ); echo term_description($terms[0]->term_id, $my_taxonomy); ?> </code> What to do if I want to show description of sub or even sub-taxonomy? | Term description works only with term id and the taxonomy name, so if you want to get the sub term's description, you should first get all the children of a term(and their children, if its another level deep) and loop over their ids with a single <code> term_description </code> call per id. <code> <?php $my_taxonomy... | Description of a sub-taxonomy | wordpress |
I can't seem to find out what level of hosting I'll require for a WordPress e-commerce website. (yes, I realise this will vary based upon a heap of factors but I'm looking for some ballpark ranges for each factor) I'm thinking about such plugins as WP e-Commerce, Shopp, etc... for instance all those mentioned in http:/... | I would say for a small store stick with the basics, PHP 5.2.4+ and MySQL 5+ some individual plugins may require higher versions of PHP or MySQL. I don't think you would necessarily need a VPS depending on traffic. My general rule start small, if you grow, great, most host (and all good host) make it easy to upgrade yo... | Hosting Requirements for a WordPress e-commerce site? | wordpress |
I am using paginate_links on my custom page query. What I have already works sweet and this is the code I have so far... <code> <?php global $wp_query; $big = 999999999; // need an unlikely integer echo paginate_links( array( 'base' => str_replace( $big, '%#%', get_pagenum_link( $big ) ), 'format' => '?paged=%... | The function paginate_links() can return "plain", "list" and "array" ( http://codex.wordpress.org/Function_Reference/paginate_links ). Just define the type as array then you'll be to display it as you want: <code> <?php global $wp_query; $big = 999999999; // need an unlikely integer $paginate_links = paginate_links(... | add spans and characters into paginate_links | wordpress |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.