question stringlengths 0 34.8k | answer stringlengths 0 28.3k | title stringlengths 7 150 | forum_tag stringclasses 12
values |
|---|---|---|---|
We have a situation where a couple of our longstanding plugins (Google Analytics is one) are currently offering the option to " Activate " them. This figures, because Google Analytics traffic stopped dead a while back. So it seems as if it did turn itself off. Is this possible? Can the plugin's original author issue an... | As far as I know, a plugin can be deactivated in these conditions: manual deactivation failed plugin upgrade remove or rename the containing folder changing the active plugin list in the database Hopefully someone else will come through and add to this if I missed any. | Can a plugin deactivate itself? | wordpress |
I use WordPress for the majority of my client work. I develop locally with MAMP and then move the sites to the remote server when its time to go live or show the client the progress. I just migrate the files via FTP and export/import the database with phpMyAdmin, tweak the url and wp-config.php settings, etc. This flow... | Using multisite to develop then export to a single install is a bad idea. For one multisite behaves different than a single install and you want your dev to as close to the production as possible. It's also a pain in the a** to manually export the right db tables then import them into a new database. For developing loc... | I want to develop locally with Multisite, then migrate each site to separate remote WP installs | wordpress |
I need a plugin or some guidence on creating a user's own folder on user registation. For example...A user clicks on Register and registers ... I need wordpress to create a directory which would be linked with this user. The reason I want to do this is because I am going to work on building a dashboard where a wordpres... | You can use the <code> user_register </code> action to hook into the register proces and then create the user directory with <code> wp_mkdir_p </code> . <code> function create_user_dir($user_id) { $user_info = get_userdata( $user_id ); $upload_dir = wp_upload_dir(); $user_dir = $upload_dir['basedir'] . '/user_dirs/' . ... | Creating a user's own folder on user registration | wordpress |
I'm trying to find a way that changes the classes of the different nav menu items, based on the value of a meta key in the page. The menu currently looks like this: <code> <li class="menu-item-1">Menu item 1</li> <li class="menu-item-2">Menu item 2</li> <li class="menu-item-3">Menu item 3&... | Your code doesn't because the global <code> $post </code> refers to the post/page being viewed (if there is one...). What is passed with <code> nav_menu_css_class </code> is a menu item - this is a particular post type. Among its properties are: <code> object </code> which stores: the post type if the link refers to a ... | Nav Menu – Add class based on meta keys | wordpress |
When installing a plugin, it will not install if the directory to which it is attempting to install already exists. This means that users of our plugin must first manually deactivate and delete the plugin. Is there any way to forcibly overwrite the directory or to deactivate the plugin and delete the directory at insta... | If you're manually installing a plugin, you need to disable and delete the old version. However, WordPress does allow you to update your plugin programatically. If your plugin is hosted on the WordPress.org repository, it will prompt the users to install updates for you. You've likely seen this with Akismet and other p... | Is there any way to allow a plugin to write over a previous version? | wordpress |
Hard question to explain here. So here goes: I have a chapter/section scenario I'm trying to work out. The custom post type of "Books" has two custom taxonomies, "Chapters" and "Sections". The Chapters, are sort of like the higher level taxonomy with Sections being inside each chapter. So it would look something like t... | It would make more sense for the sections to be child terms below each chapter. See stackexchange-url ("my answer") to the similar question you referenced as well as MikeSchinkel's stackexchange-url ("explanation of hierarchical taxonomies"). Using the the term_id returned from get_terms use <code> get_term_children </... | Show list of custom taxonomies when another taxonomy is selected | wordpress |
Is it possible to remove alias from custom post type? Let me tell a bit more. For instance, I've created a post type, name "Book". So URL will be <code> domain.com/book/post-title </code> or <code> domain.com/?post_type=book&p=528. </code> I want the URL as <code> domain.com/post-title. </code> Is it possible? | In short - you cannot, or at least should not . <code> www.domain.com/post-title </code> is interpreted as post (if your structure is <code> %postname% </code> ) and/or a page - and WordPress is set to deal with them as such, including any conflicts. You can do the following: <code> add_action('init','wpse0845_add_rule... | Custom post type and URL | wordpress |
Does anyone know if there is a Wordpress function to get the timeout value of a saved transient? I am using a transient with a 5 minute timeout to cache data from a web API call locally. Between transient timeouts I load the data locally from the transient acting as a cache and secondary API throttle. What I would like... | So, after one minute of more thinking, there is an easy solution, although i did not try it myself: <code> $transient = '_transient_timeout_' . $_your_transient_name; $transient_timeout = get_option ( $transient ); </code> you should be ready to go with this. Another Way throught the database would be: <code> $transien... | Get the timout value of a saved transient? | wordpress |
Is it possible to override default <code> update_count_callback </code> for category? The default function counts published posts while I want to count private posts. I do not want to register a new taxonomy. | In your update_count_callback function do a check for $post-> post_status and don't increment your count if post_status is not private. See this stackexchange-url ("excellent answer") on writing a custom update_count_callback callback function. Edit: Misread the question. To override the existing default for the catego... | How to Override default update_count_callback for category | wordpress |
I've found that copying and pasting tables from MS Word was closest to easiest when it comes to making tables; rather than formatting a table from scratch in a WYSIWYG editor. The one shortfall I've found is that the "center" formatting does not copy over. It LOOKS like it does but the formatting is not actually applie... | I actually have a pretty awesome way to get the HTML output of the Microsoft Word table formatting. I use MS Live Writer and copy and paste from MS Word. Then I can simply view the HTML output and copy and paste that into the WordPress editor. It works perfectly. The only downside is that now you have a ton of in-line ... | Keep formatting for tables copied from MS Word? | wordpress |
Is it possible for the_category to display a post count within a post. Looks like Posted In: Category Name (3),Category Name (2) etc etc Possible or not? I would just use wp_list_categories but it needs to appear on a post by post basis like this post is posted in category x and y not just all of them... | How about this... <code> add_filter('get_the_categories', 'wpse50876_the_counter'); function wpse50876_the_counter($cats){ foreach($cats as $cat){ $cat->cat_name = $cat->cat_name.'('.$cat->count.')'; } return $cats; } </code> Try it... | Can the_category display a post count? | wordpress |
I'm writing a feed reader plugin for wordpress . I'm seeing a DB error that I can't figure out. First I create a table called user_entries . Then I put a sample entry into that table . When I try to delete an entry , I get a very strange error in my debug log. There are no foreign keys yet, no indices on the db, etc. [... | The code you've linked to above: <code> //$sql set to raw SQL statement $sql = $wpdb->prepare($sql,$feed_id); if($wpdb->query($sql)){ $resp->uf_error = $wpdb->print_error(); } </code> So if there isn't , an error you try displaying the 'error' with <code> $wpdb->print_error() </code> . Also <code> $wpdb-... | Why does this WPDB code throw an empty WPDB error? | wordpress |
Here is what I am doing: I Added wordpress media upload with iframe popup when a button or link clicked. And with click of insert into post the image url placed on a textbox. <code> send_to_editor() </code> function handles image insertion to editor <code> window.send_to_editor = function(html) { var imgurl = jQuery('i... | only overwrite the send_to_editor function when your link or button is click but store the old function to restore it so try this on a click event: <code> //store old send to editor function window.restore_send_to_editor = window.send_to_editor; //overwrite send to editor function window.send_to_editor = function(html)... | How to handle multiple instance of "send_to_editor" js function | wordpress |
http://www.mediwales.com/v3/members/ At the moment, if you search just using a keyword it shows the correct member. But if you just search using a category it just shows the full list. What code can I wrap around the member display to show the necessary member(s)? This is in functions.php <code> add_filter('pre_get_pos... | I don't typically do what you are doing the way you are doing it - but the glaring thing to me is that your setting your tax query with the associative key of <code> 'tax_query1' </code> , which as far as I know shouldn't work. It should simply be called <code> 'tax_query' </code> Try this: <code> $query1->set('tax_... | Search by category displaying wrong items | wordpress |
happytables has a cool feature where if you are logged in, on the home page && haven't uploaded a logo yet it will insert a drag + drop image box similar to image uploader on the backend. any ideas on how to pull this off? currently digging thru the source code, but if anyone has some pointers, i'd greatly appr... | I actually wrote this for Happy Tables so should be able to give you a couple of pointers, though I don't have time to go into too much depth at the moment. We use this "image well" on tables tables a fair bit, it's basically the drag/drop upload from the WordPress upload. Similar to something like this: https://github... | front end logo upload like happytables | wordpress |
I'm currently using this code to display a menu of pages. I'm using CSS to target the class <code> current_page_item </code> which works fine until you're on a page with a custom post type. How can I target that class when the page the user is on is a custom post-type such as news or events? <code> <div id="menu-rep... | If this is for a one-off site, I would suggest doing this with CSS. Philosophically, adding the <code> current_page_item </code> class to a menu item when that's not true feels a bit wrong too. As long as you're using the <code> body_class() </code> function on your <code> <body> </code> element in the theme, the... | Highlight menu item when on a custom post type? | wordpress |
I would like to add the dimensions of each image to the media library tab in the media uploader. I have a multi-author website, where I stackexchange-url ("require users to add a featured image with minimum dimensions.") To make it even easier for them, I would like to include the dimensions of an image in the Media Li... | IMHO, I think there's no much of a solution in the WordPress filters realm... I managed to make it work using jQuery. Maybe there's a cleaner way to write this, but it is functional as it is now. Tested in WP 3.1 through 3.4-alpha4 <code> /* * Display Image Dimensions on Media Uploader tabs (Gallery and Library) * Adde... | Add Image Dimensions to Media Library Tab on Media Upoader | wordpress |
I'm trying to make sortable columns in Sites and Links listings admin pages. <code> /wp-admin/network/sites.php </code> and <code> /wp-admin/link-manager.php </code> The problem is the following filters are not firing up in these screens, preventing the query modification. Is there other method that could be used? <cod... | I managed to order the link-manager.php by a custom column using this: <code> /* * Sort links using the custom column link_image */ function sort_on_field(&$objects, $on, $order = 'ASC') { $comparer = ($order === 'DESC') ? "return -strcmp(\$a->{$on},\$b->{$on});" : "return strcmp(\$a->{$on},\$b->{$on});... | Filters 'request' and 'parse_query' not firing in sites.php nor link-manager.php | wordpress |
I want to be able to select a subscriber an author of a post in the admin so it displays their name as having written the post, but I do not want to give them any additional privileges (if they login the only thing they can access is their profile). Is there a simple way to do this without having to change roles and ca... | This is a simple hack I wrote in a similar situation. It will display all the <code> Subscribers </code> in the <code> Author </code> dropdown on edit/add post/page, from where you can select any one you want. I think it should work for you... <code> add_filter('wp_dropdown_users', 'MySwitchUser'); function MySwitchUse... | Select subscriber as author of post in admin panel? | wordpress |
I want to list 'n' number of posts (ordered by latest first) -- post's title linked to the post's permalink -- from a tag on my WordPress blog. I also want to assign each link its own class or ID. I checked this doc on WordPress Codex , which is very relevant to what I need, but makes little sense to me (and I'm theref... | I don't know PHP, so'll try to explain after showing you the example PHP code that's needed to do what's asked in the question. CODE: <code> <!-- Featured Posts --> <div id="featured-posts"> <?php $count = 0; $some_featured_posts = new WP_Query(array('tag' => 'example2', 'posts_per_page' => 7)); wh... | List 'n' number of posts from a Tag, each with a different class or ID | wordpress |
I need to display a list of events by category and month. For example I need to list all the Mountain Bike events in July. | You can use the plug-in provided function <code> eo_get_events() </code> . This is essentially a wrapper for <code> get_posts() </code> , and so is intended for 'secondary' loops. The plug-in specific arguments can also be given to a <code> WP_Query </code> object - in case you wanted to modify the main loop. ( Related... | How to list events by category and month with plugin Event Organiser? | wordpress |
Here's the scenario: A user clicks on a tag which takes them to a list of all those posts with that tag. There are hundreds of posts, so the user needs a way to filter these. Here's the question: How would you build a drop down that a user can select to filter by category while on the tag page. Filter all Yellow tags b... | The function get_posts() allows you to set parameters for both categories and tags. You could build two drop down boxes that list all categories or tags and then use JavaScript or just make a new page to sort these. What other information do you need? | Sorting by tag or category | wordpress |
I run several wordpress sites that I created. A friend has asked me to help admin his existing site. So we want to add my userid as admin to his site. However, User | Add User allows addition of a 'brand new user' with new password, email ets. I would much prefer not to have another wordpress user account to remember. ... | WordPress user accounts are unique to a single installation of WordPress. Even if they are hosted on the same server, there's no simple way (and, more importantly, probably no secure way) to hook them together. WordPress accounts on WordPress .com can be added to other sites, but not accounts on self-hosted WordPress i... | Add existing user as administrator | wordpress |
I'm using this snippet of code to send a confirmation email to user's when their account is upgraded to a new user role. <code> function user_role_update( $user_id, $new_role ) { $site_url = get_bloginfo('wpurl'); $user_info = get_userdata( $user_id ); $to = $user_info->user_email; $subject = "Role changed: ".$site_... | Quite possibly something like this might work; <code> function user_role_update( $user_id, $new_role ) { $site_url = get_bloginfo('wpurl'); $user_info = get_userdata( $user_id ); if (user_can( $user_id, 'capability' ) ) { $to = $user_info->user_email; $subject = "Role changed: ".$site_url.""; $message = "Hello " .$u... | Send a confirmation of user role upgrade conditionally | wordpress |
I'm using Artiss Youtube Embed to embed youtube videos on my site which works great because it allows me to control all the parameters for the video player. My issue is that when the video has choppy playback when it's playing in a popup window. I allow users to click on thumbnails on the homepage and then I use Simple... | Thanks to David Artiss I figured out this was a problem with the Windows Mode setting. By default it's set to opaque but for it not to conflict with video in a popup | Choopy Video Playback in a popup using Artiss Youtube Embed | wordpress |
I'm trying to pull some custom data from a Cart66 table. My code works whenever I pull results from standard WP table in (my array is populated and the print_r shows that data), but not with any Cart66 tables (it prints an empty array). I am absolutely certain that I've got data in these tables (I've rechecked that I'm... | you do not have to specify the $wpdb again in your query, but be sure that your table uses the prefix, if it has one. if it doesn't, skip the part with the prefix. also, you should always prepare a manually added query first. this should do it: <code> global $wpdb; $query = $wpdb->prepare( "SELECT * FROM %s", "{$wpd... | Why is $wpdb-> get_results failing on certain tables but not others (which have data)? | wordpress |
Is it possible to create a user account without an email. Just a username? I saw that there is a plugin to allow multiple authors under one email. Does anyone have any recommendations on other ways to do this. I know this not ideal but I have one user who will posting on behalf of multiple users. Having the user verify... | As far as I'm aware, it's not possible via Add New under the Users tab, however, the <code> wp_create_user </code> function will let you create users without an email address: <code> $username = 'someuser'; $pass = 'swordfish'; $new_user_id = wp_create_user( $username, $pass ); </code> You'd have to wrap that in a basi... | no emails for a user account | wordpress |
I'd like to place the contents of a custom field or variable in between the second and third paragraphs in the loop on a page template. Is there a way to do this? So for example, on a client's website I would like them to use the post editor to write out their page content, and keep things simple for them by giving the... | After researching this, here is what works for me: <code> <?php $paragraphAfter= 1; //show box after selected paragraph $content = apply_filters('the_content', get_the_content()); $content = explode("</p>", $content); for ($i = 0; $i <count($content); $i++) { if ($i == $paragraphAfter) { ?> <!-- START... | In Loop Output Place Custom Field Content In Between Paragraphs | wordpress |
I'm trying to limit a search to only pages, but it isn't working properly. When I include this hidden field in the search form: <code> <input type="hidden" name="post_type" value="page" /> </code> The results include posts, pages, and custom post types. If I change the above to search only posts, it works properl... | A quick test on a default install with TwentyEleven confirms this, and I'm not sure why this is the case, however there is a way you can do this via your <code> functions.php </code> . add a hidden field to the form with your own query var: <code> <input type="hidden" name="my_type" value="page" /> </code> or: <c... | can't limit search to only pages | wordpress |
By default all new registrants for my site are assigned the roll "contributor" and then I make them request an upgrade to an "author" account through a form. I also send out invitations to join the site to certain people in which I want them to automatically register as an "author" so they can skip the application proc... | You could combine your two ideas- generate a code and send them a link to a sign up form with that code as a query string in the url. match the code with the email address they enter when they sign up, then delete it once sign up is complete so it can't be used again. | Allow users to register as a higher roll than default with code | wordpress |
I am using the Wordpress SEO plug in and for some reason the plug in is not longer adding title tags to any posts or pages. I just updated my theme, and something has changed between this version and the last one regarding the way it works with the Wordpress SEO plugin. I checked the header.php and as far as I can tell... | It turns out there was an issue with a plug in (Wordpress SEO) and the theme. I had to click the check box for "enable title rewrite" within the plug in settings in order to get it to work. | Plugin is not generating title tags on any pages or posts | wordpress |
I'm working on a responsive webdesign where my navigation should swap into a select-menu when resizing the window in smaller sizes. Is it somehow possible to add another param to functions like <code> wp_list_categories() </code> or <code> wp_list_pages() </code> so that it outputs <code> <option>item</option&... | you can easily do this the same way as <code> wp_list_pages() </code> , using <code> wp_dropdown_pages() </code> . the args needed to retrieve the pages are the same. for the categories, use <code> wp_dropdown_categories() </code> | Manipulate Output of wp_list_something: select menu instead of li's | wordpress |
I've written Rewrite rules for my custom post types. they work well except that WP doesn't update the url in the User Agent when the redirect_url doesn't match the requested_url. everything else works great though including my custom permastructs ('post_type_link') and custom template options ('single-template'). my ru... | First of all use <code> add_rewrite_rule() </code> over messing directly with <code> $wp_rewrite->rules </code> if possible. The latter is a bit low-level. Regarding the 'url not updating' - this isn't the job of the rewrite rules. These simply point urls to their content, but they don't update the user's address ba... | add_rewrite_rule() vs $wp_rewrite-> rules vs 'rewrite_rules_array'? | wordpress |
How can I make all gallery images to open the high resolution image in a new window? | (Update 04.05.2012: Include captions) Let's start with a solution … There is no filter especially for gallery image links. There is also no filter for the gallery shortcode output. So we have to fake one: <code> add_action( 'after_setup_theme', 'wpse_50911_replace_img_shortcodes' ); /** * Replace the default shortcode ... | How can I make all gallery images to open in a new window? | wordpress |
I'm working on allowing users to rate posts - through the comment meta. Storing and displaying individual ratings is working, however, I would like to be able to store the average rating in the post meta. I have this thus far, seem to get stuck on passing values to the post meta. <code> add_action( 'comment_post', 'add... | <code> $parent_post </code> is an object, <code> update_post_meta </code> requires the ID, so should be: <code> update_post_meta( $parent_post->ID, 'average_wr', $commentdata ); </code> | How to update Post Meta values through the comment system | wordpress |
I've created a Custom Taxonomy and I want to hook a function when User adds new Term to my Custom Taxonomy. Can someone please show me how to use following actions in Wordpress? create_term edit_term delete term All these actions are defined in wp-includes/taxonomy.php as follows: <code> do_action("create_term", $term_... | There's not much to it, you don't need to return anything. Note that you also can't output anything to the browser, that will cause it to fail. <code> function my_create( $term_id, $tt_id, $taxonomy ){ // do some stuff } add_action( 'create_term', 'my_create', 10, 3 ); </code> You mention using this with a custom taxon... | How to use create_term, edit_term, delete_term actions? | wordpress |
I've been searching around for a solution but am coming up dry. I need to have a confirmation email sent to users when their role is upgraded. By default users are signed up as contributors and make them apply to be upgraded to an author and I want an automated email sent to the user as soon as they are upgraded. Any i... | Send email notification when user role changes - Adding this snippet to the <code> functions.php </code> of your WordPress theme will send the member an email notification when the user’s role has changed. <code> function user_role_update( $user_id, $new_role ) { $site_url = get_bloginfo('wpurl'); $user_info = get_user... | Send confirmation email when a user's role is upgraded | wordpress |
Ive searched around and havent been able to find anything regarding using a specific "template" as a target to trigger when to show custom meta boxes...Is this possible, and if so how would you script this out? If post/page ID's are the only real feasible option then would it be possible to target a parent page ID rath... | I needed the same thing, showing a metabox based on the selected page template, and since the user has to select a page template and save and only then i could know which metabox to show i ended up showing all and use some simple jQuery to only show the needed one without having to save first, here: <code> function cus... | Possible to limit custom meta boxes depending on what page template is used? | wordpress |
I would like to make the email field on the profile page for subscribers read only. They can see their email but not change it. I want only admins to to be able to change users email address. | Although the readonly attribute can be removed using Chrome/Firebug inspector (making the field editable again), much probably the average user will not know this. <code> <?php function wpse50730_script_enqueuer(){ if(current_user_can('subscriber')) { echo '<script type="text/javascript"> jQuery(document).read... | How do you make the email field on the profile page read only for subscribers? | wordpress |
I need to debug a problem with filters I have in place. they're affecting any url that includes a query; eg, <code> http://my.domain.hk/?attachment=1 </code> . does anyone know in which function WP begins to work with this kind of url, one that includes a query? cheers, Gregory | Any url that doesn't point to a file/directory that actually exists is redirected (by .htaccess) to the <code> index.php </code> in the root of your WordPress install. <code> index.php </code> is what actually loads WordPress and its settings etc. It then calls the function <code> wp(); </code> , which is responsible f... | when the incoming url is a query, in which function does WP begin to work with it? | wordpress |
So what is the best way to create an export and import feature, I tried <code> serialize() </code> and <code> urlencode() </code> on an array of options to be used in a url like so: <code> export.php?data=(long string) </code> , and use $_GET method in export.php file which forces download using headers, but that's not... | I'm just about done adding my own <code> admin panel class </code> an Import/ Export functionality and I've come to a point where i feel the best way to export data would be as a base64 encoded serialize array, and this is way, serialize data alone is somewhat human readable and i wonted to avoid that (theme options ha... | What is the best way to export and import theme options? | wordpress |
I have a multi-author website and no matter how much education I give to Authors, 80%+ either refuse to or forget to use headings in their posts, instead they use bold text on a separate line to designate a new section of the post. In my battle, I am thinking that I should try to add a tooltip to the B in the <code> wp... | The "bold" icon on the visual editor is represented by a <code> <span> </code> with the class of <code> mce_bold </code> . You can target it using jQuery pretty easily and add a tooltip: <code> jQuery('.mce_bold').attr('title', 'Please use an H2 tag instead.'); </code> If you want to target it inside the HTML edi... | Target wp_editor buttons to add a tooltip | wordpress |
Many searches and tests but in vain, I need an expert to rescue me. I need a custom post query in worpdress, which returns only 5 posts starting from a specific post. In other terms, there is a div in single.php where i need the list of 5 posts starting from the current post (the post returned by single.php) I hope I w... | You can do this by using <code> get_adjacent_post() </code> and the filter <code> get_previous_post_where </code> or <code> get_next_post_where </code> . You'll call <code> get_adjacent_post() </code> as normal, but you'll need to change the <code> LIMIT </code> to 5, using the filter. I wasn't sure from the question w... | Wordpress - query 5 posts with a specific post in top | wordpress |
Is there any way to remove the help tabs? I'm looking to remove these tabs not to hide them with CSS. On the <code> wp-admin/includes/screen.php </code> there are a couple of lines that mention this but no idea how to create something to remove the help tab. Is there any way to create something similar to: <code> add_f... | You need to use the <code> contextual_help </code> help filter. <code> add_filter( 'contextual_help', 'wpse50723_remove_help', 999, 3 ); function wpse50723_remove_help($old_help, $screen_id, $screen){ $screen->remove_help_tabs(); return $old_help; } </code> The filter is for the old context help (pre 3.3). ( I'm not... | How to remove help tabs? | wordpress |
How to: Add a publish immediately button when editing custom WordPress posts? I have found to update a custom post type I need to re-edit the scheduled time to save it. Is it possible to simple update the content for custom post types by pressing something like "Current Date" then it will add the current date, there yo... | As per the comments above: you should be able to click 'update' in the publish metabox. If your post is scheduled to be published, it will be updated and still scheduled to be published at that date. If the post is already published, it is updated (and remains published). If the post is in draft or pending status click... | How to: Add a publish immediately button when editing custom WordPress posts? | wordpress |
<code> function my_add_rewrite_rules() { add_rewrite_rule('testing/([^/]+)?$', 'index.php?pagename=testing&event_slug=$matches[1]', 'top' ); } add_action( 'init', 'my_add_rewrite_rules' ); function add_query_vars( $query_vars ) { $query_vars[] = 'event_slug'; return $query_vars; } add_filter( 'query_vars', 'add_que... | if it's a child page, you have to update <code> pagename </code> to reflect the parent/child path: <code> add_rewrite_rule('about/testing/([^/]+)?$', 'index.php?pagename=about/testing&event_slug=$matches[1]', 'top' ); </code> | add_rewrite_rule() not playing nice with child pages | wordpress |
I am making a Wordpress Theme for a website with video tutorials. I would like to put the video that is embedded in the content (with oEmbed ) in a apart div. An example The full content (output from <code> the_content() </code> ) is something like this: <code> <p><iframe src="http://player.vimeo.com/video/000... | The <code> embed_oembed_html </code> filter runs before an oEmbed resource's HTML is outputted, so you could hook into this and wrap the output in a <code> div </code> as below. I can't think of a simple way of wrapping the other content. <code> add_filter('embed_oembed_html', 'my_embed_oembed_html', 99, 4); function m... | How to wrap oEmbed-embedded video in DIV tags inside the_content? | wordpress |
I am trying to add javascript when a post has been published so that it's more noticable for my user but I can't figure out what to use. I tryed with publish_post and save_post, but it doesn't work unless I put die; at the end of the code. I've tryed so hard to stay out of the wordpress core code, and I really don't wa... | To enqueue scripts on the admin side, you should use the <code> admin_enqueue_scripts </code> hook. In this callback I check that are on the appropriate page (i.e. the page where you edit posts / post types), using the passed <code> $hook </code> argument. Optionally you can check if the post is of a specific type (in ... | Add javascript when post is published | wordpress |
How to remove the contextual help and its tab completely from Wordpress v3.3.2? The add_filter for contextual help that used to work like wonder on older version no longer work now. Update: (trimmed solution from Chip Bennett) <code> function wpse50787_remove_contextual_help() { $screen = get_current_screen(); $screen-... | Since WordPress 3.3, contextual help tabs are added via the Screen object , using <code> add_help_tab() </code> . The basic structure is as follows: <code> <?php $screen = get_current_screen(); $screen->add_help_tab( array( 'id' => 'sfc-base', 'title' => __('Connecting to Facebook', 'sfc'), 'content' => ... | How to remove contextual help on WP 3.3.2? | wordpress |
Not sure if im going about this in the right way but, overall, ive been told to create, kind of like a news box on my home page and so, the "latest news" is going to be this clients posts. now i know i can control <code> the_excerpts(); </code> content length etc but, i cant seem to find any way for it to also allow an... | Ensure that your Theme supports Post Thumbnails, and that the client sets a "Featured Image" for each post. Then, combine <code> the_excerpt() </code> with <code> the_post_thumbnail() </code> , e.g. like so: <code> <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?> <div id="post-<?php the_I... | can the_excerpt function also get images? | wordpress |
Is there any non-plugin solution to add template meta box on the category edit screen? Template meta box like that on the page edit screen, but this one for category. I'd like to have this function built into the theme page. Something similar to the one Mike Schnikel did for Scott B stackexchange-url ("here"). | I'm currently working on a theme framework and one of it's classes is a custom category template class which does just what you are asking for: it adds a select field to the category edit screen that lets you select a template, just like with pages, and i just published it as a plugin <code> Custom Category Template </... | Add template meta box to category edit page? | wordpress |
I'm not sure when this happened, I just noticed it. I have custom taxonomies and post types. For the longest time I was able to go to <code> domain.com/taxonomy/term </code> and it would display the posts related. Now it's not. I'm still able to access it by <code> domain.com/?taxonomy=taxonomyhere&term=termhere </... | Sometimes a plugin changes WordPress' internal rewrite rules during an update, an installation or deactivation. If the plugin's update happens to run after your taxonomy registration it may just wipe out the custom rules for the taxonomy. To inspect the currently active rewrite rules use the plugin Monkeyman Rewrite An... | Permalinks for custom taxonomy stopped to work | wordpress |
I read @nacin's You don't know Query yesterday and was sent down a bit of a querying rabbit hole. Before yesterday, I was (wrongly) using <code> query_posts() </code> for all my querying needs. Now I'm a little bit wiser about using <code> WP_Query() </code> , but still have some gray areas. What I think I know for sur... | You are right to say: Never use <code> query_posts </code> anymore pre_get_posts <code> pre_get_posts </code> is a filter, for altering any query. It is most often used to alter only the 'main query': <code> add_action('pre_get_posts','wpse50761_alter_query'); function wpse50761_alter_query($query){ if( $query->is_m... | When to use WP_query(), query_posts() and pre_get_posts | wordpress |
I'm having trouble with my "custom meta box/write panel" script that contains radio buttons. (see below)...It currently does not seem to save the selection made after publishing the custom post type, not sure what Ive missed??? How I plan to utilize this essentially is by letting the client choose one of the radio butt... | The error is in you saving function where you are looking for <code> $_POST['meta_box_musicreleases_linktype'] </code> which is never set and should actually be <code> $_POST['linktype'] </code> , and the use of <code> wp_kses </code> is not right here, if you want to validate the data and you know all of the accepted ... | Custom "radio button meta box" not saving correctly | wordpress |
How would I achieve this condition ... <code> if lastest comment is < 7 days old echo 'New Comment'; else '' </code> | To get the latest comment use <code> get_comments() </code> . <code> get_comment_date </code> returns the date of a comment in any format for PHP's <code> date() </code> . Now it is easy. Let's put the logic into a function to keep the global namespace clean: <code> /** * Returns the number of days since the latest com... | How to get and use the the number of days since the last comment? | wordpress |
I'm trying to replicate the functionality of the content showcase/slider seen here: http://stylewatch.stelladot.com/ From what I see in the HTML, it appears that there's 2 divs, one with the post images and one with the post titles. I'd like to use something like <code> wp_list_pages </code> to return the 4 most recent... | You'll have a difficult time doing that with <code> wp_list_pages() </code> . You will need to create a custom query loop , using either <code> WP_Query() </code> or <code> get_posts() </code> . Custom loop with 4 most recent posts <code> <?php $recent_posts_query_args = array( 'posts_per_page' => 4 ); $recent_po... | query posts and split meta information into separate div's | wordpress |
Here is the loop from my <code> author.php </code> page. It is showing recent posts, but not the MOST recent. Where is my mistake? <code> <?php if (have_posts()): the_post(); ?> <h3> <?php _e('All posts by'); ?> <?php echo get_the_author(); ?> <span class="arrows">&raquo;</span> ... | The mistake is in your first block of code: <code> <?php if (have_posts()): the_post(); ?> <h3> <?php _e('All posts by'); ?> <?php echo get_the_author(); ?> <span class="arrows">&raquo;</span> </h3> <?php while (have_posts()) : the_post();?> </code> You call <code> th... | Most recent post is missing from Author page | wordpress |
I'm building my theme options page and I want to use Wordpress TinyMCE editor here, so I'm calling <code> wp_editor </code> . But when I'm saving data some entities are added to the content for example, lets say I want to add image: <code> <img class="" title="" src="path_to_image" alt="" /> </code> Thats what I'... | WordPress is running <code> addslashes </code> on <code> POST </code> input. The value you get from the data base looks probably like: <code> <img title=\"\" … </code> … and the editor tries to enforce valid markup from that. So … call the editor with … <code> wp_editor( stripslashes( $content ), strtolower($value['... | wp_editor adds HTML entities to the content | wordpress |
I'm using the Sociable plugin for WordPress. In the admin settings, the Live Preview of Sociable works exactly how I'd like it to: However, on the front-end, I'm getting varying different results. Last night, my user ( <code> dunc </code> )'s view was that of the Live Preview. At the same time however, my colleague had... | If you dig down into the HTML, you'll see that the buttons are there but the background images that make the buttons are not. That's because they're looking for their background sprite image in the following location: /dev/wp-content/plugins/sociable/images/sprites/option1_16.png I'm assuming, therefore, that you eithe... | Sociable buttons displaying seemingly at random | wordpress |
I want to show large image in checkout page right now it showing 31x31 size image in <code> wpsc-shopping_cart_page </code> and using <code> <img src="<?php echo wpsc_cart_item_image(); ?> </code> to call thumbnail image. what should i do for that? | here is the solution i find myself with just 4 easy step <code> 1. go to wp ecommerce plugin folder 2. find cart.class.php file 3. find wpsc_cart_item_image function 4. change $width and $height accordingly </code> | How to show large image in checkout page using WP Ecommerce plugin | wordpress |
I'm trying to create a child theme based on Toolbox 1.4 by Automattic. I have my scripts file saved as <code> child_theme/js/scripts.js </code> on my server and I enqueue it by using <code> wp_enqueue_script( 'scripts', get_stylesheet_directory_uri() . '/js/scripts.js', array('jquery') ); </code> in the <code> header.p... | Shouldn't you be enqueuing that in functions.php instead? <code> function script_enqueueing() { wp_enqueue_script( 'scripts', get_stylesheet_directory_uri() . '/js/scripts.js', array('jquery') ); } add_action('wp_enqueue_scripts', 'script_enqueueing'); </code> Edit to add: if calling directly in header.php, use <code> ... | Page not found when trying to link to files in child theme directory | wordpress |
I know all security updates are important but given that how important on a scale from 1 to 10 is it to upgrade from 3.1.3 to 3.3.2. I have some sites that need to be upgraded but the host has me locked down in an older version of php that limits me to 3.1.3. I am currently running version 5.2.3 of php. Thanks, Bart | Since WP 3.1.3 has come out, we've released: 3.1.4 - security update 3.2 3.2.1 - security update 3.3 3.3.1 - security update 3.3.2 - security update On a scale of 1-10, skipping a single security update is about a 3 (bad, but not catastrophic). Skipping 4 security updates, though, would be closer to an 8-9 ... You shou... | Security updates to 3.3.2 | wordpress |
Is it possible to add a parameter to Simple Facebook Connect and the sfc_like_button function to cause the popup to fly out to the left? Right now, it flies out to the right and is underneath the dark outer wrapper of my page. (see below) This happens in Firefox, IE and Safari. Using <code> overflow:visible </code> in ... | Thanks to SO: stackexchange-url ("stackexchange-url Turns out I needed positions and z-indexes, but also this on the containing <code> <div> </code> , which uses a "clearfix" trick (instead of using overflow:hidden) to make #main wrap its floated children: Original: <code> #main { clear: both; padding: 5px 0 0 0;... | Change the Simple Facebook Connect popup position | wordpress |
I am trying to get the term children and then check if they exist to display them. But I get no IDs in return of get_term_children command. This is the code: <code> $children = get_term_children($term->term_id, locations); echo $children; </code> $term is already defined and outputs well, "locations" taxonomy exists... | At first, try passing the Taxonomy as a string: <code> $children = get_term_children($term->term_id, 'locations'); </code> The function get_category_children produces a string as return, so you can just echo it. the function get_term_children, however, returns an array. To see the contents of the array, try <code> p... | get_term_children doesn't return an array of children terms | wordpress |
I know that I can edit .htaccess manually and add a RewriteCond statement inside, but I need to build a plugin that does this the proper way by using WP rewrites which then get pushed into .htaccess with flush_rewrite_rules(). I need RewriteCond in this case. Does WP have some obscure function that lets me push a Rewri... | In short yes... 'External' Rewrite Rules If in <code> add_rewrite_rule </code> the rule is isn't directed to <code> index.php </code> then the rule is treated as an 'external' rule (i.e. not to be processed by WordPress' internal handing of rewrites) and instead written to the <code> .htaccess </code> file. I.e. if: <c... | Does WP Have a Function To Generate .htaccess RewriteCond? | wordpress |
I'm migrating a Wordpress install and trying to get down the correct process for doing so. I've tried using the method I thought would work, but it didn't. My files and database are in place, but when I visit the wp-admin the theme manager tells me this - The active theme is broken. Reverting to the default theme. Unfo... | Try the XCloner plugin: http://wordpress.org/extend/plugins/xcloner-backup-and-restore/ . I use XCloner to move sites between my live server and my dev server. It takes care of all the migration differences between the domain, database, etc. It preserves all my widget settings, custom menus, etc. | Current theme broken - after server and domain migration | wordpress |
The situation is this: I'm using Video Thumbnails plugin to automatically get and set youtube/vimeo thumbnails as post featured image. The problem is that default youtube/vimeo thumbnail sizes are just a bit smaller than my theme main content width. So what I need is to scale them up. If I go to the Media Library, I ca... | the easiest way would be to add an image-size with 640x298, and use css to resize it. as it is just a minor scale up, the browser scaling should work quite fine. unfortunately, all the plugins i know do not provide image upscaling, just generating of the smaller image sizes, so if you want to have the 688x320 on your s... | How to scale up featured post thumbnail? | wordpress |
I wasn't exactly sure how to word the question, so I'm sure that's why I cannot find what I need when searching Google either. I want to link all commenter names to their author.php page if they have <code> edit_posts </code> capability (Authors, Editors and Admins), otherwise link to the website they have listed in th... | Edited my answer since the original code was slightly flawed. Tested and triplechecked this to make sure it does exactly what you've requested. :) Enjoy! <code> function comment_author_profile_link(){ /* Get the comment author information */ global $comment; $comment_ID = $comment->user_id; $author = get_comment_aut... | Link name in comments to Author page? Comment Author Meta in Comments? | wordpress |
I am trying to add some security/acccess prevention to my site via the functions.php. However whenever I try to add through functions.php (instead of as a plugin, which I've done in the past) it fails (always returns false). For example: <code> add_action("parse_query", checkaccess()); // in functions.php </code> and <... | Your <code> add_action </code> should be: <code> add_action( "parse_query", "checkaccess" ); </code> | add_actions called from functions.php not returning good values | wordpress |
I am currently building a network of blogs for individual real estate agents. Currently, a broker will have a main site, with agents sites added as subdirectories, e.g., www.example.com and www.example.com/agent. Each agent's <code> front-page.php </code> template has an area which displays the agents contact info. I a... | The problem is that the idea of "the user of a specific subdirectory" doesn't really exist natively in WP. There are sites ("subdirectories"), and there are users, and users can be associated with sites (through Roles and Capabilities), but there is no guarantee of a one-to-one correspondence. If you are running a netw... | Solving a get_user_meta() problem in Multisite | wordpress |
i am currently working on a wordpress plugin. the plugin includes a database table that being update every time a post is being created, edited or deleted with the data of that post. one of the columns in this table is "post_status" and i need it to be updated with the status of a post whenever it changes. right now i ... | You do not want to reference the global <code> $post </code> , but the post that is given to you as one of the argument. You simply need to remove <code> global $post </code> ; Remember also to sanitize input and prefix function names. <code> function wpse50651_filter_transition_post_status( $new_status, $old_status, $... | add filter to “quick edit menu” in wordpress admin | wordpress |
I have functions that have to execute based on the user roles. How do I check the user role so that I can insert the respective function under their role? EG. <code> if ($_GET['role'] == "free member" ) {//insert funtion 1} elseif if ($_GET['role'] == "sliver member" ) {//insert funtion 2} else {//insert funtion 3} </c... | Looking around Google for a few minutes yielded several promising results . Here's a more detailed one adapted from a snippet on The Code Collective : <code> function get_user_roles( $user_id ) { $user_roles = []; $user = get_userdata( $user_id ); $capabilities = $user->{$wpdb->prefix . 'capabilities'}; if ( !iss... | How to check user role? | wordpress |
I'm wrangling a little logic problem: I'm making a single page WP theme which uses the JSON API for the content and Mustache style templates for the presentation... However, shortcodes? What would be the best way to handle these? For example: JSON result-> template-> DOM injection-> trigger hijack for gallery/slideshow... | You can add your own AJAX API for <code> do_shortcode </code> . Add this to a suitable location (i.e. <code> functions.php </code> or a plugin): <code> add_action('wp_ajax_doshortcode', 'ajax_doshortcode'); function doshortcode() { echo do_shortcode($_POST['text']); die(); // this is required to return a proper result ... | How to handle shortcodes when using the JSON API | wordpress |
I get this error when I change theme in my wordpress. *Cannot modify header information - headers already sent by (output started at /home/mortgage/public_html/autoblogdemon.com/test/wp-content/plugins/test/test.php:28) in /home/mortgage/public_html/autoblogdemon.com/test/wp-includes/pluggable.php on line 866* Notice o... | The issue is that your plugin should not be outputting anything to the browser on <code> init </code> . As you can see by the error, some code in <code> pluggable.php </code> is trying to set a header, but headers were already sent when your plugin sent output. If you want to output markup, you have to hook something i... | I get "Cannot modify header information - headers already sent" when I change my theme | wordpress |
Currently, on my homepage (which is a list of posts), if you click an image it opens in the same window as a full size image. I'd like to change it so that when a user clicks said image it opens into a Fancybox pop-up. I've got my Fancybox code, which works on my Custom Post Type pages (because I've been able to set th... | Here is the code i use in my site, which loads all images under an anchor tag to fancybox <code> add_action('wp_footer','auto_fancy_box'); function auto_fancy_box(){ if (!is_single() && !is_page()) return; ?> <SCRIPT TYPE="text/javascript"> jQuery(document).ready(function(){ jQuery(".post_content").fin... | Add a Fancybox automatically to post type "post" images | wordpress |
Im using a custom filter to change the fields, but can´t figure out how to change the order of the fields in the comment form. Desired order: comment field (first/top) name email website This is the code which I am currently using: <code> function alter_comment_form_fields($fields){ $fields['comments'] = 'Test'; $field... | That's pretty simple. You just have to take the <code> textarea </code> out of the default fields – filter <code> 'comment_form_defaults' </code> – and print it on the action <code> 'comment_form_top' </code> : <code> <?php # -*- coding: utf-8 -*- /** * Plugin Name: T5 Comment Textarea On Top * Description: Makes th... | How to rearrange fields in comment_form() | wordpress |
How do I redirect to a post after submission with gravity forms. It gives you the option to put in query string values but when I add <code> {post_id}/{Video Title:1} </code> I get <code> mysite.com/?123/name+of+post </code> and it just goes back to the homepage. My permalink structure is <code> post_id/postname </code... | Set the query string to <code> p={post_id} </code> . WordPress will redirect it to the proper URI then automatically. | Redirect to post after submission with Gravity Forms? | wordpress |
I've searched to see if anyone came up with a solution to a peculiar problem I'm having but did not find anything that was close to what was happening in my case. I have two custom post types - let's call them Diary and Journal. Both have been setup correctly with has_archive to true , rewrite with a same named slug an... | Custom post types do not have date-based archives by default (by which I really mean they don't have permalink structures for their date archives). For example: <code> www.example.com?post_type=journal&year=2012&monthnum=4 </code> should give you the archive of journals published in April 2012. However, <code> ... | custom post types, wp_get_archives and add_rewrite_rule | wordpress |
To keep legacy entries on a blog hosted on TypePad on sync with a new WordPress installation... How do I map this permalink with accented letters: <code> domain.com/no-es-fácil-alejarse-de-la-política </code> to this clean WP permalink without accented letter: <code> domain.com/no-es-facil-alejarse-de-la-politica </cod... | The best way to accomplish this is remove the default sanitize_title filter and replace it with yours, which will encode those characters properly. Here is an implementation of using accents in permalinks . Example: <code> remove_filter( 'sanitize_title', 'sanitize_title_with_dashes'); add_filter( 'sanitize_title', 're... | How to map permalinks with accented letters to sanitized slugs? | wordpress |
I have set the blog to be a different page other than the home page. I want to have a link from single.php to this blog page. Is there any function that pulls out URL for the blog ? | To build on Sagive's answer, you'll want to wrap the ID in get_permalink() to get the actual link. <code> <?php echo '<a href="' . get_permalink( get_option( 'page_for_posts' ) ) . '">Our Blog</a>'; ?> </code> | Get the blog page URL set in Options | wordpress |
Does WordPress have an easy way to insert video in a post? I am not referring to YouTube, Vimeo or other hosting sites, just video I upload myself on the server or through the Media manager. I have an mp4 video for example, and I'd like to have it play within the post, it's hosted on the same server as the website. | HTML 5 <code> <video width="640" height="360" src="/wp-content/uploads/2012/04/my_video.mp4" autobuffer> <div class="fallback"> <p>You must have an HTML5 capable browser.</p> </div> </video> </code> For Flash Check out JW Player | How to Insert Self-Hosted Video in WordPress Post | wordpress |
I have a very basic question. In the <code> functions.php </code> file of a theme, what happens to the text that is outside a function and outside the <?php ?> tags? Can I place notes before and after the functions without commenting it and without affecting the system? Or should I at least enclose the out-of-php... | It will probably throw a 'Headers already sent' error/warning and cause a lot of trouble to everything. | What happens to the text in functions.php file outside of the php enclosure? | wordpress |
whilst wp_enqueue_script seems to work it's not really elegant. I'm currently making a WP front end which uses MVC (backbone.js) and has literally 30+ seperate Model/View/Collection/Controller scripts and I keep adding to the number. I've used require.js a lot before and really like it, however it seems to completely b... | Though WordPress already has a basic .js API (with register and enqueue script), I don't see why you cannot use it in conjunction with require.js, at least at the modular level. From what I can tell (never used it) it only needs to be loaded, so you can, <code> wp_enqueue_script( $handle, '...folder../require.js', $dep... | require.js to load javascript | wordpress |
I'm using wp-postratings to rate posts which stores the rating as a custom meta value <code> ratings_score </code> . It gives you the option to use <code> r_sortby </code> to order the loop by highest rated but I want to give it a trending feel by dividing the $ratings_score" by how old the post is in days. So somethin... | You could do this by sorting on a calculated factor. Dividing the rating by the days gives a good starting point: <code> rating/days = factor (e.g. 15/6 = 2.5 or 11/3 = 3.6) </code> You can balance this to your needs by multiplicate the variables (rating and day) with any factor you like. There are to ways to implement... | How to order results by date and meta key? | wordpress |
Working on first responsive website template; layout is part fluid, with fixed sidebars, using media queries. I want to have some of my images be scalable. Per this article http://www.blissfulinterfaces.com/making-wordpress-images-responsive/ it should be very simple, at least for manually loaded images. Add this to st... | Nothing appears to happen because the size of the images is smaller than the available width. If I add a bunch of padding to the container in Chrome and then resize the window, the image scales once all horizontal width is consumed. | making images scalable for responsive designs | wordpress |
I want to get the theme root URL with PHP. What would be the best way to do that? There is a function called <code> get_theme_root() </code> which gives me the path but not the URL. Maybe just get the current themes or parent themes URL and cut the theme directory off? How do I do that? | I think you just want <code> get_theme_root_uri() </code> . Note that it doesn't contain the trailing slash. | How to get the theme directory URI? | wordpress |
I had a blog exposing posts as "day and name". After exporting that blog and importing it on a new installation of WordPress I can't see the posts in that format, only in the default one: http://blog.xxxxx.com/main/?p=123 Also moving to previous pages (http://blog.xxxxx.com/main/page/2/) does not work. Is this a known ... | The WordPress .xml import file only contains post data and not any site settings, such as permalinks. It seems to me that this is only an issue of setting the permalinks the same way of your old site. Settings -> Permalinks ( <code> /wp-admin/options-permalink.php </code> ) select <code> Day and name </code> save chang... | Importer failed to import posts as format "day and name" | wordpress |
When I include some div into a plugin I am creating I get an error when activating the plugin. "The plugin generated 33 characters of unexpected output during activation. If you notice “headers already sent” messages, problems with syndication feeds or other issues, try deactivating or removing this plugin." Though the... | The answer... <code> add_action('init', 'text_on_top'); function text_on_top(){ ?> <div id="bar">hello there</div> <? } </code> Never output anything outside of a function, use a suitable action/filter to do so! | how would I include some html in the header section of a wordpress plugin? I get an error | wordpress |
I have been on this for a while now and haven't really come across a solution to filter the posts on a category page using a sort of offset in php. There are plugin for posts and pages but I am trying to achieve this with pure php and specifically for a category page. Scenario example: A blog with 7 posts, setting the ... | The 'offset' parameter does what you want. I've written this hack, it should help you... <code> <?php //The third parameter corresponds to action priority, //set it to change the order of execution in case of a conflict add_action('pre_get_posts', 'the_modified_loop', 10); function the_modified_loop($query){ //Remov... | Wordpress category loop offset possible? | wordpress |
I know it's probably not encouraged, but is there a way to replace the standard dashboard widgets (Recent Drafts, Quickpress, etc.) with a standard image banner ad? I know how to add new dashboard widgets, but I want this to be a plain image with no surrounding widget. | Check this reference http://www.wpbeginner.com/wp-themes/how-to-add-custom-dashboard-widgets-in-wordpress/ for adding dashboard widget stackexchange-url ("Remove Widgets in Dashboard") for removing dashboard widget <code> add_action('wp_dashboard_setup', 'example_remove_dashboard_widgets' ); function example_remove_das... | Replace dashboard widgets with banner ad | wordpress |
I having a problam with my wordpress plugin. The plugin does whenever new post has been published, it will automaticly create a new file with that post content. this is my code <code> function example($post_ID) { global $post; $content = htmlentities(get_post_field('post_content', $_GET['post'])); file_put_contents(dir... | Where you pass post id ? <code> $content = htmlentities(get_post_field('post_content', $post_ID)); </code> | How to write a new file when new post has been published in Wordpress | wordpress |
is there is a way to convert <code> <!-- more --> </code> to shortcode | Try adding this to your plugin file (or functions.php). You'll use [my_more] as the shortcode for this example. <code> function wpse50449_more_func( $atts ){ return "\n<!-- more -->\n"; } add_shortcode( 'my_more', 'wpse50449_more_func' ); </code> | convert more tag to shortcode | wordpress |
It's pretty common to see Wordpress running on pretty permalinks in the style of: <code> /blog/2012/04/my-post/ </code> However I'm trying to customize a fresh Wordpress install with a different set of URLs. I believe wp_rewrite is my best method, writing a small block of code inside functions.php. I have seen a few ex... | You don't need custom rewrites for that, you can simply use the permalinks settings to achieve those results. Click the Custom Structure option and enter: <code> /blog/%year%/%monthnum%/%postname%.html </code> | Wordpress add_rewrite_rules for custom URLs ending in .html | wordpress |
I am using wp_enqueue_script to do this. If I try to do something else lets say popup a dialog, it works but the code below does not. Can someone tell me the problem. thanks. <code> var $j = jQuery.noConflict(); $j('#mystuff').hide(); var mouseLastYPos = null; $j(document).mousemove(function(e){ if(mouseLastYPos){ if (... | The jQuery library included with WordPress loads in "no conflict" mode. This is to prevent compatibility problems with other javascript libraries that WordPress can load. In order to use the default jQuery shortcut of $, you can use the following wrapper around your code: <code> jQuery(document).ready(function($) { // ... | this jQuery function works perfect in static html page but not on wordpress | wordpress |
I'm using Wordpress to create a blog of my travels later on this year. I would like the blog to have the following features my posts to be geo-located a map containing the locations of my posts ability to click individual points on the map to get to the post. I am looking for the best/most appropriate plugins to use. T... | I think GeoMashup is the go-to plugin for something like this. http://wordpress.org/extend/plugins/geo-mashup/ I've used it for a similar site with great results. There's a lot to dig into, it's very flexible, but you'll definitely be able to get what you want. | Travel Blog Plugins | wordpress |
WP Super Cache plugin generate page and save html of this page to static file and if needed this file is served instead of dynamically generate this page each time. Does WP Super Cache plugin make any extra SQL queries during serving the cached page? | I've received an answer about it from Donncha O Caoimh - developer of the WP Super Cache plugin: If using mod_rewrite to serve cached files then there won't be any queries executed. The page might load images that require queries but the cached html itself won't require queries. If using PHP mode than I think it won't ... | How many SQL queries WP Super Cache make to serve cached page? | wordpress |
I want something like this Home > Products > Steel > Nails This information should come from the menu structure! I installed Breadcrumb NavXT but it seems that it only takes the path I defined (this is the parent and so on). But I need this from the menu structure not from the user. Do I have to set the parent page for... | The best way would be to use <code> wp_nav_menu </code> with a custom walker. Prerequisites: Registered theme location Menu saved to that theme location Useage Wherever you want the breadcrumbs ( for theme location 'primary' ): <code> <?php wp_nav_menu( array( 'container' => 'none', 'theme_location' => 'primar... | show current navigation path from menu | wordpress |
Sorry for the question but can you help me? I have this form in a widget: <code> <form> <fieldset> <legend>Counter Position:</legend> </br> <p> Right <input type="radio" name="position" value="right"/> <p> Left <input type="radio" name="position" value="left"/> <... | <code> <?php add_option( $option, $value, $deprecated, $autoload ); ?> </code> http://codex.wordpress.org/Function_Reference/add_option <code> global $options; ?> <form action="options.php" method="post"> <?php $settings = get_option( 'options' ); ?> <?php settings_fields( 'theme_options' ); ?&g... | Save Option on Database | wordpress |
I use Magic Field 2 to display custome field on my page ! However, I would like to be able to hide several field depending on the page ID... I do not want to use custom post type because my website rely on basic page. Any idea on how I could do that ? Using javascript perhaps ? I can't figure out, which hook I should u... | You can remove meta boxes with the <code> remove_meta_box </code> function: <code> function wpse50430_remove_meta_boxes() { // make sure we're on an admin screen and `post` is set if( !is_admin() && !isset( $_GET['post'] ) ) return; if( $_GET['post'] == 99 ): // editing page ID 99 remove_meta_box( 'pageparentdi... | Hide / Show Custom field depending of the page ID (Magic Field 2) | wordpress |
I am working on a WP theme/project that includes several custom page templates that will only be used once each. For example, there is a page with a map and search form for finding things on the map. Clearly the map page needs a unique page template, but that template will never be used for any other pages. I would lik... | If a page won't work without a specific template, I would just remove the need for them to select a template. Filter <code> template_include </code> and select the template based on the requested page: <code> function wpse50455_template_include( $template ) { // check if it's a page if ( is_page() ): $this_page_id = ge... | Can I create a page template, use it once, then hide/remove the option to use it again? | wordpress |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.