question stringlengths 0 34.8k | answer stringlengths 0 28.3k | title stringlengths 7 150 | forum_tag stringclasses 12
values |
|---|---|---|---|
I have a custom post type called "destinations" and I have set the EP mask for the post type to default EP_PERMALINK. I have added a couple of endpoints as follows : <code> add_filter( 'query_vars', 'add_query_vars'); function add_query_vars($vars){ $vars[] = "tours"; $vars[] = "activities"; return $vars; } add_action(... | A couple things. First, your function names need to be prefixed with something unique. WordPress is a big ecosystem, and someone else has probably used all the generic function names you can think of. Second, <code> add_rewrite_endpoint </code> takes care of adding query variables for you. So you don't need this: <code... | Custom post type permalink endpoint | wordpress |
I'm using W3 Total Cache's CDN connection to RackSpace CloudFiles to serve severall hundred media files. My goal is to get the files to download in the user's browser, rather than stream. According to the CloudFiles Documentation (http://docs.rackspacecloud.com/files/api/v1/cf-devguide-20111115.pdf) I can set the Conte... | This can be broken down to a simple task by adding a custom filter. You will need to add the following to the _send_request method within the CF_Http class in cloudfiles_http.php line 1283. <code> $headers = $this->_make_headers($hdrs); //Add this line below $headers = apply_filters('cloudfiles_headers', $headers, $... | W3 Total Cache, RackSpace Cloud Files, and Forcing Downloads | wordpress |
Some how google indexed a directory inside one of the plugins I use. I cannot figure out how to set a 301 redirect from the indexed path to the home page. has anyone else seen or dealt with this? here is what google indexed. I have replace all personal information with generic. http://www.domainname.com/wp-own-dir/wp-c... | give an noindex in your robots.txt - <code> Disallow: /wp-content/plugins/ </code> and dont access the wp-content/plugins folder; also you can add an 301 redirect in your WP install via Plugin or with an extra in the htaccess | how to 301 redirect from a plugin folder | wordpress |
Is there a way to have a navigation div(s) on the Twentyeleven theme or similar themes that runs over the header image and finishes below the header image? Basically so overflow runs below the image. Here's an example: Link to Website | @Sneek's comment is your best bet. Otherwise, if you're bent on splitting one menu, you have three choices: Use PHP to intercept the menu code and split it up before it gets output. This would work great in many regards, but it wouldn't be knowledgeable as to where the "break" occurs, so you'd need to do it by some oth... | Navigation that Runs Above and Below Header Image | wordpress |
I'm trying to create an one page template [ w/out infinite scroll ]. The two problems I'm running into are adding a class to the list pages function [ or finding some other way to target the menu for smooth page scrolling ] && dynamically loading each page inside of a section or div all on one page. Any thought... | I understand now! You just need to figure a way to programmatically generate sections of code with anchors and have your main menu link to those anchors! <code> <?php $args = array( 'post_type' => array( 'page' ), 'post_status' => array( 'publish' ), 'orderby' => 'menu_order', 'order' => 'asc' ); query_p... | one page wordpress theme | wordpress |
I have a bunch of old posts on a blog that I would like to assign a featured image to. I have retrieved all the images I would like to use for each post. I saved each image file name after the slug of each post. I would like to retrieve all posts, grab the slug name from each post, search the specified directory where ... | Wrote a script myself, along with a blog post. Contributions for improvements are appreciated. Refer to this link for answer: Set WordPress Featured Image For All Post Slugs Matching Image File Name in Specified Directory | Set WordPress Featured Image For All Post Slugs Matching Image File Name in Specified Directory | wordpress |
I am new to WordPress and playing around with it to get some idea about its working. I have done some changes to WordPress' <code> .htaccess </code> file to add some redirection and that worked perfectly fine. Now my problem is even after removing the changes from the .htaccess file, WP is still redirecting me as per t... | If this is still persisting after even reinstalling the database again, than i doubt this is something related to browser cache. I do not know anything how Word-press or WAMPP work but try to use another browser and also try to clear browser cache. If even after clearing the cache if still problem persists than i hope ... | Changes done to .htaccess are not getting reverted back | wordpress |
I am starting a Blog and I am trying to keep my Localhost version as up to date as possible with my Remote server version on the web. I would really like to be able to make a post/article on my Localhost install and have it somehow post the same article/post to my Web version (remote version) once I hit publish. Does a... | I'm currently working on a plugin that addresses a similar need. Basically what you need to do is use the post hook and use XML-RPC to remotely post it. | Sync Wordpress Articles from Local to Remote? | wordpress |
I just set up a custom post type, mostly following this tutorial . I'm setting up things on my site now, doing a lot of CSS modifications and such, and every few minutes the post just forgets everything that's in the custom meta boxes. I'm sure I've done something wrong in the add_action/update_post_meta section, but I... | In the function hooked onto <code> save_posts </code> you should make sure that you check that the action wasn't triggered by an auto-save routine. I suspect that the reason why the post 'forgets' the data is that the post auto-saves, and updates the post-meta with blank data. To do this: <code> function save_details($... | Custom Post type forgetting data | wordpress |
I'm attempting to generate a thumbnail for an image I have posted, but it seems when I call image_downsize, the index[0] actually prints an array as the URL. I'm a bit confused, so any help would be appreciated! My code: <code> $wpUploadPath = wp_upload_dir(); $target_path = $wpUploadPath; $filename = 'http://www.mysit... | http://codex.wordpress.org/Function_Reference/image_downsize Returns: (bool|array) False on failure, array on success. Array with image url, width, height, and whether is intermediate size, in that order is returned on success is returned. $is_intermediate is true if $url is a resized image, false if it is the original... | image_downsize returning an Array? | wordpress |
Im looking for a simple plugin to make a site from which i can make orders for products. The whole shop should be under an own "tab" in the menu. It should be possible to use nested categories. Each product have an "Add to cart" button, and a textfield to enter the quantity. When the user is finished, they fill out the... | Check out WooCommerce . Everything you're asking for it will handle. | Simple webshop-plugin? | wordpress |
I am experiencing an issue where terms with a parent are not being displayed in the category admin screen. The screen gives the total number of terms that should be there (i.e., 32), but only displays parent terms (i.e., 9). Interestingly, if run: <code> var_dump( get_terms( 'category' ) ); </code> all 32 terms are ret... | The issue was that somehow the "category_children" value in "wp_options" was reset to a blank, serialized array. In certain contexts, WordPress uses this value to determine the parent child relationship. The value in my DB suggested no such relationships exist. The fix for the issue was to add/edit/delete a category as... | Child Terms not Displaying on the Taxonomy Term Admin Screen | wordpress |
I have a pretty basic 'featured-list - image slider' implemented above my content in my custom WordPress theme. How do I integrate WordPress content into the slider so that the slide content is pulled via 'Recent-Posts' or via a 'Category'? Also, how can I set the 'Featured Imgs' to display as the photo within the slid... | it is just a question of translating the jquery ui tabs markup into the appropriate wordpress functions. text is the_title() or the_excerpt(). images are the_post_thumbnail and so on. put this in your template where you want the slider to appear: <code> // Get any existing copy of our transient data if ( false === ( $f... | Integrating WordPress Content into a jQuery Slider | wordpress |
I'm trying to generate thumbnails on my server that are being uploaded by a plugin. It uploads all images to a directory. I'm trying to target these files and then create a thumbnail with them based on img_resize, but I am not having any lucky. Eventually I'll be inserting the thumbs into the media gallery and into use... | Looking at your code, it looks like the file wil be looked for in <code> .../wp-content/uploads/bill.jpeg </code> . You'll need to include the yyyy/mm as well. I would use this: <code> require_once(ABSPATH . '/wp-admin/includes/media.php'); require_once(ABSPATH . '/wp-admin/includes/image.php'); $file = 'http://www.mys... | Creating a thumbnail from an image already on the server? | wordpress |
Is there a Wordpress plugin out there, that redirects only Blackberry visitors to a very simple basic something of the site? Currently I have a responsive website, a long vertical one with <code> smoothscroll.js </code> (Similar to the Nike one). It responds in iOS, Android, and iPad - and while it displays alright in ... | There isn't one that I know off, however if you wanted to write a script to solve your problem then: In Javascript: <code> <script type="text/javascript"> var userBrowser = navigator.userAgent; var url = "http://forblackberryusers.yoursite.com/"; if (userBrowser.indexOf("BlackBerry") >= 0) { if (userBrowser.in... | Blackberry specific Mobile Redirect plugin? | wordpress |
As stated in one of the answers in stackexchange-url ("this") question and in the codex entry for the <code> request </code> filter, said filter gets called only in a default query, such as the main query used for a loop. My question is, what else is or isn't considered a default query? Would creating a new <code> WP_Q... | The "default" query is the one WordPress does itself, based on the URL and such, automatically. Any query you create manually, via a new WP_Query or by calling query_posts(), will not use the 'request' filter. There is only one "default" query, and you cannot trigger it via any code in the template. | What is considered a default query for the request filter? | wordpress |
I am hosting on godaddy (yes, i know - shameful - but it is a proof of concept for now) I have artifacts/installers for a mobile phone project (Windows .CAB file) and part of my build server steps FTP the files up to the server. I can see them using the web browser FTP client on my godaddy account. Unfortunately when I... | You might check out a plugin like this one . If you don't want to go that route, I'd suggest using a page template and a technique like this to list out the files. Lastly, assuming you're using apache, you could set apache to allow listing directory contents (not the best idea, IMO) and then edit your .htaccess to prev... | How do I allow http/ftp access to files I have uploaded? | wordpress |
Just wondering, how can remove slugs from some URLS. I'm using a custom post type called exhibitors, and some taxonomies to define those exhibitors (eg: featured-guests, publishers etc.): Right now I have this: <code> http://thisurl.com/exhibitor_filters/featured-guests/ </code> I would like this: <code> http://thisurl... | This by default is not possible, and using the CPT and Custom Tax registration APIs, is not possible. And for good reason. It's all to do with permalink and slug clashes, and removing ambiguity. Admittedly there are cases where unique URLs that never overlap are not allowed by the system for this reason ( false negativ... | Remove slug in taxonomy url | wordpress |
I am trying to retrieve the slug of the current wordpress page outside the loop. The title of the page returns with <code> wp_title () </code> but how can I get the slug? <code> <li><a href="/slug-of-current-page/"><?php wp_title("",true); ?></a></li> </code> | use global variable <code> $post </code> . <code> <?php global $post; $post_slug=$post->post_name; ?> </code> | How to retrieve the slug of current page? | wordpress |
I've been looking around for the past couple hours for a way to create a custom page template from within a plugin but haven't had any luck yet. What I am specifically trying to do is add an option to the list of available page templates when editing a page, and not using some other method like <code> if( is_page( 'pag... | Filters? Anyone? There's no filter there to help: <code> page_template_dropdown($template); </code> is used to build the drop down and it's not filterable. Sneaking into the Templates Array? To build the drop downs contents, the core meta box uses <code> get_page_templates() </code> . From inside, the function looks li... | How can I add an option to the Page Template list from a Plugin? | wordpress |
I want to re-enable the original WP admin bar after installing BuddyPress! <code> define( 'BP_DISABLE_ADMIN_BAR', true ); </code> completely disables the admin bar - don't want that. stackexchange-url ("This question") tells us to check the BuddyPress Codex page , and I tried messing with those action hooks but didn't ... | Since buddypress 1.5 you can use: <code> define( 'BP_USE_WP_ADMIN_BAR', true ); </code> I use it in bp-custom.php although it can go in wp-config.php | Restore original WP admin bar after BuddyPress install | wordpress |
I'm editing this site http://www.millermusicproductions.com/ currently and I updated WP 3.0.1 to 3.3.1. After updating, the page now is zoomed in compared to how it had been and I have no idea why. Here's another site with the same template that is sort of zoomed out in comparison. I want it to end up looking like this... | It looks like the the page is not "zoomed" in. It appears that the image: http://www.millermusicllc.com/wp-content/uploads/2010/11/DSC_3508.jpg Is bigger on the first link as apposed to the second link, also styling on the style.css is different in general: First link: <code> <img src="http://www.millermusicllc.com/... | Trouble After Update, Removing Plugin | wordpress |
I am working on a plugin that creates an inventory list page using an XML data file. For the sake of this example, let us say the inventory items are antique motorcycles or contemporary area rugs. User activates my plugin and adds a short code to a page in order to display the inventory on a page called "Inventory." I ... | Create a custom post type <code> inventory </code> . You get a separate post editor, nice URLs for free. No need for a short code, because each post type has its own archive page. You may add custom meta data, taxonomies etc. Write an importer. Look at the WordPress importer, it uses XML too. This isn’t very hard, just... | How do I write an inventory list plugin that creates dynamic details pages? | wordpress |
Is there a way to call the toolbar or adminbar as you would a menu? <code> <?php wp_nav_menu( array( 'container' => false, 'menu_id' => 'nav', 'theme_location' => 'primary', 'fallback_cb' => 'bp_dtheme_main_nav' ) ); ?> </code> I want to add the toolbar to a div within the header.php file. Currently t... | There's actually an entire API for adding/removing items in the Toolbar. You're specifically looking for the <code> add_menu() </code> method . | BuddyPress Toolbar | wordpress |
I need to include a file twice. once in admin, another in its component. <code> if( is_admin() || is_the_component() ) require... </code> But, there's a big function in the class for registering stuffs is only needed at plugin activation. What's more, I want to make the class a super GLOBAL. <code> $GLOBALS['user_data'... | Include the right way There are two different things to remember when including a file: 1. Use a core function to get the path I explained most of the available functions stackexchange-url ("with this answer"). Consider to take a look at the <code> /wp-includes/link-template.php </code> file in core to see what else co... | How to include a file for admin and 2 pages without being loaded on other parts of the site? | wordpress |
How can I add one or more extra fields to the registration form in bbpress 2.0.2? I want to add a textarea where prospective users can write their reason for joining the forum. | Turns out that the WordPress login and bbPress logins are the same. So you can just find code to tweak the WordPress registration form, or indeed use a plugin, which is very simple:http://wordpress.org/extend/plugins/cimy-user-extra-fields/ | How to add more fields to bbPress registration form | wordpress |
I have a question about how to stop processing a post when a plugin(server side) finds errors on custom fields. Basically I developed a plugin which adds and process some custom fields in the edit post panel. When i click on publish/update button i'd like to stop the process of updating or saving the post...in fact the... | welcome to WordPress Answers. I'm afraid there isn't a (server-side) way of preventing posts being submitted. The hook that is fired when a post is saved, <code> save_post </code> , is fired after the post and its custom fields are saved to the database. However, you can always retrieve the custom field values, validat... | Don't publish/update a post when a plugin finds errors in custom fields | wordpress |
I need to call the WordPress options table and pull some data. However, the table name may be different (typically wp_options) depending on whether the default table prefix was used on installation. How can I obtain a reference to the site's table prefix in order to properly access the site's options table via $wpdb? <... | <code> global $wpdb; $prefix = $wpdb->prefix; </code> | How to obtain a reference to $table_prefix in $wpdb object | wordpress |
Could anyone explain to me how to create a picture galleries page, using the built in Wordpress galleries (no plugins if possible)? Basically, I would like to create a page (template?) in which I loop over all the news of the type Gallery. I've seen some related questions, but without an answer. Could anyone be of serv... | If 'gallery' is a taxonomy item (like a category) you could create a new page template (perhaps based on index.php) and then use the get_posts() function to return a list of posts in that category. That's the process. Do you need more detail? If 'gallery' is a post format that may be a quite different operation. | Page (template) with only news of the type "gallery" | wordpress |
FIXED I changed this: <code> wp_enqueue_script( 'pfxconversion', plugin_dir_url( __FILE__ ) . 'function.js', array( 'jquery' ) ); wp_localize_script( 'pfxconversion', 'MyAjax', array( 'ajaxurl' => admin_url( 'admin-ajax.php' ) ) ); add_action( 'wp_ajax_nopriv_pfxconversion', 'pfxconversion_callback' ); add_action( '... | 1: the codex recommends enqueing all scripts and styles on the wp_enqueue_scripts() hook. this won't solve the problem, but is good practice. 2: i think that all the data that goes INTO the php function is wrapped up in $_POST. which is sent by the .ajax call. so it doesn't look like you are sending any data other than... | Problem running Ajax in Wordpress | wordpress |
Put simply, I'm trying to redirect the user after clicking a 'Save Changes' button. The plugin uses custom capabilities, and so I want to check the current user has the correct capabilities before progressing with the save and redirect afterwards. However, bit of a dilemma. I have tried loading the function that carrie... | You should be able to use <code> current_user_can </code> inside the <code> admin_init </code> hooked callback. See the Codex examples . | wp_redirect and current_user_can issues | wordpress |
What is correct way to send HTML back to an AJAX request in WordPress? I currently have this: <code> add_action( 'wp_ajax_nopriv_get-location-info', 'sc_locations_get_location_info' ); add_action( 'wp_ajax_get-location-info', 'sc_locations_get_location_info' ); function sc_locations_get_location_info() { $nonce = $_POS... | Depending on what kind of HTML you're expecting, there are different tools you can use: <code> esc_html() </code> escapes entire HTML blocks so you don't end up with breaking characters in your JSON object literals. <code> esc_html_e() </code> escapes (as above) and translates the string if you're concerned about local... | WordPress function that makes HTML safe to be sent via AJAX request | wordpress |
The functions that I am aware of: <code> WP_User </code> and <code> wp_get_current_user </code> seem to only get the user object of the current user. As an administrator, if I want to display certain profile information in a table from each user, how can I loop through the ids? Can this be done with WP template tags or... | How about using <code> get_users() </code> ? You probably don't even need parameters for it, default behavior should be just what you're looking for. | How to loop through each user id? | wordpress |
The WordPress function wp_get_nav_menu_items returns my whole site's navigation nested and all. Now if i want to get the nav menu for one "level" of that nested navigation only, how do I do that? | Are you trying to display the posts from the top down a certain number of levels? If so, use wp_nav_menu. It has an argument "depth" built just for this and it works painelssly. <code> wp_nav_menu(array('depth' => 2)); </code> Also, http://codex.wordpress.org/Function_Reference/wp_nav_menu | How do I retrieve menu items from one level only? | wordpress |
I'm playing a little with wordpress widgets and I trying to do something like this: I created a sidebar and a widget to display a slider with latest posts. The jQuery loader is something like this: <code> jQuery('#slider-wrap-id').mySlider({ //args }); </code> Ok, there aren´t problems if user include one of this slide... | The correct practice is actually to use <code> $args['before_widget] </code> and <code> $args['after_widget'] </code> to handle the id, class, and anything else. In pseudo code: <code> class My_Widget extends WP_Widget { function My_Widget() { //basic widget settings. $widget_ops = array( 'classname' => 'my-name', '... | Distinguish between different widgets of the same type | wordpress |
I have a situation where the Wordpress 3 Admin Bar (which is cool and I do want to have) obscures some important information on my page. Before I start fiddling with the CSS myself (which I'm sure will break stuff): Is there an existing patch to change this so the Admin Bar starts "above" the actual page? I realize the... | Upon closer inspection, I found out that Wordpress already does try to move everything that would be obscured further down. The problem is elements that have been positioned using <code> position: fixed </code> or <code> position: absolute </code> . What I ended up doing is adding separate CSS rules for those that appl... | Is there a ready-made fix to make the admin bar not obscure content? | wordpress |
I'm currently having some difficulties getting this below snippet to work. The current outcome is it replaces nothing. I realize this particular question could also be solved using <code> gettext </code> , but I was looking a general example solving all of my <code> str_replace </code> questions at once. <code> add_fil... | I haven't tested this code, but I think it will work for you. I just put <code> add_filter </code> after the function and chose <code> preg_replace </code> : <code> <?php /** * wpse_replace_version_message */ function wpse_replace_version_message( $html ) { $html = preg_replace( '<span id='wp-version-message'>... | Using str_replace on wp-admin | wordpress |
I have a custom query to display my custom post type. <code> posts_per_page </code> set to '5'. In admin post per page set to '10' (settings => Reading => Blog pages show at most 10 posts) My template lists 5 posts per page. If I have 15 posts it must be shown in 3 pages, but on third page I get 404 error. So my pagina... | Pagination is calculated before you get to the template file that runs <code> query_posts </code> . The proper way to alter <code> posts_per_page </code> conditionally is to use the <code> pre_get_posts </code> hook to modify the main query. | posts_per_page & pagination conflict | wordpress |
I don't think there is, but I was wondering whether anyone ran into this issue before. Is there a function (or variable) call to get all registered WP Actions and all registered WP Filters? My current way of doing so would be to have something like this: <code> static private $wp_actions = array( 'muplugins_loaded', 'r... | I'd just like to point out that that is, by no means, anywhere NEAR a complete list. According to adambrown.info , there are 595 actions and 970 filters in wordpress 3.3...and that's just by default, not including hooks added by your plugins. You might be able to do something with <code> global $wp_actions </code> or <... | Get list of available wordpress actions | wordpress |
Codex loosely only mentions PHP version in server requirements, however PHP can be configured in pretty wide range of excluding/including different parts. What are extensions/libraries that: are required for WP to work at all? MySQL... are required for specific functions? GD ?... are preferred for best operation of spe... | I gave this some more thought and given size of WP code base (including bundled libraries) it doesn't seem very realistic to compile such list by hand (and repeat it for every new version - meh). I looked up appropriate static code analysis tool - PHP_CompatInfo and after some tinkering generated following report of ex... | What are PHP extensions and libraries WP needs and/or uses? | wordpress |
I'm trying to implement a jQuery Autocomplete where the Autocomplete gets its data from a ajax source. However, for some reason when I make the call it results in a 302 which in turn results in a 404. This is what I have: In functions.php: <code> function my_ajax_foo() { die("OK"); } add_action('wp_ajax_my_ajax_foo', '... | I'd say, just skip that: <code> cookie: encodeURIComponent(document.cookie) </code> There's no need to post any cookies on XHR - the browser handles that. Well, how about something like that instead (untested): <code> data:{'term':encodeURIComponent($.term)} </code> Most easy is to use FireBug, open Net panel and inspe... | jQuery ajax call throws an HTTP 302 | wordpress |
I don't know why but images uploaded to my site in posts are getting a top level permalink. So if I upload an image into a post called "Apple" then it gets an attachment page at mysite.com/apple and that is a big problem for me. How can add a path between my top level and image attachment page name? | Don't link to attachment pages anywhere on your site and it won't matter what permalink they have. Search engines only see what you make public. BTW another thing you can try is to upload only from within the post/page edit screen. That way attachments take up the parent post/page permalink. Sort of like example.com/po... | Stop Attachment image names from taking top level permalink | wordpress |
I've been looking around at this for solutions but strangely I can't seem to find one that appears decent - maybe I haven't looked hard enough. What I want is a notification on my dashboard when posts are pending review. I can't believe this doesn't seem to be core behaviour for WP. I so far can't seem to find any rece... | Jonnny, I would highly recommend checking out Edit Flow. It does add a notification to the dashboard about Pending posts, as well as a host of other things. The plugin is aimed at organizing a whole team of content creators. It's well described at editflow.org. | Pending Post review notification for contributors | wordpress |
Looking in other plugins/widgets code , I usually see TWO different methods for a query : one would be : <code> $args = array( 'numberposts' => $limit , // or, 1, or 20 ... 'exclude' => '1049', 'meta_key' => 'some_meta', 'post_status'=>'publish'); $recent_posts = get_posts( $args ); //or get_recent_posts() ... | <code> query_posts() </code> is just a wrapper for <code> WP_Query </code> that sets the <code> $wp_query </code> global. | difference between methods of query | wordpress |
I have a site and i'm almost done with it. It have teached me a lot about wordpress, although i'm still a noob who doesn't know anything about php or programming (besides html). I have managed to create a loop as a page template. But I want to show posts ordered by most viewed and most rated. My loop looks like this <c... | Having taken a quick look at the wp-postviews documentation, it seems you can change <code> query_posts( 'posts_per_page=5' ); </code> to <code> query_posts( 'posts_per_page=5&v_sortby=views&v_orderby=desc' ); </code> , but I haven't tested that. Give it a shot and see how it turns out. A cautionary note on doi... | How to sort a loop after most viewed | wordpress |
Hopefully it's OK asking a second question pretty much directly after the first one... I'm currently having some difficulties accomplishing this: I've been able to remove the 'Attachment Post URL' button using <code> function medium_attachment_fields_to_edit($form_fields) { $form_fields['url']['html'] = preg_replace("/... | You can just replace the html with a checkbox, ensuring the name of the checkbox is the name of the <code> <input> </code> we're replacing. You can also change the 'label' and the 'help' text, ( see here for there the filter is fired ) - just simply uncomment the appropritate lines and replace the text with your ... | Making the Add Media Link URL into a checkbox | wordpress |
I'm looking to adapt an existing forum-like plugin which has no facility for attaching media. The plugin works as a Custom Post Type, so it would be as "simple" as attaching an image to a post. I am only concerned about attaching images rather than any file type, but the plugin does use <code> wp_editor </code> and as ... | I think the easiest way, since you're already using the <code> wp_editor </code> function is going to be to just include the media buttons in the WP_Editor instance - this way you'll have the native functions, including the "Insert into post" button, built in for free. How you do this obviously depends on the plugin yo... | Handling front-end file uploads, considering safety and ease of use | wordpress |
I am working with WordPress 3.3.1 and cannot resize the image I am trying to add to the page as the thumbnail, small, medium and large options are greyed out. the size of the image in question is 276x354. I have created my own theme and have added <code> <?php the_post_thumbnail(); ?> </code> template tag but to ... | it can be caused by multiple reasons , some of which may be : theme disabling this function => switch to default theme and check function again GD library not installed on server => check your PHP server settings . the image you are inserting is smaller than the thumbnail image size set in Admin/Settings/Media. => chec... | Resizing image into thumbnail, small, medium and large options greyed out | wordpress |
The server that I am on has these characteristics: Intel(R) Xeon(R) CPU E5506 @ 2.13GHz/24GB ddr3 CloudLinux Server release 5.7 64 bit/litespeed webserver And overall are 800 clients (in whois.domaintools.com that I am looking right now the Shared IP Address of the server that I am is the "Reverse IP: 1,195 websites us... | Your first issue is the fact that you're on shared hosting. The fact that 1,195 websites are using the same IP address is a dead giveaway. You're likely running into resource limits with your hosting provider. Second is a misconception of what caching does to optimize a site. Caching helps clean up and optimize load ti... | Help with overloading the limits of CPU/RAM issue in a resseler account with wp sites | wordpress |
I am working on a classifieds website that has a custom taxonomy called 'countries'. In the main header menu I have these categories showing in a dropdown list of particular countries people can browse the site by. How would I basically make it so when someone selects their country, it sets a session variable and or co... | You can definitly use PHP session variables. Follow this blog post ("Listing 3") for the best way to enable PHP sessions in WordPress. Namely, you need to use this code in your plugin or in your theme's funtions.php: <code> add_action( 'init', 'session_start', 0 ); </code> After that you can use basic session variables... | Adding session variable and/or cookie based on user-selected input | wordpress |
In a blog, I am using <code> next_post_link() </code> and <code> prev_post_link() </code> extensively on posts. I also have a number of pages that I show in a WP3 menu. They are organized in topics and sub-topics e.g. like so: <code> Home About - Subpage 1 - Subpage 2 - Subpage 3 Contact </code> I would like to set up ... | The function behind the function behind the function… <code> next_post_link(); </code> is a wrapper for <code> adjacent_post_link(); </code> which then calls <code> get_adjacent_post(); </code> where the 3 rd argument is <code> $previous </code> and set to <code> true/false </code> to get the previous or next po... | next_post_link() on custom menu structure | wordpress |
I've implemented Ryan Fait's oh-so-common sticky footer in a custom Wordpress theme. I've noticed now if I implement the Wordpress Admin Bar into my pages, which is 28px high (in current Wordpress version at least...), it pushes the sticky footer down 28px as well. Here's the admin bar: Anyways, the way Wordpress works... | The footer is pushed out because WP will add margins to your page whenever the admin bar is set to show. The function responsible for this is called <code> _admin_bar_bump_cb() </code> and is located at wp-includes/admin-bar.php. The bad news is that it uses a harcoded 28px setting (meaning you won't be able to fetch i... | Wordpress Admin Bar pushed Sticky Footer off the bottom of the page | wordpress |
I have a custom post type <code> Event </code> that contains a starting and ending date/times custom fields (as metaboxes in the post edit screen). I would like to make sure that an Event cannot get published (or scheduled) without the dates being filled, as that will cause problems with the templates displaying the Ev... | OK, this is finally how I ended up doing it: an Ajax call to a PHP function that does the checking, sort of inspired by stackexchange-url ("this answer") and using a clever tip from a stackexchange-url ("question I asked on StackOverflow"). Importantly, I make sure that only when we want to Publish the checking is done... | Prevent post from being published if custom fields not filled | wordpress |
Is it possible to redeclare/change the slug of a plugin's existing custom post type (without simply editing the plugin)? That is, if Plugin X creates a custom post type with the slug /uncookedtoast/, is it possible to add a filter to functions.php (or something similar) that changes the slug to /bread/? | Yes, this is possible, but if the plugin is creating a custom post type using the <code> rewrite => array('slug' => 'post_type') </code> parameter, then it's not likely that you're going to be able to replace the slug. Whenever custom post types are created, URL rewrite rules are written to the database. Dependin... | Redeclare/Change Slug of a Plugin's Custom Post Type | wordpress |
The "Reply" option on the comment box is not working. Please let me know how to make that work? Note: I am able to reply on comments from admin area (wp-> comments-> ...) but the site visitors are not able to reply. For example check this: www.linuxstall.com/linux-command-line-tips-that-every-linux-user-should-know/ Cl... | Make sure your header.php file has this before the wp_head function: <code> <?php wp_enqueue_script( 'comment-reply' ); ?> </code> Note: Some themes may use the comment-reply function in the themes function.php file. Caution: I've scanned your theme and I notice it's using an outdated version of TimThumb which is... | Problem with comment box | wordpress |
I have a very weird error running on my plugin. I am currently developing a plugin that will allow the user to create routes and specific dates for the route. The dates are more or less tickets that can be purchased by the visitor. I am running ajax request for the data creation and removal of a date. The return of the... | Some Notes You shouldn't use anonymous/lambda fn, closures for hooks - Those can't get unregistered. Create your nonces, when localizing the script - See for ex. stackexchange-url ("this answer"). The <code> ajaxurl </code> isn't set by default. You'll have to define it (and let it point to admin-ajax.php) when localiz... | Ajax request sends url rather than data | wordpress |
Today I've tried to write a Wordpress Cronjob. For testing purposes I wrote a function that sends me an email every hour, but it's not working. I've got a plugin called 'Core Control' which shows me all existing Cronjobs - mine is also listed there. There is also a button "Run now". If I press it, I get the test-mail, ... | Unfortunately the WordPress cron jobs are only triggered when your site is visited (see Codex ): The action will trigger when someone visits your WordPress site, if the scheduled time has passed. I believe this to get around the fact that many on shared hosting aren't normally allowed to set up cron jobs (at least, not... | Cronjob not working as expected - issue with hook? | wordpress |
I am a new bee in wordpress but i can code in PHP. I have a free wordpress theme installed on my local host. The theme Do not have an option to add to add menu/sub menu in it. It comes with predefined number of menus. What i want is , can i add sub menu in the theme using some php skills? what i want is, a drop down su... | See the answer here: stackexchange-url ("Dropdown Like Twenty-Eleven Theme Question") Be sure to use the updated code toward the bottom of my answer. It should be self explanatory, but if you have any issues let me know and I'll help you out. Be sure to back up your files before changing them in case you break it. How ... | Adding Sub Menu In a theme which Do not have Menu Options | wordpress |
I want to give a group of user types (Editor + a custom role) the add_users /create_users capability. The only catch is that I wanted to limit that capability to adding 'subscriber' type users only, and nothing above that. Is there a way to do this? | This first step to making this happen is add the capability to <code> create_users </code> to a given role. You do this be calling <code> get_role </code> , then using the <code> add_cap </code> method. This only needs to be done once. Here's an example that does it on plugin activation. <code> <?php register_activa... | Allow roles below admin to add subscribers only | wordpress |
I'm trying to install Facebook comments onto a word press blog, but I do not want to loose all the previous comments. I'm curious if anyone has any ideas how to do this. I've looked at a lot of the various plugins, and haven't been able to find a good solution. I would like to find a way for the Facebook comment system... | From all I could research on this, there's just no way to "merge" existing WP comments onto the Facebook Plugin. So my solution for this problem with a client was to style wordpress comments exactly like fb comments, except that they always appear below all other fb comments. Then, by default, i leave the fb comment fo... | Installing Facebook comment plug in without loosing all previous wordpress comments? | wordpress |
I'm using this code. <code> $blog_list = $wpdb->get_results( "SELECT " . $extra . "blog_id, last_updated FROM " . $wpdb->blogs. " WHERE public = '1' AND archived = '0' AND mature = '0' AND spam = '0' AND deleted ='0' AND UPPER(blog_name) LIKE 'A%'" . $order . " " . $limit . "", ARRAY_A ); </code> But that LIKE st... | Prepare your Queries! <code> global $wpdb; $wpdb->get_results( $wpdb->prepare( "SELECT %s blog_id, last_updated FROM %s WHERE public = '1' AND archived = '0' AND mature = '0' AND spam = '0' AND deleted ='0' AND UPPER(blog_name) LIKE '%s' %s %s ", ARRAY_A ), $extra, $wpdb->blogs, $wpdb->esc_like( 'A%' ), $or... | Mysql query LIKE not working | wordpress |
I would like to distribute the content in a post through several divs. Much like a word processor distributes content through pages. Any ideas? | You have two options. You can either use a jQuery plugin like columnizer (even if you don't do columns, you can repurpose this plugin to split it how you want), or you can do it with PHP. Here's a great article that should get your started. | Distribute post content through several divs | wordpress |
Here is my wp_enqueue_script and wp_localize_script - which i am using to run an Ajax call. <code> wp_enqueue_script( 'function', plugin_dir_url( __FILE__ ) . 'function.js', array( 'jquery', 'json2' ) ); wp_localize_script( 'function', 'MyAjax', array( 'ajaxurl' => admin_url( 'admin-ajax.php' ) ) ); </code> While de... | <code> wp_localize_script() </code> now uses <code> json_encode() </code> which means a multidimensional array will now work for the passed data. And, HTML entity decoding only applies to the first level of the array. Better is an way to use json and default js possibilities from WP. At first, i add the options from th... | wp_localize_script escaping my url - fix or alternative | wordpress |
Is there a WordPress function displaying all sections registered with add_settings_section() ? I was thinking about SQL query maybe, but have absolutely no idea how and where these are stored, couldn't find them in my database. | Use the <code> $wp_settings_sections </code> global . It returns an array of settings sections. | Echo all API Settings sections? | wordpress |
I would like to use the url <code> http://site.com/post/title-of-the-post </code> for my posts and I've saw in my admin page I have the current url <code> http://site.com/%slug%/title-of-the-post </code> obiouvsly incorrect. How can I define the slug for my default posts? I'm using various custom post types so I would ... | Set your permalink structure to custom and use: <code> /post/%postname%/ </code> Then when registering your custom post types use something like this: <code> 'rewrite' => array( 'slug' => 'something', 'with_front' => false ), </code> Using <code> with_front </code> set to false will make sure that your new cus... | Define a name to the posts slug | wordpress |
Does exist some way to get the current searched hierarchy php page in <code> Wordpress </code> ? I've set a default category to my posts named <code> post </code> so if I digit <code> http://site.com/post </code> which php page is searched in the <code> hierarchy </code> ? It would be great to get the current page sear... | Assuming that you're wanting to determine which template page is currently being displayed, within the template hierarchy , the easiest way to do so is via the output of <code> body_class() </code> . However, if you need to return this information programmatically, the easiest way might be to call <code> get_body_class... | Get the current hierarchy php page | wordpress |
I'm using post formats heavily on a project, but have no current need for the standard option. Beyond being an unnecessary bit of UI, it actually causes broken behavior if it does get mistakenly selected. I might, with some convoluted logic, be able to set up a template for Standard that properly handles the incoming c... | The first thing to remember about the post editing screen is that everything (except for the post title, editors, permalink, etc.) is a meta box. Since you can easily add and remove meta boxes, there's no need for CSS and JS hacking. Don't want the standard post format to show up? Remove the default meta box and roll y... | Is it possible to remove the "standard" post format? | wordpress |
I set up my site on a PreviewDNS, I have since pointed my Domain to the correct place and changed all the links to non-previewDNS links. However I can see (using Jetpack) that visitors to my site are somehow able to click on some images (I have the no right click plugin as well as no urls on images) I do not want peopl... | It appears that you have content (pages, posts or widgets) that contain old URL information. An example of a URL that is correct: <code> http://www.hutchisonhaines.co.uk/wp-content/themes/FactoryWP/style.css </code> An example of a URL that is incorrect: <code> http://hutchisonhaines.co.uk.previewdns.com/wp-content/upl... | Clicks registering on Preview DNS site | wordpress |
I'd like to run a custom query using some meta data whenever a post is updated or published. Is there something I can put in functions.php to fire when those events occur? | The <code> save_post </code> action fires When a post is updated and/or published -- including when a new post is inserted. <code> <?php add_action( 'save_post', 'wpse41912_save_post' ); function wpse41912_save_post() { // do stuff } </code> If you want your functions to fire only when a post is being edited, you ca... | Perform an action when post is updated/published | wordpress |
I have a multisite with 500+ subsites. I would like to install the same theme in all 500+ sites. Most of them requires configuration like selecting sidebar(left/right), Selecting primary menu etc. Is there any plugin available to do this job? OR Can anyone give me some idea? Thanks | If you configure your Theme settings code properly, the Theme will work fine without having any user-defined settings. The key is to define a defaults array, and anytime you need to output a Theme option, run an <code> array_merge() </code> on the defaults array, and the theme's options DB entry. Something like this: <... | Bulk theme settings in wordpress multisite | wordpress |
I have some pieces of code within functions.php that I could easly replace with much shorter functions, like, for example: <code> function register_sections() { add_settings_section('SOMETHING_settings', 'SOMETHING Settings', 'generate', 'SOMETHING_page' ); add_settings_section('SOMETHING2_settings', 'SOMETHING2 Settin... | Try this instead: <code> function settings_sections() { // array containing settings identifiers $array = ( 'SOMETHING', 'SOMETHING2', 'SOMETHING3', 'SOMETHING4' ); // loop through settings identifiers and generate settings sections foreach( $array as $v) { add_settings_section( $v . '_settings', $v . ' Settings', 'gen... | Generating add_settings_section() calls dynamically | wordpress |
I'm trying to find a way to selectively disable qTranslate - I would like to be able to show certain static content on my site in 4 languages, but to then only have a single language (and a simplified editor) for posts and also custom post types. I would also need to disable the output on selective pages in the front-e... | Following snippet will disable it for post_type <code> post </code> (modify array below to affect other post_types): <code> function qtrans_disable() { global $typenow, $pagenow; if (in_array($typenow, array('post')) && // post_types where qTranslate should be disabled in_array($pagenow, array('post-new.php', '... | Disable qTranslate by post type in admin + disable per page / post ID on front-end | wordpress |
I'm working on a plugin which we'll call "my-plugin" for the purposes of this question. The my-plugin directory looks like this: <code> my-plugin/ |- image.jpg |- script.js |- script.php |- plugin.php |- ajax.php </code> In script.php I have a section of code that specifies some JS. In it, I need a URL for ajax.php. e.... | You can try to override it by using the following in config.php and see if it works as it will update your database, doing so will make it unable to be changed in your admin (it will be greyed out). <code> define('WP_SITEURL', 'http://example.com/'); </code> And some alternative definitions, http://codex.wordpress.org/... | plugins_url() incorrectly returns a url with www subdomain | wordpress |
I'm using this structure to make album lists. I'm using a key so I correspond lists to albums but I don't know how to reverse the output so the items start at the top with lowest key value. Any ideas? <code> <?php $album = get_post_meta($post->ID, "album", false); $album_list = get_post_meta($post->ID, "album_... | how about array_reverse() http://php.net/manual/en/function.array-reverse.php there are a bunch of array manipulation functions at php.net. i'm always there looking something up. also sort() might be useful EDIT based on your comments: <code> sort($album); print_r($album); </code> should return: <code> Array ( [0] =>... | How to query posts that have certain post meta keys, and sort by meta key and/or value | wordpress |
I'm working on a plugin that interacts with Gravity Forms, and under certain conditions I want to prevent a form from being deleted. Here's the method in Gravity Forms that handles deleting a form: <code> public static function delete_form($form_id){ global $wpdb; if(!GFCommon::current_user_can_any("gravityforms_delete... | Short answer: no. Long answer: also no. Actions don't work that way. Edit: To elaborate and make your question totally generic: <code> function foo() { bar(); return 1; } function bar() { // stuff } </code> There is nothing you can put in stuff that will prevent a call to <code> foo() </code> from returning 1, other th... | Can an action callback prevent the parent from continuing execution? | wordpress |
In my theme directory I have the following structure: /includes/functions-custom.php /includes/avatax/AvaTax.php /includes/classes/gmaps.class.php I'm making a call from the functions-custom.php to include the second file within the WordPress admin using this code <code> require_once('avatax/AvaTax.php'); //Avalara Sal... | So after a night of sleep, and confirmation from the above users that I was including files properly, I've managed to resolve the issue. In the AvaTax.php file, there was an __autoload() function: <code> <?php function __autoload($class_name) { if ( $class_name != 'WP_User_Search' ) { //WORDPRESS HACK $path=dirname(... | Using require_once() within admin | wordpress |
The wordpress function wp_insert_user doesn't seem to set (overwrite) the input I give. (documentation shows you can't) Trying to use: wp_insert_user using the returned userID also doesn't work. Of course I could just make my own query but maybe I'm forgetting an option to insert this data using a existing function. <c... | What you are best off doing is hooking into <code> user_register </code> and from there updating the user options you want them set to. Below is an example of disabling the admin bar for new users: <code> add_action("user_register", "sc_set_user_admin_bar_false_by_default", 10, 1); function sc_set_user_admin_bar_false_... | Insert "New User" and update/set meta data at once | wordpress |
I'm trying to edit the loop so if its on category ID 60 it displays "Photos" instead of "Blog".. how do I do this? blog <code> <?php if(is_archive()&&!is_category()&&!is_tag()&&!is_search()){ ?> <!-- BEGIN .archive-title --> <h1 class="page-title"> <?php if ( is_day() ) : ?&... | <code> <?php if( is_archive() && is_category() && !is_tag() && !is_search() ): ?> <!-- BEGIN .archive-title --> <h1 class="page-title"> <?php if ( is_day() ): ?> <?php printf( __( 'Daily Archives: %s' ), get_the_date() ); ?> <?php elseif ( is_month() ): ?> <... | Help with Changing loop.php? | wordpress |
is there a way to add a custom post_type (directors) link to a menu? I can add the individual director posts but not the link to all of them. I'd like to avoid using custom links as this will be used in several sites and not always at the root. (so making a default /directors/ wont always work). PLus i'd like it to beh... | ok - got this working with a walker in the end; (added a custom directors link to the menu) <code> class Director_nav_links extends Walker_Nav_Menu { function start_el(&$output, $item, $depth, $args) { global $wp_query; $indent = ( $depth ) ? str_repeat( "\t", $depth ) : ''; $class_names = $value = ''; $classes = e... | menu link to custom post_type? | wordpress |
I have two forms created using Settings API, and when I save one of them the other one gets erased and vice versa. Here's the whole code so you could paste it into your functions.php file and see for yourself: <code> // Register settings function registerSettings() { register_setting('XX_theme_settings', 'XX_theme_sett... | The reason is that if you are on page 1, the data that is posted to be saved is an array of the form: <code> XX_theme_settings=array('XX_Option1' =>'input1','XX_Option2'=>'input2',...) </code> and contains no data from page 2. This is because the input from page 2 is not posted with it (since it wasn't in the sam... | Settings API erases itself? | wordpress |
For some reason I get the following output from <code> var_dump( plugin_dir_url( __FILE__ ) ); </code> http://local.dev/wp-content/plugins/C:/development/xampp/htdocs/vanilla/wp-content/themes/twentyeleven/ in a local install. Note: I deactivated all plugins and added the line on top of the <code> functions.php </code>... | There is <code> plugin_basename() </code> call some levels inside which seems to use <code> WP_PLUGIN_DIR </code> and <code> WPMU_PLUGIN_DIR </code> constants, so my guess would be this function is only meant to be used for things inside plugin directories and not other places like theme. | plugin_dir_url() adds path to url | wordpress |
I have a set of settings fields: <code> (...) add_settings_field( 'Option1', 'Option 1', 'textarea', 'page1', 'plugin_options'); add_settings_field( 'Option2', 'Option 2', 'textarea', 'page1', 'plugin_options'); add_settings_field( 'Option3', 'Option 3', 'text_input', 'page1', 'plugin_options'); add_settings_field( 'Op... | You're absolutely right that you can pass reusable form field markup to <code> add_settings_field() </code> . The trick is to define the data type for each setting, and then pass the same callback to each call to <code> add_settings_field() </code> . Within that callback, you simply add a switch that includes cases for... | Settings API - creating reusable form elements? | wordpress |
Im trying to clean up my scripts and I'm using a function to but ran into a problem with using both !is_page or !is_single to only show certain scripts on singles and pages. What did I do wrong here. <code> add_action( 'wp_print_scripts', 'my_deregister_javascript', 100 ); function my_deregister_javascript() { if ( !is... | The problem is probably because <code> wp_print_scripts </code> is too late to deregister scripts as this is when they are outputted to the template. You should consider using <code> wp_enqueue_scripts </code> or <code> wp_register_script </code> instead. This question may help: stackexchange-url ("wp_enqueue_scripts, ... | is_page() or is_single not working | wordpress |
I've got (currently) 3 custom post types that I need to display on my sites' home page using a custom query. Each custom post type has a different layout (1 post across, 2 posts across and 4 posts across). What I am trying to do is call a different template for each layout. I've been working on this close to a month an... | There are a couple of confusing points to the question, namely that the home page is usually reserved for a stream of posts (where you could at one time trigger a 4 posts across layout, not necessarily all of them of the same post type), or a static post / page, where a such a check would be meaningless. Still, I think... | Multiple custom post types on index page with custom templates | wordpress |
If I use is_front_page() in my front-page.php file it works as expected. However if I use the same function in my theme functions.php file it does not work. Is this normal behavior? If not can it be trouble shot somehow? In settings-> reading I have my front page set to a page called "front page" so I think that is all... | That maybe normal behavior, depending on how exactly you're using <code> is_front_page </code> in your functions file. If you just dropped it inside the file, it's not going to work. Why? Because WordPress loads functions.php before the $wp_query object has been set up with the current page. <code> is_front_page </code... | is_front_page only works in theme file, and does not work in functions.php | wordpress |
I have just hit my first serious issue with WordPress and for someone that enjoys Ajax this is a biggy. I have an Ajax request that is taking 1.5 seconds to complete while using the Ajax API. If I take the same exact code and run it with a custom script(no WordPress) the Ajax request takes merely 150 milliseconds. This... | Yep, this is nasty issue that to have full WordPress environment you need to spend considerable time loading it. I've needed much better performance (for very dynamic incremental search feature) for work and what I went with is: Custom file as Ajax handler. SHORTINIT constant for limited WP core load. Very selectively ... | Ajax takes 10x as long as it should/could | wordpress |
How do I save options as an array using forms? I don't want to use Settings API. Here's working form that saves 3 options separately: <code> <form method="post" enctype="multipart/form-data" action="options.php"> <?php wp_nonce_field('update-options'); ?> <input type="text" name="option1" value="<?php... | Have you tried... <code> <input type="text" name="my_options[option1]" value="<?php echo $options['option1']; ?>" /> <input type="text" name="my_options[option2]" value="<?php echo $options['option2']; ?>" /> <input type="text" name="my_options[option3]" value="<?php echo $options['option3... | How to save Wordpress Options as an array? | wordpress |
I've got the following code in my functions.php <code> function add_custom_rewrite_rules(){ add_rewrite_tag('%gallery%','([^/]+)', 'gallery='); add_rewrite_tag('%album%','([^/]+)', 'album='); add_rewrite_rule('galleries/(.+)/?$' , 'index.php?pagename=galleries&album=1&gallery=$matches[1]'); } add_action('init',... | First off, don't ever do this: <code> add_action('init', 'flush_rewrite_rules'); </code> Every time WordPress loads, you are going to flush the rewrite rules. You only need to do this once to make sure your rewrite shows up. Second, <code> add_rewrite_tag </code> only takes two arguments, the tag and the regex. If you ... | Can't add external rewrites | wordpress |
I would like to implement tag subscription and follow/nofollow for registered users. I mean when the user goto tag page, left side widget should show subscribe/unsubscribe button. And when the user goto author page, left side widget should show follow/nofollow button. Front page posts should have two other tabs called ... | The way I would approach this is: Create several AJAX calls using the nopriv hook bound to the subscribe/follow button clicks. Within the PHP callback functions, I would insert value of the tag or the followed user into the logged-in user's meta using <code> add_user_meta </code> , <code> get_user_meta </code> , <code>... | Somebody guide me to implement tag subscription plugin. | wordpress |
I'm trying to add a line to my functions.php that does a behind-the-scenes HTTP request submitting some user information to a mailing list URL I have. I'm trying to test the code at the moment, but nothing seems to be working. I have tried the following: <code> $url = 'blabla.org/mailinglist/add?' . $user_email; $reque... | Only use <code> wp_remote_post() </code> if you are actually posting something. Try using <code> wp_remote_get() </code> with a full url <code> $url = 'http://blabla.org/mailinglist/add?' . $user_email; $results = wp_remote_get( $url ); // var_dump( $results ); </code> | Behind-the-scenes HTTP Request? | wordpress |
I would like to know how to use the built in wordpress search to return results from all content on my site. Specifically, I want to search; posts pages tags custom post type (portfolio) custom taxonomy used in custom post type (skill, client) metaboxes used in custom post type (portfolio_caption, portfolio_excerpt, po... | DeluxeBlogTips.com 1) has an article on how to do combined searches in both posts and meta data. Basically, it involves two queries via the $wpdb object; one to search the meta table to get a list of <code> post_id </code> s and the other is a query of posts to get <code> post_id </code> s. You then merge the arrays an... | Search everything (posts, pages, tags, cpt, meta) | wordpress |
I am trying to create a custom meta box for multiple custom post types in WordPress without creating duplicate code. Currently I have: <code> add_meta_box('adv_form_box1', 'Advanced Form', 'adv_form1', 'custom-post-type1', 'side', 'high'); add_meta_box('adv_form_box2', 'Advanced Form', 'adv_form2', 'custom-post-type2',... | In addition to the other answers, you can further improve it by looping through an array of types instead of manually adding a new add_meta_box() line each time you add a new type. <code> $postTypes = array( 'custom-post-type1', 'custom-post-type2', 'custom-post-type3' ); foreach( $postTypes as $pt ) add_meta_box( 'adv... | Global custom meta box | wordpress |
I've been working on building a theme for the past couple days now, and I've run into a wall. While I originally included foundation.js as an enqueued script, I couldn't remember why I had added it. Today, when I tried removing it (to improve page-load speed) from my functions.php file, it messed up all of my jQuery pl... | Try changing the first line of your custom JS file. <code> jQuery(document).ready(function($) { </code> jQuery operated within WordPress should be run in compatibility mode. That line allows this to happen, as per point #5 here. | Wordpress Enqueue Script Chaos (jQuery & Foundation.js) | wordpress |
Can I list all the blogs in my network on one page? | yes, small source for an template. <code> <ul class='postlist no-mp'> <?php /** * Old version, change on 07/23/2013 * $blogs = $wpdb->get_results( "SELECT blog_id,path FROM {$wpdb->blogs} WHERE blog_id != {$wpdb->blogid} AND site_id = '{$wpdb->siteid}' AND spam = '0' AND deleted = '0' AND archived ... | How to list all network sites on one page | wordpress |
I am using the Orbit Slider plugin successfully on my site. The plugin supports its own categories. I would like to embed the slider within my page.php template but allow each page to have it's own slider based on the category. Inside my page.php I have this: <code> <?php echo do_shortcode('[orbit-slider category="p... | You've got an <code> echo </code> inside an <code> echo </code> . Rewrite you code like this: <code> <?php echo do_shortcode('[orbit-slider category="' . get_post_meta($post->ID, "slide-category", true) . '"]'); ?> </code> This will concatenate things instead. and give you <code> '[orbit-slider category="5"]' ... | Help solving t_echo php error while using echo do_shortcode | wordpress |
In my application, users have to login first before accessing the website. So now what I am doing, I have created one custom login page. How can I redirect a user to the login page if he/she is not logged in yet. Should i customize wp-login.php for login? Which is better way, 1. Redirect user to login page or 2. wp-log... | You can use the following action to redirect all traffic to that login page. You will need to specify the page name and the page slug. <code> add_action('wp', 'wpse_41699_wp', 0); function wpse_41699_wp(){ if(is_page('Login')) return; if(!is_user_logged_in()){ $url = get_bloginfo('home').'/login'; header('HTTP/1.1 403 ... | User needs to login first before accessing website | wordpress |
There are a good plugin, that allows user to make several galleries in one post not using manually "include" attribute. http://wordpress.org/extend/plugins/multiple-galleries/ But after upgrading on 3.3.1 core version of WordPress this plugin don't work anymore. (I suggest this is because of changes in file post manage... | Use Nextgen and problem solved. You can add as many galleries as you want. And you're right, sadly, this core upgrade killed a lot of amazing plugins. I have downgraded sites because of that. | Multiple Galleries in WordPress 3.3.1 | wordpress |
Is there a way I could have my search results show Pages first and posts after the pages? My site is a business site with a blog, as opposed to the blog being primary. The static pages have all the "here's what we do" stuff and ideally they would come up first if someone was searching for various services. The blog pos... | You can use the <code> posts_orderby </code> filter to alter the order of returned posts. This will run for every query (front and back), so make sure you ensure you want to alter the order by using <code> is_admin </code> , <code> is_search </code> etc. In the example below search results are ordered by post type in a... | How do I filter the search results order? | wordpress |
Actualy the question says it all. I integrated a media upload box to my admin page and a button with the text 'Insert into post' makes no sense. I rather like to change it to something like 'Use this image'. Anyone got a clue on how you are able to do so? | <code> add_filter("attribute_escape", "myfunction", 10, 2); function myfunction($safe_text, $text) { return str_replace("Insert into Post", "Use this image", $text); } </code> Place in your theme functions file of in a plugin file. The first usable filter that this button hits is on the function <code> esc_attr() </cod... | How can you change the 'Insert into Post' title in the media button? | wordpress |
Why does the jquery below not fire? Its going to the "else" every time. <code> if ( is_admin() && $pagenow == 'theme-install.php' && $_GET['tab']=="upload"){ add_action('admin_print_scripts', 'theme_upgrade_alert'); function theme_upgrade_alert(){ wp_enqueue_script('jquery'); echo ' <script type="tex... | First, check for syntax errors. The syntax highlighting seems to indicate that you have syntax errors. Second, don't wrap your <code> add_action() </code> calls inside conditionals; rather, wrap your callback function content inside the conditionals, e.g.: <code> <?php function theme_upgrade_alernt() { if ( is_admin... | How to enqueue jquery in admin and why is it not already there? | wordpress |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.