question stringlengths 0 34.8k | answer stringlengths 0 28.3k | title stringlengths 7 150 | forum_tag stringclasses 12
values |
|---|---|---|---|
I have created a plug-in with an Admin Menu that displays a list of artists saved into the database in a custom table. This page is a "master" page and I am trying to figure out how to link the artist name to a "details" page all in the backend. From the codex and other books I have determined that the second level pag... | The <code> add_submenu_page </code> function allows you to link to a callback function and its this callback function which handles the display of that pages content. <code> add_submenu_page( $parent_slug, //The slug name for the parent menu i.e. ppmtalentexpo $page_title, $menu_title, $capability, $menu_slug, $callbac... | Link to Second Level Admin Page | wordpress |
I want to add the featured image URL of a post to the header. When a Facebook user shares a Wordpress page, this code in the header: The <code> rel="image_src" </code> attribute is what facebook is searching for. <code> <link rel="image_src" href="FEATUREDIMAGEURL"> </code> Will return a specific image for the sh... | To answer this one and point to the real problem: As the <code> <head> </code> HTML tag comes far before the actual loop, you'll need something else than the <code> global $post </code> . <code> get_queried_object(); get_queried_object_id(); </code> The plugin The code is tested and works. As you might want to ke... | Wordpress Post featured image URL in the header | wordpress |
I've had an interesting request from a client, and subsequently spent a couple of hours looking into it. The crux of it is exactly as the title of this post suggests: they have 3 separate sites with unique domains, but the subject material & content for all three is ostensibly the same. They would like to be able t... | This should be doable. First step would be pointing each domain to the same document root/install of WordPress. Next up, use <code> WP_HOME </code> and <code> WP_SITEURL </code> in <code> wp-config.php </code> that change based on <code> $_SERVER['HTTP_HOST'] </code> . Example: <code> <?php define('WP_HOME', 'http:/... | Multiple sites/domains with content all managed by single installation of Wordpress | wordpress |
In my sidebar every widget title is enclosed in <code> <h2> </code> tags. I use 4 widgets in my sidebar and I'd like to have the first 2 widget titles as <code> <h2> </code> and the other 2 as <code> <h4> </code> . I changed in my function.php as given below: <code> 'before_title' => '<h4>', ... | <code> dynamic_sidebar_params </code> is the filter that lets you modify those parameters on a per-widget basis. It fires for every sidebar though, so you'll need to use both <code> add_action </code> & <code> remove_action </code> call. Try <code> var_dump </code> once before writing the code to get an idea of wha... | Add individual tag to widget title in sidebar | wordpress |
I am having two meta keys, longitude and latitude, and what I am trying to do is the equivalent of the google store location algorithm for distance, in wp_query: SELECT id, ( 3959 * acos( cos( radians(37) ) * cos( radians( lat ) ) * cos( radians( lng ) - radians(-122) ) + sin( radians(37) ) * sin( radians( lat ) ) ) ) ... | You can do that. There are filters available in WP_Query that enable you to modify the query just as you like. The filter <code> posts_clauses </code> filters all of the parts of the query together. There are also filters specific to the parts of the query too. The best way to know about them is, search <code> posts_cl... | WP_Query search by multiple meta key and distance | wordpress |
I know there should be a way to call the AJAX function by page load but I've been looking at how to do this for hours and can't figure it out. Any help is appreciated. | I fixed it by bypassing the script. | Display the popular tags by default in the backend post edit page (without having to click on the link that displays them) | wordpress |
Update / Question clarification: How could you modify the following code from this thread: stackexchange-url ("Force category choice before creating new post?") which offers a drop-down menu to choose a category BEFORE creating a new post to add some default html content to a specific category??? <code> add_filter( 'lo... | Using the code you posted, the selected category's ID is available in the <code> $_REQUEST </code> , you can check that ID against your <code> products </code> category in the <code> default_content </code> filter and add content if there's a match: <code> add_filter( 'default_content', 'wpa70073_default_products_conte... | Add default content to posts in a specific category? | wordpress |
I am using Wordpress Gallery shortcode and I was wondering if there is a way to navigate using the arrow keys? Like if I view an single image and used the right arrow to navigate to the next image in the gallery set. Any idea how to do this? | The Underscores (_s) starter theme comes with a keyboard navigation script for this. I haven't tested this myself though. But the JS file looks like this: <code> jQuery( document ).ready( function( $ ) { $( document ).keydown( function( e ) { var url = false; if ( e.which == 37 ) { // Left arrow key code url = $( '.pre... | Navigate with keyboard in Gallery shortcode | wordpress |
I have recently invested a bunch of hours updating the alt text of all the images in a media library, only to realise that the changes are not reflected on posts/pages. Whoops! Is there any way to force these changes across? Or have I no choice but to edit each page manually? Hope someone has good news for me! Thanks | If the image is the featured image or some image inserted via a shortcode, then those changes will reflect automatically(if they don't, it's your theme's fault, you'll have to edit your theme) If the image is inserted into the post content, yes you'll have to go through each page/post & manually do the changes. Tho... | How to have changes made in media library to be reflected on posts/pages | wordpress |
I have a weird problem, which I could not solve yet. I installed wordpress 3.4.1 and made an own template. I use one plugin - qTranslate. Everything is fine on my local copy and also on my dev copy dev.mysite.cz. When I copied wordpress and log in on the main site, http://www.mysite.cz , the dashboard does not show up.... | The problem was in .htaccess. There was an old global .htaccess file (from the old website) besides the wordpress one which was hidden on the sever (by admins of the hosting company) which rewrite rules harmed the ones in wordpress. I actually had to contact the admins and ask them to remove those rewrite rules. | wp-admin does not redirect to dashboard | wordpress |
I've been trying to create a Recent Post widget where it only show/display posts that have both categories X and Y (or more). The categories X and Y is user-defined, so I'm planning to make it look like this: In fact, that picture is an actual screenshot from what I have managed to create. It is working fine if I selec... | you're using <code> 'category__and' => array($category_name) </code> which according to the input becomes <code> 'category__and' => array('594,3') </code> Here '594,3' is not a valid id instead try <code> 'category__and' => explode(',', $category_name) </code> This will make the input as <code> 'category__and'... | Widgets: Show Recent Posts Only if the Posts Have Both Categories X and Y | wordpress |
When I upload images, Wordpress 3.4.2 sets the Title to the base of the filename, such as "DSCN1234" or "IMG_1234". I'd like the Title to be left blank. The code that sets the Title during the upload seems to be in "wp-admin/includes/media.php" in the function <code> media_handle_upload() </code> , here: <code> // Cons... | (Answering my own question, with help from @brasofilo) Wordpress 3.5 has a great new Media manager, and it no longer requires the Title to be filled in for images. It also no longer fills in the Title automatically when reorganizing images in a Gallery. It does, however, still fill in the Title with the image filename ... | Filter to modify post_title after image upload? | wordpress |
I have created a function that takes one parameter - post type, and will output each posts with some html and title, content etc within that. However, I want to be able to use functions associated with <code> $post </code> , especially <code> the_excerpt </code> . However, when I try to use my function in my sidebar ph... | Your function works in your page template but not in the sidebar because at the point that your template is processed, $post already contains the post that has been loaded for the page. I tried your code and, just like Michael said, all I needed to add was the global declaration of $post inside the function , and it di... | Why can I not use setup_postdata($post) in the sidebar? | wordpress |
I am developing TwentyTen child theme and wish to display dynamic sidebar on front page, but something is not quite right. I modified <code> loop-page.php </code> : <code> <div class="entry-content"> <?php dynamic_sidebar('promotion-sidebar'); ?> //ADDED LINE <?php the_content(); ?> <?php wp_link_p... | <code> loop-page.php </code> is the wrong context for what you are trying to do. If you want it to appear on the home page, then you need to edit <code> loop.php </code> , so in your child theme you can either create a file called, <code> loop.php </code> ...which should take precedence over the <code> loop.php </code>... | dynamic sidebar in front page | wordpress |
I trying to remove unused image size (Thumbnail, Medium, Large) in MediaBox Any function can i use in functions.php ? or some trick ? PS : I know i can use jQuery trick but any better function to use ? | Exactly the same code as Mridul, but different filter: <code> function wp_70048_remove_image_sizes($sizes) { unset($sizes['thumbnail']); unset($sizes['medium']); unset($sizes['large']); return $sizes; } add_filter('image_size_names_choose', 'wp_70048_remove_image_sizes'); </code> Tested with WP 3.4.2 | Removing default image size list in Media Box | wordpress |
I have a blog in which several post's categories have to be outputted first before other categories. Those categories have lower ID compared to other categories. I am using <code> get_the_category_list </code> but it is not working as I expected. Makes me confused because I remember a theme doing this very well. Can so... | You're using wrong arguments for <code> get_the_category_list </code> function. The function you should use for this is <code> wp_get_object_terms </code> http://codex.wordpress.org/Function_Reference/wp_get_object_terms | Sort post's categories by ID | wordpress |
The code below from WPSnipps provides an excerpt character counter, but I'd like to count words instead. Does anybody have an idea of how to do this? <code> // Excerpt character count function excerpt_count_js(){ echo '<script>jQuery(document).ready(function(){ jQuery("#postexcerpt .handlediv").after("<div sty... | Sorry for reading wrong your question @siouxfan45! here is the right answer: just a little improvement in your code and you can count words! just change these two lines: <code> jQuery("#excerpt_counter").val(jQuery("#excerpt").val().length); </code> to this: <code> jQuery("#excerpt_counter").val(jQuery("#excerpt").val(... | Excerpt Word Count | wordpress |
So far I've got around 8,000 products in my WooCommerce and the product page on the front end takes several seconds to load, even after caching. My VPS host says that I should have multiple databases. Is that the right method and if so, how is it possible? Any suggestions on speeding up my database queries or simply sp... | This is really a server question and not particularly Wordpress. You're running into a MySQL server speed bottleneck at 1and1. Sorry, but they're well known as a slow shared host, and for that reason I doubt their VPSs are any better. Caching and a CDN will only do so much for you. You need more horsepowwer in the form... | WooCommerce with thousands of products - site is very slow - optimize db queries? | wordpress |
I want to be able to seperate the first image form the post into a <code> <div> </code> tag and link it to the post page and be able to add html around the post text elements seprately. Any help is greatly appreciated This is what I have tried <code> query_posts('posts_per_page=1&tag=food'); while (have_posts... | Look at this snippet from CSS-Tricks. It gets the first image from a post. | how can I get seperate the HTML in the_content(); output? | wordpress |
I've created a plugin, and of course being me, I wanted to go with a nice OO approach. Now what I've been doing is to create this class and then just below create an instance of this class: <code> class ClassName { public function __construct(){ } } $class_instance = new ClassName(); </code> I'm assuming there is a mor... | Good question, there are a number of approaches and it depends on what you want to achieve. I often do; <code> add_action( 'plugins_loaded', array( 'someClassy', 'init' )); class someClassy { public static function init() { $class = __CLASS__; new $class; } public function __construct() { //construct what you see fit h... | Best way to initiate a class in a WP plugin? | wordpress |
Currently, when I load a search or result page, it queries the <code> wp_postmeta </code> table which is leading to the page taking ages to load. I realise this is a result of this table being huge (70k rows), and because of how much data is loaded into the cache. Is there a way to stop <code> update_post_caches </code... | <code> add_filter('pre_get_posts', 'customize_query'); function customize_query($query) { if($query->is_main_query() && ($query->is_search() || $query->is_archive()) { $query->set('update_post_meta_cache', false); $query->set('update_post_term_cache', false); } } </code> Then wordpress will make ... | How to stop wp_postmeta from being called on archive and search pages? | wordpress |
I have many pages which have a lot in common. They are supposed to display the same things but according to their own categories. The logical way to implement this would be to pass a variable through the url and display the info according to it. The only problem is that my wordpress urls are rewritten... I search this ... | What I did is rewrite url's in order to display the categories on them. After that, I just extracted them with the function "get_category_by_path". It allowed me to use the url info without having to inject and extract any custom variable. Thank you. | Use get variable when rewritten url in wordpress | wordpress |
I want to use Google Adsense code snippets in my blog posts, so in my single.php. However, when I do so, then my RSS feed becomes invalid because of the javascript code in the content and the feed won't be updated anymore. Is there ANY way to fix this? I still have the Google Adsense code in the sidebar where it's not ... | Do not paste the Adsense code into the blog posts. Use a plugin instead. Sample Plugin: <code> <?php /* Plugin Name: Zoomingjapan Adsense */ add_filter( 'the_content', 'zoomingjapan_adsense' ); function zoomingjapan_adsense( $content ) { if ( is_feed() or ! is_singular() ) return $content; $adsense = '<adense cod... | RSS feed validity and Google Adsense | wordpress |
In my index.php file, I'm trying to create a thumbnail for each post with the size width: 200px and height 142px. And on the single.php, I would ike for the featured image to be width: 598px and height: 300px; for the index.php i tried <code> <?php the_post_thumbnail( array (200,150) );?> </code> but I cant get i... | For this situation, you should use <code> add_image_size </code> . You can find more info about it in the codex . What <code> add_image_size </code> does is register new sizes for your thumbnails, so you can use them with <code> the_post_thumbnail </code> (and other functions). Here´s the example from the codex: <code>... | Thumbnail and Featured Image With Fixed Sizes? | wordpress |
I was recently asked to help out with a site where, as you can see, all the content is on one page. As it's less than elegant, I'd like to separate things out but I've looked around the menus and settings, I can't find anything obvious. If I click the "pages" link on the left side, I'm taken to a list of seemingly sepa... | ..are they using the latest version of WordPress? If not, upgrade. Also, see if the problem continues after switching to the default "Twenty Eleven" WordPress theme. | separate home page into separate pages | wordpress |
I am working on an online store using Woocommerce, many products have variations in size and price. Is there a way to have the range of prices (highest to lowest) of the variations on the product page? | try it like this: <code> /** * This code should be added to functions.php of your theme **/ add_filter('woocommerce_variable_price_html', 'custom_variation_price', 10, 2); function custom_variation_price( $price, $product ) { $price = ''; if ( !$product->min_variation_price || $product->min_variation_price !== $p... | Display price range on woocommerce product variations | wordpress |
I have 2 questions for caption for images: - how to edti them with bold, italics and so on? I do it, but it doesn't work. - if the image is first, how to exclude caption from excerpt in query especially for frontpage? | For your first question- HTML support for captions was a new feature in wordpress 3.4, if you have any version prior to that, it won't work I'm not sure if i understood your 2nd question, but to exclude the caption from not displaying on the page, you'll have to either delete the caption from the image or edit your the... | How to edit caption for images and exclude it from excerption query? | wordpress |
I´d like to display all car manufacturer in order by title (e.g. "Merecedes") and order from lowest to highest values (e.g. "A-Class") "ASC", too. It should looks like a glossary. Page: Cars A ... BMW: 1er 2er 3er ... Mercedes: A-Class B-Class C-Class ... Z This is my <code> custom-port-type-cars.php </code> <code> <... | <code> $index = 'A'; $terms = get_terms('manufacturer'); foreach ($terms as $term) { if($index != strtoupper(substr($term->name, 0, 1))) { $index = strtoupper(substr($term->name, 0, 1)); echo '<h1>'. $index . '</h1>'; } ?> <h2><?php echo $term->name; ?></h2> <?php $args = ar... | Custom Post Type order Title ASC | wordpress |
How could I let each user subscribe to a specific categories of his choice? I want to do something like reddit subscribe to categories? Is there any tutorial helps doing this? | You can give them this url http://www.example.com/?cat=42&feed=rss2 This one if permalinks are enabled http://example.com/category/categoryname/feed Replace the site url & also the cateogries id or slug with the correct one UPDATE IN RESPONSE TO COMMENT Display a list of categories to the user maybe with <code>... | Let user subscribe to specific categories | wordpress |
In my plugin, I use these instructions to obtain a list of posts: <code> $args = array( 'numberposts' => -1, 'offset' => 0, 'meta_query' => array( array( 'key' => 'metadata1', 'value' => '80', 'compare' => '<=', 'type' => 'UNSIGNED' ), array( 'key' => 'metadata2', 'value' => '4.6', 'compar... | Try meta_value_num <code> 'meta_key' => 'metadata1', 'orderby' => 'meta_value_num' </code> Add these 2 parameters to $args. This does the sorting considering metadata1 as numeric | Ordering posts by metadata | wordpress |
How can I show the update message only to super admin in the network wordpress ? I don't want the other admins/users see the update message that shows the current version. Is there any plugin to do this or I have to changes the core? | Create your own plugin with this code or put this in theme's functions.php <code> add_action('init', 'remove_update_notification', 1) function remove_update_notification() { if (!current_user_can('manage_network')) { // checks to see if current user can update plugins add_action( 'init', create_function( '$a', "remove_... | How to display update message only to admin | wordpress |
I want wordpress to stop making multiple size images cause it's going to eat up my storage space. So I went Settings > Media and then set all the sizes to 0. When I uploaded a new image it still is making 2 copies for example: <code> achannel.jpg achannel-346x288.jpg </code> although they are both full size images so w... | <code> add_filter('intermediate_image_sizes_advanced', 'filter_image_sizes'); function filter_image_sizes( $sizes) { unset( $sizes['thumbnail']); unset( $sizes['medium']); unset( $sizes['large']); return $sizes; } </code> | Stop wordpress from creating multiple size images | wordpress |
Currently in my theme i am running the default query that pulls all recent posts/latest entries/latest published posts . But i am looking for something more complex like i am gonna setup two sections . One is for all the latest entries and the other one is for the four sub-sections which will show posts from 4 selected... | You must first do the 4 queries for selected categories and while looping through them remember the IDs. Save them in an array. Then when pulling latest posts just add the <code> post__not_in </code> parameter with all the IDs you want to exclude. You need 4 queries that look somewhat like this: <code> $args = array( '... | Showing posts from 4 categories along with all latest posts | wordpress |
I'm making a plugin that emails the site webmaster when I go to the 404 page. The script checks if the referring link is on our site, and then sends an email to the webmaster. <code> $message = " <html> <head> <title>Alton Bible Church - Broken Link</title> <style type=\"text/css\"> * { fo... | Use wp_mail() </code> , not just <code> mail() </code> . It is a wrapper for PHPMailer , a class that takes care for many problems the native <code> mail() </code> function often gets. See my plugin 404 Tools for how to use it in this case. To send an HTML email see stackexchange-url ("Milo’s answer") to a related ques... | How can I send an email in my plugin? | wordpress |
Is there a way to add support for a custom feature for a custom post type, after it has been created? I know how to create a custom post type using register_post_type(), and how to use the supports parameter to specify what the CPT should support; <code> 'supports' => array( 'title', 'editor', 'author', 'thumbnail',... | Yes, there's a function called <code> add_post_type_support </code> Hook into <code> init </code> -- late, after the post types have been created -- and add support. Adding support for excerpts to pages for instance: <code> <?php add_action('init', 'wpse70000_add_excerpt', 100); function wpse70000_add_excerpt() { ad... | How to add "supports" parameter for a Custom Post Type? | wordpress |
I am smashing my head against some code. Here is the situation: I have one post in 3 different categories, this post has to be visible in "category 1" with the single1.php, in "category 2" with single2.php and in "category 3" with single3.php. Obviously the 3 single.php pages have a different template inside. For examp... | Instead of making it category specific you could use post formats and use different content-templates. In single.php you can write <code> <?php get_template_part( 'content', get_post_format() ); ?> </code> Then create different post formats <code> add_theme_support( 'post-formats', array( 'withpictures', 'withcom... | Posts in multiple Categories different single.php | wordpress |
I use the <code> add_menu_page </code> function to add an new admin menu: <code> add_menu_page( 'Custom_menu', 'Custom_menu', 'edit_posts', 'custom_slug', '', 'wordpress_existing_icon', 5 ); </code> How to use one of WordPress' existing icons? For instance, if I would like to use the "Posts" WordPress icon, by what mus... | <code> add_menu_page(); </code> as far as I can tell does not work with <code> screen_icon </code> or the default CSS parameters. The <code> $icon </code> paramater only takes 2 options, an <code> url </code> or <code> div </code> (well 3 if you leave it empty), so that leaves you with these options: Hard-code the link... | How to use a WordPress' existing admin icon? | wordpress |
I have a Drupal 5.x based travel review site which I'm moving over to Wordpress 3.x (same domain name). The Drupal site is structured like this: <code> www.example.com/travel-guides </code> (these are top-level pages) - these are only a handful. <code> www.example.com/<filename>.html </code> (filename is the name... | Above the WordPress rewrite rules add: <code> RedirectMatch permanent ^/([^/]+)\.html$ /$1 </code> That will catch <code> example.com/foo.html </code> but not <code> example.com/travel-guides/foo.html </code> . To catch all URLs ending with <code> .html </code> remove the first <code> ^ </code> from the pattern. To red... | Htaccess redirect from '/%postname%.html' to '/%postname%' | wordpress |
I'm working on a site where I'd like anyone to be able to sign up, but people who sign up with an invite code would automatically be promoted to a role with more privileges. I'm aware that there are plugins that handle invite codes, but so far I haven't found any that will do quite this. For my purposes, one invite cod... | This is one way to do it <code> add_action('user_register', 'set_custom_default_role') function set_custom_default_role($user_id) { // Maybe get available referral codes from database & compare them against the one available if(true) { $user = new WP_User( $user_id ); $user->set_role('custom-role-slug'); } } </c... | Set user role based on invitation code | wordpress |
SOLUTION PASTEBIN LINKS:: http://pastebin.com/YmXVC1kn - Author Single Post http://pastebin.com/g0xgvxgh - Book Archive Template Please refer to these files here - solved by storing the post ID in a variable and reworking how I was nesting my loops. I would like to display a single post (from a custom post type "author... | For the author single page <code> $query = new WP_Query(array( 'post_type' => 'books', 'meta_key' => 'author', 'meta_value' => get_the_ID() // assuming you're inside the loop )); while($query->have_posts()) { $query->the_post(); the_title(); } wp_reset_query(); </code> For the books archive page <code> /... | Display a list of posts whose meta field values are equal to the ID of the post being viewed? | wordpress |
I've been reading this by stackexchange-url ("@nacin") and getting to grips with wp_query over query_posts that I used to use. What I want is: to put this in a template file to query all posts of this category, in this case '3' to display, if available, the first result on the page the latest sticky post after the firs... | you could use <code> wp_list_pluck(); </code> <code> if ( $exclude_featured ) $args['post__not_in'] = wp_list_pluck( $exclude_featured->posts, 'ID' ); $args['posts_per_page'] = 999; query_posts( $args ); endif; while ( have_posts() ) : the_post(); ... </code> | wp_query for the first sticky, then display the rest of the posts excluding the first sticky | wordpress |
I have searched the net with no success on what should be an easy thing. I have a highly customized blog with pages, sub pages and posts. While I rely heavily on the use of categories and tags I don't want them to be viewable in a url. The same goes for authors and date categories. Basically I wan't to throw a 404 erro... | building on chrisguitarguy's answer here is a quick snippet you can drop in your theme's functions.php file to do job <code> add_action('template_redirect', 'wpse69948_archive_disabler'); function wpse69948_archive_disabler() { if(is_tag() || is_category() || is_date() || is_author()) { global $wp_query; $wp_query->... | Get rid of Wordpress category, tag and author archives? | wordpress |
I have a widget sidebar, but I'd like dividers between them. I can achieve this in CSS using boring borders, but I have a png image I'd rather use instead. Is there a way to insert a divider after each widget item? (apart from the last one of course). I can do this in jQuery quite easily but I'd rather do it in the tem... | <code> 'after_widget' => '', </code> As far as I know, thats the best way to do it | Wordpress widget/sidebar dividers? | wordpress |
Are there any technical reasons that prevent WP to be part of Framework Interop Group? | Yes, WordPress's maintains backward compatibility (spaghetti), it would not be feasible to adhere to PSR-0 and rename everything, which is somewhat unfortunate for the long-term, with regards to FIG. That being said it's possible to adopt it for plugins and themes, there is a trac about it here: https://core.trac.wordp... | Why isn't WordPress part of Framework Interop Group? | wordpress |
I want to display post view in localize number. I add these function in function.php to do so <code> function make_bangla_number($str) { $engNumber = array(1,2,3,4,5,6,7,8,9,0); $bangNumber = array('à§§','২','à§©','৪','à§«','৬','à§','à§®','৯','০'); $converted = str_replace($engNumber, $bangNumber, $str); ret... | The problem is most probably, that you don't actually call the filter. WordPress does this not automatically for you. If you want to create a custom filter you have to manually call <code> apply_filters </code> , so that the added filters get executed: <code> function the_views($postID){ $count_key = 'views'; $count = ... | how to localize the number of wordpress post views? | wordpress |
I have a subdirectory install of the WP multiste and I'm trying to use the Pretty Link Lite Plugin to create shortlinks. I'm also using the MU domain mapping plugin to map each subdirectory site to a domain name. The pretty link manager creates shortlinks such as: <code> domain.com/shortlink //base domain domain.com/su... | look in your domain mapping options. Did you activate "Redirect administration pages to site's original domain (remote login disabled if redirect disabled)"? If so uncheck this and use the mapped domain name for the admin section (I have checked point 2+3 which is Permanent redirect and User domain mapping page and the... | Pretty Link Lite Plugin on WP Multisite | wordpress |
I use .html on PAGES plugin , and this works fine for me in Chrome and Firefox. However, Internet Explorer displays "page cannot be found". Why would one browser not display a page, but two others find it? Problem pages are: http://tech.doig.com.au/testimonials.html http://tech.doig.com.au/portfolio.html | You are sending a very confusing response: <code> HTTP/1.1 301 Moved Permanently Date: Sat, 20 Oct 2012 12:33:06 GMT Server: Apache X-Powered-By: PHP/5.3.13 X-Pingback: http://tech.doig.com.au/xmlrpc.php Keep-Alive: timeout=5, max=100 Connection: Keep-Alive Content-Type: text/html; charset=UTF-8 </code> After that the ... | page not found in IE, but found in Chrome & Firefox | wordpress |
I have a portfolio website where my portfolio updates are supposed to go to both my portfolio and blog pages, as well as show thumbnails for the posts on my homepage . The thumbnails work perfectly; if a post is to go in two categories, the thumbnails show up in both categories. My trouble is with the blog- posts marke... | First thing : you should not use category ids directly. Use slugs instead : it's easier to maintain. <code> <?php query_posts('category_name=portfolio'); ?> </code> Second thing : why did you put a query parameter in <code> the_post </code> ? This function does not accept any parameter ( see the Codex ). Third th... | posts going to 2 pages/categories only show up in 1 | wordpress |
I'm wondering why WordPress doesn't list PHP <code> array() </code> and any serialized data in Custom Fields in Admin Panel (for Pages, Posts etc.)? Only Custom Fields containing strings and numbers show up and can be edited by user manually. Edit: Why aren't post meta values displayed if they are stored as a non-strin... | There is no filter to change that behavior, you would have to stackexchange-url ("replace the entire metabox"). On the other hand: I think there is no really simple way to show and to save those arrays. Example for a fictive meta key <code> 'foo' </code> : <code> array ( 0 => 2, 'hello' => array ( 0 => 2, 'hel... | WP doesn't show Array Custom Fields? | wordpress |
It is my understanding that there should not be more than one <code> <h1> </code> tag on a page, and that the <code> <h1> </code> tag should be the site title, for SEO reasons. If that is correct, why does WordPress allow users to insert <code> <h1> </code> tags into posts? Also, would it be a good id... | It is my understanding that there should not be more than one <code> <h1> </code> tag on a page, and that the <code> <h1> </code> tag should be the site title, for SEO reasons. But that’s your opinion, not a rule . From an accessibility perspective the <code> h1 </code> should be used for main content’s tit... | Why does WordPress allow inserting tags into posts? | wordpress |
I have created a custom post type called 'event' and added an event called London 2012. I want the following URL structure for a page: <code> local.mysite.com/london-2012/speakers </code> I have created a page called Speakers giving me a working <code> /speakers </code> url (I have Permalinks set to 'Post name'). Now I... | It looks like you need to process the rewrite using query strings rather than a URI segment and pass your query through index.php. WordPress seems to be agnostic of what you're trying to accomplish here. Try the following rule and visit your Settings-> Permalinks page to flush previous rules and add this to the stack. ... | .htaccess rewrite | wordpress |
Just a bugbear about declaring taxonomies, reading Justin Tadlocks article about Taxonomies and want to find what does the 0 mean in this snippet from the above article: <code> add_action( 'init', 'create_pc_db_taxonomies', 0 ); </code> In the codex article on taxonomies they've omitted it but I see it used just about ... | The third argument of <code> add_action </code> is the priority, or order in which functions hooked to an action will be executed. from <code> add_action </code> in codex : (optional) Used to specify the order in which the functions associated with a particular action are executed. Lower numbers correspond with earlier... | Declaring arguments for taxonomy | wordpress |
I am using a child theme and try to get some code show up after the content on single post/pages <code> function app_bits() { global $post; $app_logo = get_post_meta($post->ID, 'AppLogo', TRUE); $zund_id = get_post_meta($post->ID, 'AppURL', TRUE); if ( is_single() || is_page() ) { ?> <div class="hidemobile"... | You get the <code> $content </code> as a parameter for your function, and you should not echo anything in that function. Return a string instead. Example: <code> add_filter( 'the_content', 'app_bits'); function app_bits( $content ) { if ( ! is_singular() ) { return $content; } $extra = '<div style="text-align: cente... | Adding code using functions.php in child theme | wordpress |
I hate to try to reinvent the wheel here, but none of the suggested post seem to work in answering my question. I am building a system for our 30 Under 30 honorees, which is basically setup as a portfolio of images. The types of post I am creating will be called "honorees", and the overall menu called "30 Under 30". Th... | Your post_type slug will default to the name of the post_type unless specified otherwise. So, in it's most basic form you can set a custom base slug as follows, <code> 'rewrite' => array( 'slug' => 'slug-name-here'); </code> Currently, you have it set to <code> true </code> only. Don't forget to visit your permal... | Understanding Permalinks on Custom Post Types | wordpress |
I thought this would be simpler using the basic widgets that WP provides but its not. I need to create 2012 Decemeber November ... 2011 December ... The month items would be links to that archive. Is this possible? I would prefer not to use a plugin but if thats the answer its ok. | <code> function archive_links_custom() { global $wpdb, $wp_locale; $query = "SELECT YEAR(post_date) AS `year`, MONTH(post_date) AS `month`, count(ID) as posts FROM $wpdb->posts WHERE post_type = 'post' AND post_status = 'publish' GROUP BY YEAR(post_date), MONTH(post_date) ORDER BY post_date DESC"; $arcresults = $wpd... | How can I organize/create an archive listing by Year and month | wordpress |
I am trying to display the posts of last 24 hours and order them by most views. I call the most views by this code: <code> query_posts('meta_key=post_views_count&orderby=meta_value_num&posts_per_page=7'); if (have_posts()) : while (have_posts()) : the_post();?> <li><a href="<?php the_permalink();... | Base on the updated code, the answer to your question, "How can I add filter or query to show the most views post (new posts) of last 24 hours?" is that you can't do that. Your code is not tracking time at all. There is no way to pull 'last 24 hours' if you aren't tracking times for the post views. You will need to add... | Display posts from Last 24 hours and order them based on most views | wordpress |
when i call this link ; <code> ?s=key&order=ASC </code> wp display my search query order by ASC. <code> ?s=key&order=ASC&number=10 </code> how can we display whatever i want to display postnumber like 10 or more ? is that possible ? | If you're asking to change the number of posts from 10 to something else, you can do one of the following 1) Submit the search query as <code> ?s=key&order=ASC&posts_per_page=5 </code> You can achieve this by adding hidden fields to the form. Just change the number to whatever you want 2) Go to Settings > Readi... | Display number of posts via adress bar? | wordpress |
I am using the hook <code> publish_post </code> to run my code where I need the post meta of the just published post. But the post meta value I am looking for is somehow not available at this point of execution. On checking the <code> wp_postmeta </code> table, I found that my meta key value hasn't been created yet. Al... | Solved it! Used <code> save_post </code> to run <code> push_notification() </code> as well as to run the function <code> save_post_meta() </code> that saves my post meta. The problem occurred coz <code> push_notification() </code> gets fired before <code> save_post_meta() </code> due to which the meta wasn't being save... | How to access the post meta of a post that has just been published? | wordpress |
I want to execute custom jquery code which shows login dialog to user if he clicks a button and he is not logged in. How could I do that? | In case you want to know if the user is logged in at the current moment. The other answers check if the user is logged in or not when the page loaded not the time when you're running the javascript. The user could have logged in in a seperate tab for instance Put this in your javascript <code> var data = { action: 'is_... | Check if user is logged in using JQuery | wordpress |
First, I need to ask if it's possible to create a photo gallery only with the featured images of the latest 6 posts? I assume it is possible but just want to make sure. I don't have much experience working directly with the wordpress gallery so could someone point me in the right direction for accomplishing this? Any p... | <code> $query = new WP_Query(array('posts_per_page' => 6, 'meta_key' => '_thumbnail_id')); while($query->have_posts()) : $query->the_post(); the_post_thumbnail(); endwhile; </code> This code gets 6 latest posts which have featured image available & show those 6 images on the page. It will skip those pos... | Photo gallery with Featured Images | wordpress |
I'm using the following function to create a custom excerpt for my homepage and categories pages so I can do it by character count and have a custom "read more". However, I have captions shortcode showing up in my excerpt. Example: [caption id="attachment_4656" align="aligncenter" width="450"] Crispy Vegetable Tacos[/c... | Don't use a custom function. You should use the hooks. You don't have to strip shortcodes, wordpress does that for you automatically, just use something like this <code> // setting higher priority so that wordpress default filter have already applied add_filter('the_excerpt', 'custom_excerpt_filter', 11); function cust... | Stripping shortcode from custom excerpt function | wordpress |
when i open any post then 1st image show my featured image. i want to increase this size . see it or . i already try to increase from single.php to change this code <code> <p><img src="<?php echo get_template_directory_uri(); ?>/images/thumbnails/thumbnail-leadimg.jpg" width="610" height="320" alt="<?... | It's probably because the original image is not big enough. You can make the image display bigger via CSS : <code> .post_thumbnail{ height: 320px } </code> | how i can increase Featured thumbnails size? | wordpress |
I am trying to do two things, which I have no idea how to do: give child categories the same class as the parent category (which is the parent category-slug) create a menu which displays my categories, where the child categories will be displayed as dropdown-items when hovering the parent categor Currently I am using t... | If you want only 2 levels, you may use the <code> parent </code> parameter. Example <code> <?php $args = array( 'hide_empty' => 0, 'parent' => 0 ); $categories = get_categories($args); $menu = '<ul class="nav">'; // iterate through your categories foreach($categories as $category) { $menu .= '<li clas... | Give child-categories same class (the parent category-slug) as parent in menu list? | wordpress |
I need to add a shortcode in my theme and I would like to put the HTML code not in the function which creates the shortcode but in a template file in my theme directory. Now I have <code> function wpse450_show_video( $atts ) { extract(shortcode_atts(array( 'id' => 0 ), $atts )); if( is_numeric($id) ) { $ngvideo_titl... | <code> function wpse450_show_video( $atts ) { extract(shortcode_atts(array( 'id' => 0 ), $atts )); if( is_numeric($id) ) { $ngvideo_title = get_the_title($id); } ob_start(); include 'path/to/file/video.php'; return ob_get_clean(); } add_shortcode( 'ngvideo', 'wpse450_show_video' ); </code> You can use $id, $atts in ... | How to format shortcode's HTML in external file | wordpress |
Background : Working on a Widget that uses a remote API using <code> wp_remote_post </code> to log into the service, once logged in storing the cookies received for the second request to query data with <code> wp_remote_get </code> . Problem : The cookies from the first request are stored in the response as WP_Http_Coo... | AFAIK URL encoding the cookie value is still kind of a defacto standard, it's an ancient relict based on the old, ugly Netscape cookie specs , that basically says that semicolons, commas and whitespaces are disallowed, and should be encoded, for example using URL encoding. Neither does it does it require enocding, nor ... | WP_Http_Cookie destroys cookie value through urldecode() | wordpress |
I have about 50 custom fields I need to delete at once, going through each one and deleting one at a time would take too long because it takes about 4 seconds for a page to load and I just don't have time to do that. I need to delete them because I previously used a plugin called Advanced Custom Fields (ACF), but appar... | You can use the SQL way. Go in your database tool, like phpMyAdmin or Adminer (also possible via Plugin in the WordPress back-end). Use the SQL area for creating custom queries. Before you start, create a backup of the database and also a single backup for the table <code> _postmeta </code> . Change the string <code> w... | Delete all custom fields at once? | wordpress |
I cannot figure out how to arrange my custom widgets one left and one right. I'm using this code to create custom widgets: <code> //Add my comments. Shows user his last 5 comments function dashboard_user_comments_widget_function() { echo 'beh!'; } function dashboard_user_add_comments_widget_function() { wp_add_dashboar... | The dashboard widget function <code> wp_add_dashboard_widget() </code> is just a wrapper for <code> add_meta_box() </code> . So you can use the underlying function instead. <code> add_meta_box( 'my_comments_user_dashboard_widget' ,'My comments' ,'dashboard_user_comments_widget_function' ,$screen // Take a look at the o... | Dashboard widget custom positioning? | wordpress |
I try to use this function i have created when a post is published for the first time. <code> function a_new_post($post){ $post_id = $post->ID; if ( !get_post_meta( $post_id, 'firstpublish', $single = true ) ) { // ...run code once update_post_meta( $post_id, 'firstpublish', true ); } } add_action( 'draft_to_publish... | The correct action is <code> 'draft_to_publish' </code> . To be sure you used the correct status try to get a list of all registered post statuses (including custom statuses) with: <code> <pre><?php print '- ' . implode( "\n- ", array_keys( get_post_stati() ) );?></pre> </code> On a vanilla installati... | Execute function when post is published | wordpress |
I wish to restrict the user from putting inline images in the article. I am using the Wordpress Attachments plugin to allow the user to attach images, which I then position and stylize the way I want. I also managed to remove the Upload/Insert link from the post through adding a hook to my functions.php of my theme. (T... | You can do this via, <code> add_filter('image_send_to_editor', 'restrict_images'); function restrict_images($html){ return false; } </code> ...now consider the above function primitive, because it will restrict images for all post types. We can modify that on a <code> post_type </code> by <code> post_type </code> basis... | How to disable "insert into post" only when selecting the Featured Image? | wordpress |
I'm actually using the qTranslate plugin to translate my website. It works really well with everything except one thing. the titles of my sidebar widgets. Actually, to translate some words we need to put tags like this: <code> <!--:en-->My English Title<!--:--><!--:fr-->My French Title<!--:--> <... | I just found the answer and instead of putting this in the Title: <code> <!--:en-->My English Title<!--:--><!--:fr-->My French Title<!--:--> </code> We need to put this code: <code> [:en]My English Title[:fr]My French Title </code> and qTranslate does the rest :) | Translate widget titles using qTranslate plugin | wordpress |
Fristly, sorry for my bad english. Secondly, I can't find a solution for my problem since 2 weeks. It's a simple things but I can't find how to do it. I explain my problem : I got 2 custom taxonomies call in a function "my_custom_init" : <code> register_taxonomy( 'directors', 'video', array( 'hierarchical' => true, ... | I think you can use <code> directors_row_actions </code> & <code> clients_row_actions </code> . Also you can use <code> tag_row_actions </code> which is called for every taxonomy. It accepts 2 parameters, first being the actions & 2nd being the term object. You can use this term object to filter out which actio... | Modify "View" in admin panel for custom taxonomy | wordpress |
just starting out in WP dev, and I'm looking for any guidance I can get. What I'd like to do is use a hook or filter to add my own option to the core WP gallery shortcode. I would want it to work just like the standard 'exclude' option, but still show those images for Administrators. So it would look something like thi... | This code should work in your functions.php <code> add_shortcode('gallery', 'custom_gallery_function'); function custom_gallery_function($atts) { $user = wp_get_current_user(); // if current user isn't admin, add posts to be hidden to exclude if(!in_array('administrator', $user->roles)) $atts['exclude'] = $atts['exc... | Adding option to Gallery shortcode | wordpress |
I have set up a simple mailer before I get the full implementation sorted. I've tried a few email addresses but am not receiving them even though it returns 'true'. I'm using wp_ajax as well if that makes a difference. functions.php // Check for email return in share folders add_action( 'wp_ajax_share_email', 'share_em... | You need to supply or line breaks for your header fields. For example: <code> $headers = "From:" . $from . PHP_EOL; </code> Or put the header fields into an array, in which case you don't need to add the line breaks manually. <code> $headers[] = "From:" . $from; </code> Email headers are not 'normal' text. Those line e... | Using wp_mail in functions.php | wordpress |
I have certain posts that are nothing but [gallery] with quite a few images in them. Is there a way to define an auto generated excerpt to only display the first three images for these posts on the index, so that users would have to click through to see the rest? Thank you. | You can do this pretty easily using the <code> do_shortcode </code> function. Check if an instance of <code> [gallery] </code> exists in your post content. Here's a simple function to drop in functions.php that checks the current post's content for the gallery shortcode: <code> function gallery_shortcode_exists(){ glob... | First three images in post excerpt | wordpress |
I am trying to build a Wordpress plugin here with a custom user admin area. What I would like to do is when the user adds /edit at the end of the page, it should open a page from my plugin. So for example <code> example.com/page-1/edit </code> should load <code> example.com/wp-content/plugins/custom-user-admin-area/ind... | stackexchange-url ("Create an endpoint"). In the callback function for the endpoint call your plugin functions internally, so the whole WordPress environment is available and you are still on the same domain, no matter where the stackexchange-url ("plugin URL") is. Plus, make sure not to flush the rewrite rules on ever... | How to Rewrite Wordpress URL for a Plugin | wordpress |
Is there an efficient way to change a post status from 'published' to 'draft' when a user of a certain type tries to update their posts. I tried something along these lines <code> function change_post_status($post_id) { if(current_user_can('rolename')) { $current_post = get_post( $post_id, 'ARRAY_A' ); $current_post['p... | So I ended up using the wp_insert_post_data filter and came up with the following, which after testing, seems to be working properly. <code> add_filter('wp_insert_post_data', 'change_post_status', '99'); function change_post_status($data) { if( (current_user_can('role')) && ($data['post_type'] == 'custom_post_t... | change a post status when users update posts? | wordpress |
I'm a complete noob when it comes to Wordpress, but I've joined a company who use it as their website and they need an answer quickly. I want to know if I can I lock a post in position, so it always appears on the homepage ? I don't want to use a plug-in (preferably) Any suggestions or advice is greatly appreciated. Th... | Depending on the theme you are using. You might want to look into creating a page for your home page and then going into settings > reading and making that page your static home page. If you want to lock a single post on your front page and your theme lets you... try : I the Post editor find the "Publish" section. Next... | Can I lock a post in position, so it always appears on the homepage? | wordpress |
The lack of documentation for the WP_Widget class is driving me mad. Here is what I have salvaged off the codex: <code> public function form($instance){ ?> <label for="<?php echo $this->get_field_id('title'); ?>">Title: <input type="text" name="<?php echo $this->get_field_name('title'); ?>... | <code> $instance </code> holds the data stored for this widget instance as an array. You could use the same widget multiple times, and each would get different data. <code> get_field_name() </code> and <code> get_field_id() </code> returns name/id attributes for that widget. They are unique for each widget, but do not ... | What is this instance variable doing in the Widgets class | wordpress |
I want to include ads HTML code after related post plugin. My site my <code> single.php </code> code below: <code> <?php if ( get_option('wap8_author_gravatar') == 'true' ) { ?> <div id="post-header"><!-- Begin post header --> <div class="post-title clear"><!-- Begin post title --> <div... | I'm absolutely guessing here, but you may want to put your code between: <code> <?php if ( get_option('wap8_post_rel') == 'true' ) { locate_template( '/includes/relatedposts.php', true, true ); } ?> // these are your related posts </code> and <code> <?php comments_template( '', true ); ?> //these are the co... | Want to include ad code after related post | wordpress |
I have a wordpress site which uses a plugin to provide a music player. This plugin uses frames to keep the music playing while the user browses the site. Mobile devices have trouble with this because of the frames. When I disable the plugin then the mobile devices view the site fine. I want to disable this plugin for a... | This question is borderline within (if at all) the scope of WPSE as per the newly committed change to the stackexchange-url ("FAQ"). If done "with code", the easiest would be to employ css media queries to hide the frame (or parent element) by its class or id. For the sake of completeness, there is a WP core function t... | Is there a plugin which disables other plugins for mobile browers? | wordpress |
I am creating a CSS generator in my WordPress theme and I want to be able to save custom skins with images as well. My problem is that I have a hierarchy like /skins/custom-skin/images for the uploaded images, but as you know the WordPress Media Uploader puts them in the uploads folder by default, sorted by date. My qu... | In, <code> Dashboard -> Settings -> Media </code> You can uncheck the, ☑ <code> Organize my uploads into month- and year-based folders </code> ...and optionally change the path uploads (but this would effect all uploads of course). Optionally you can hook onto the <code> upload_dir </code> filter and... | Media Uploader in custom path | wordpress |
I am looking for a way to generate featured image per post based on the first image in the post for old posts without a set featured image. I'm switching from handmade thumbnails to auto generated featured images. With new posts I got this working, but I don't want to set a featured image of my other 2000 posts by hand... | You can look into this post: http://ken.ph/first-image-of-wordpress-post-as-thumbnail/ Or if you're comfortable with MySql try using this (obviously check it on local database first): <code> INSERT into wp_postmeta (meta_value, meta_key, post_id) SELECT DISTINCT(ID), post_type , post_parent FROM wp_posts WHERE post_typ... | Generate featured images old posts | wordpress |
By using the code below, I can create a new post and upload an image to wordpress's <code> upload </code> directory as a attachment through a form's submitted data. <code> $new_post = array( 'post_title' => $title, 'post_content' => $content, 'post_status' => 'publish', 'post_date' => date('Y-m-d H:i:s'), '... | You can set the uploaded image as the post thumbnail via, <code> update_post_meta($post_id,'_thumbnail_id',$attach_id); </code> Example... <code> if ($_FILES) { foreach ($_FILES as $file => $array) { if ($_FILES[$file]['error'] !== UPLOAD_ERR_OK) { return "upload error : " . $_FILES[$file]['error']; } $attach_id = m... | Insert an image into a post by API | wordpress |
This is a strange one. I host a website that is primarily for children. All posts are moderated. Users are required to enter a user name and location (State), but are not required to be registered and logged in to make a comment. Some users have started using a common user name, allowing them to see one another's posts... | Check in your theme's <code> comments.php </code> for the <code> wp_list_comments() </code> function. In the Twenty Eleven theme, for example, uses a custom callback function which is in the <code> functions.php </code> file and outputs the template for comments. Within this comments template, you can then use <code> w... | Hide comments awaiting moderation from user who submitted the comments | wordpress |
I have a WordPress multisite network and the question is related to one of my sites on that network. The site has a login page before you can use that site. So I created a user from wp-admin with the Subscriber role. The idea was to let that user log in to the site but not have access to wp-admin, but it didn't work. S... | you'll find the user in network admin => users | Users disappeared from wp-admin | wordpress |
This widget code is causing my WP site to white screen. I've re-factored the code about 5 times trying to solve it, but no luck. <code> <?php class latest_mag_issue_widget extends WP_Widget { function latest_mag_issue_widget() { $widget_ops = array('classname' => 'widget_latest_issues', 'description' => 'Lates... | <code> register_widget( 'latest_mag_issues_widget' ); </code> should be <code> register_widget( 'latest_mag_issue_widget' ); </code> Update After fixing that though, there are a couple of other errors. Here's the complete updated copy of your code that I could get working: <code> class latest_mag_issue_widget extends W... | Simple widget causing whitescreen | wordpress |
I am creating a custom plugin that has dynamic forms and I wanted to ask on how I can create a dynamic form action url. Example is Contact Form 7, how did cf7 create the form action url without creating a new page or a file for submission? Please share any idea on how to do something like that for plugin. Thanks | It doesn't need a new submit URL, most of the plugins submit the form on the same page(the one on which the form was rendered), then before rendering the form they check if there is submitted data present. Then for eg. if data is present then they have to show a thankyou message & skip rendering the form, if there ... | Wordpress plugin url for form submit | wordpress |
I want to create a local network on a Windows machine using subdomains. I do not want to edit the <code> hosts </code> file for each new subdomain. But Windows does not support wildcard subdomains, and the Codex doesn’t say anything useful about this topic. What should I do? | There is a plugin for that: WP XAMPP Multisite Subdomains. Unfortunately, there is no English description available. I’ll try that here. The following guide will set up a multi-site under <code> mu.wp </code> with subdomains. 1. Basic Installation Start with a fresh installation of WordPress and XAMPP. Create a network... | Multisite on Windows with wildcard subdomains | wordpress |
Alright, so i have a custom post type called Blurbs (translated, sort of). I want to add a static set of categories for the posts within Blurbs (i don't want the user to be able to create custom categories). I want two different types of categories; links and page-excerpts. I did some reading and came to the conclusion... | 1) Make it <code> show_ui => false </code> Then to show it on the post edit screen add the box manually <code> add_action('add_meta_boxes', 'meta_boxes_function'); function meta_boxes_function() { add_meta_box('categoriesdiv', 'categories', 'post_categories_meta_box', 'blurb', 'side', null, array( 'taxonomy' => '... | Creating "static" taxonomies to choose from, inside custom post type? | wordpress |
I'd like to check if a registered sidebar has widget content - but can't seem to find a WP function for this - is_active_widget checks if it has content, but not if it exists or not. <code> function ql_widget( $widget, $widget_name, $element = 'sider' ){ if ( $widget ) { // widget name passed ## // check if widget is a... | <code> wp_get_sidebars_widgets(); </code> will return a list of all sidebars & the widgets in each of them. This can allow you to check for sidebars with no widgets | check if registered sidebar is active & has widget content | wordpress |
I'm using a custom field plugin called Advanced Custom Fields to create custom fields, but i don't think that's what's causing the problem. When i fetch the custom fields from a template using get_post_custom(), the tags in the field is removed. If i view the source, it's written out like a big chunk of text but with "... | Advanced custom fields plugin has it's own set of functions to use, use them instead. Also text fields there have an option of weather to save HTML or pure text http://www.advancedcustomfields.com/docs/ They also have nice examples if you go to the documentation of the particular field type | Paragraphs removed when using get_post_custom()? | wordpress |
I need to add a check-in feature (very similar to foursquare check-in) in worpress based site. There will be "Check in" button at the top of the web site, and clicking on it the visitor will be presented with a list of places. Can somebody guide me to decide which one is more suitable for wordpress architecture? i. Cli... | I would use an AJAX call + modal dialog. And for the API, just create a plugin, and follow the steps on this page to create your own custom ajax action. | How to implement a plugin featuring foursquare like check-in | wordpress |
I've registered several custom post type using a custom plugin. All of them seems to work fine. All are listed under the Post Menu. The problem occurs when I saved a custom post entry. The custom post type is saved on the database, and the permalink works fine from the front end. But strangely, the custom post type tab... | Some words used as names for post types will produce unpredictable results, in your case, the word <code> order </code> is a reserved term and is causing problems with the query. Change that post type name to something unique and the admin UI will behave. | Saved custom post type entry doesn't appear on custom post type table | wordpress |
I'm trying to reduce my database queries. I don't have any sidebars or widgets set but I noticed the following query <code> SELECT option_value FROM wp_options WHERE option_name = 'widget_pages' LIMIT 1 </code> Similar queries happen for widget_calendar, widget_links, widget_tag_cloud, and widget_nav_menu. 5 database q... | Does unregistering them the also disable the database queries? Goes in functions.php: <code> //Unregister all Default Widgets function unregister_default_wp_widgets() { unregister_widget('WP_Widget_Pages'); unregister_widget('WP_Widget_Calendar'); unregister_widget('WP_Widget_Archives'); unregister_widget('WP_Widget_Li... | Widget queries even when there are no sidebars? | wordpress |
How can I restrict users (based on Capabilities ) from editing their published posts after a custom amount of time. For instance, a user that can <code> publish_posts </code> (authors) can not edit a their post if it is older than 3 days, and a user that can <code> moderate_comments </code> (editors) can not edit any p... | I took the example code from the Wordpress user_has_cap filter codex page and modified it. Add this code to your theme functions.php: <code> function restrict_editing_old_posts( $allcaps, $cap, $args ) { // Bail out if we're not asking to edit or delete a post ... if( ( 'edit_post' != $args[0] && 'delete_post' ... | Restrict users from editing post based on the age of the post | wordpress |
I'm requesting the wordpress function <code> if (email_exists($email)) { ... } </code> from a file (email_check.php) via ajax. Using this function is causing a server error though. The origin (from an input text field): var check = $('#email-input'); var email = check.val(); $.ajax({ url: "email_check.php", data: {'ema... | This happens because the PHP file you are using has no connection to WordPress, the function is never loaded. Use the stackexchange-url ("built-in AJAX-API") instead, and it will work fine. | Using email_exists() wp function in an ajax request | wordpress |
how do you set the current post ID as a JS variable with localize_script? It seems like the $post variable isn't availible in the functions.php file. When is it created? Do i have to add localize script to a hook? Which? | You should declare <code> global $post; </code> before attempting to access this variable, but to answer your question regarding when it is created, the 'wp' action hook is the safest bet. As such I'd suggest the following in your functions.php file as a simple solution <code> function my_localize_post_id(){ global $po... | How to get the post ID when creating JS variables with localize_script | wordpress |
I'm developing a site on a server that the client has access to as well and what I'd like to do is show <code> WP_DEBUG </code> only for administrators. Referencing Yoast's article on a way around this: <code> if ( isset($_GET['debug']) && $_GET['debug'] == 'true') define('WP_DEBUG', true); </code> would show <... | I don't think there is a universal URL hook. There are a lot of hooks and I may have missed it, but I don't think there is one. You can look through the hooks at adambrown.info. There are a lot of URL hooks, but not a universal one. If I may suggest another solution: Log the errors to a files. <code> /** * This will lo... | Define WP_DEBUG conditionally / for admins only / log errors (append query arg for all links?) | wordpress |
i want when i publish any post then it show my facebook with feature image. because most of plugin don't show feature image. it's show other image. please tell me how i can do it except - simple connect facebook and add link to facebook.plugin.i already use sample connect facebook plugin but it's not publish automatica... | Change your Facebook plugin: I recommend you change the plugin to the official Facebook plugin - it's been made by some of the same people and allows you to publish immediately. Image in your RSS feed: Your RSS feed should be found at http://www.desyfun.tk/feed (but it's not there?) because you are using another RSS fe... | Automatic connect wordpress to facebook with featured image? | wordpress |
I am using <code> WP_User_Query </code> to search use by name, ID, email etc... In that case I need to use <code> search_columns </code> field to pass ID or email of user. What i am doing is <code> $my_users = new WP_User_Query( array( 'role' => $role, 'offset' => $offset , 'number' => $number, 'fields' => ... | This is covered in the link you reference: The <code> search_columns </code> attribute does not set what should be searched for in each column, but instead specifies which columns should be searched for the term set in 'search'. Specifically, you can only search for one term - but you can look in one or more columns. <... | How to use search_columns in WP_User_Query? | wordpress |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.