question stringlengths 0 34.8k | answer stringlengths 0 28.3k | title stringlengths 7 150 | forum_tag stringclasses 12
values |
|---|---|---|---|
I’ve got a metabox I set up using WPAlchemy that allows authors to add a link to an associated post. It’s been working fine for months but now for some reason the dropdown with the appropriate posts isn’t updating. Here’s the code in the custom post meta php file: <code> <p> <?php $mb->the_field(‘product_vi... | Try WP_Query to get the posts, since <code> get_posts() </code> also makes use of it: <code> $args = array( 'category_name' => 'product-videos', 'posts_per_page' => 5000, // or -1 if you want all 'offset' => 1 ); $the_query = new WP_Query( $args ); if ( $the_query->have_posts() ) : while ( $the_query->ha... | get_posts in meta box dropdown not showing latest posts | wordpress |
Trying to build a search that not only searches the defaults (title, content etc) but also a specific custom field. My current query: <code> $args = array( 'post_type' => 'post', 's' => $query, 'meta_query' => array( array( 'key' => 'speel', 'value' => $query, 'compare' => 'LIKE' ) ) ); $search = new ... | As per stackexchange-url ("Nick Perkins'") suggestion, I had to merge two queries like so: <code> $q1 = get_posts(array( 'post_type' => 'post', 's' => $query )); $q2 = get_posts(array( 'post_type' => 'post', 'meta_query' => array( array( 'key' => 'speel', 'value' => $query, 'compare' => 'LIKE' ) ) ... | Using meta query ('meta_query') with a search query ('s') | wordpress |
CSS-Tricks suggests this code to load jQuery. However, I'm curious if anybody has done the same thing in functions.php with two fallbacks: the Microsoft hosted jQuery being the first option and locally hosted jQuery being the second , that is, in the case the Google library decides not to load/crashes/gets eaten by a p... | I use a similar pattern to enqueue jQuery from the Google CDN (as the CSS Tricks example). However in my footer (typically <code> footer.php </code> ) I'll usually hard code the following fallback. <code> <script type="text/javascript"> if (typeof jQuery === 'undefined') { document.write('<script src="<?php... | Loading jQuery With Two Fallbacks | wordpress |
I am trying to determine if an item has a sub-item with depth 1 or higher. I cannot find anywhere if there is some function/query I can write that grabs the current item looks in the database if it has any sub-pages and returns <code> true </code> . What I aim to do with this is give the <code> <li> </code> class... | You can filter <code> wp_nav_menu_objects </code> and add the classes in one rush. You don’t even need a custom walker for that. <code> add_filter( 'wp_nav_menu_objects', 'add_has_children_to_nav_items' ); function add_has_children_to_nav_items( $items ) { $parents = wp_list_pluck( $items, 'menu_item_parent'); foreach ... | Determine if a navigation item has children | wordpress |
stackexchange-url ("Here") is an amazing solution to restrict the creation of new parent pages, and I would want to use it, but the newly created sub-pages are saved only as drafts and this was not solved (see last comments at mentioned link). The problem is that this code always saves the page as <code> Draft </code> ... | you actually don't need any ajax or server side action, simple see if the user has selected a parent page: <code> add_action( 'admin_head-post-new.php', 'publish_admin_hook_wpse_78690' ); add_action( 'admin_head-post.php', 'publish_admin_hook_wpse_78690' ); function publish_admin_hook_wpse_78690() { global $current_scr... | Allow only new sub-pages to be created | wordpress |
I have two parent categories, and pagination is working fine on them - the paged url's show as: <code> /parent-category-1/page/2/ </code> ... etc <code> /parent-page/parent-category-2/page/2/ </code> ... etc However, when I go to a child-category, pagination returns a 404 - for e.g.: <code> /category/parent-category-1/... | I was finally able to get this working! Here's how: What I had misunderstood (being a WP noob and all...) is that <code> get_query_var('page') </code> is for pages, and <code> get_query_var('paged') </code> is for posts. http://codex.wordpress.org/Function_Reference/get_query_varfor So I replaced these two lines <code>... | Pagination breaks on child-categories, works fine on parent-category | wordpress |
I imported over 1000 posts from a Tumblr gallery. All the posts are untitled, but each has a photo and name inside of the post. How do I make take the content of each post and make it the post name? | Hook into <code> the_post </code> – called when the post is actually used – and fill the title. Be aware the slug has to be changed too. If you are used not to enter a title, hook into <code> save_post </code> too, and let the same code do this for you. The code Download on GitHub <code> <?php /** * Plugin Name: T5 ... | Fill post titles from post content? | wordpress |
<code> header('Location: /page-name/?var1=' . $_GET['var1'] . '&var2=' . $_GET['var2'] ); exit(); </code> The result of the above code ends up redirecting the site to: <code> http://www.domain.com/page-name/?var1=val1&amp;var2=val2` </code> I have a feeling Wordpress is cleaning the ampersand in the URL, but I ... | WordPress has API functions for doing both of these things- <code> wp_redirect </code> and <code> add_query_arg </code> . | adding GET variables to a header() location in a page template | wordpress |
i have created custom post type 'event' to display in single page named single-event.php file but it provides me 404 error. how i can solve this problem even i used flush_rewrite_rules(); please provide some idea....... <code> function custom_event() { $labels = array( 'name' => _x('Event', 'post type general name')... | Follow this tutorial for creating the custom post type. Here is the working code as per your requirement: <code> function create_post_type_event() { //Create custom post type for event $labels = array( 'name' => _x('Event', 'post type general name'), 'singular_name' => _x('Event', 'post type singular name'), 'add... | page not found for single-type.php file | wordpress |
On my Wordpress webpage, I have several Pages. Now I want to display "Next Page" & "Previous Page" links. I know that there are several ways out there to do this, but they all fail because I want to skip one page using this link system. The existing Wordpress functions for this can exclude pages, but if the next pa... | I just tried this and it works for me. Given that you would like to exclude page id 4 this is the code you are looking for. <code> <?php $pagelist = get_pages('sort_column=menu_order&sort_order=asc&exclude=4'); $pages = array(); foreach ($pagelist as $page) { $pages[] += $page->ID; } $current = array_sear... | Next Page & Previous Page links - skipping a single page - how? | wordpress |
I seem to be having this issue with all of the images on my site. First I optimise a .jpg in Photoshop to approx 100k (it's a large header image), then I upload through Wordpress' media uploader as a Featured Image. Here's the code I use to output the image in my template file: <code> <?php if (has_post_thumbnail( $... | Instead of using timthumb, use the internal image API. Firstly, specify the custom size you're wanting to use by using <code> add_image_size </code> : Usage: <code> <?php add_image_size( $name, $width, $height, $crop ); ?> </code> So you would put this in your themes <code> functions.php </code> : <code> add_imag... | Large image upload size (using timthumb.php | wordpress |
I basically want to use WP_Query to select 3 latest posts which have featured images and this is the only way I can think of. regards edit tried <code> $query = new WP_Query( array( "post_type" => 'case-study', 'meta_key' => '_thumbnail_id', "posts_per_page" => '10', 'orderby' => 'menu_order' ) ); </code> w... | You've provided the answer to your own question, query for meta key <code> _thumbnail_id </code> to get posts with a featured image: <code> $args = array( 'meta_key' => '_thumbnail_id', 'posts_per_page' => 3 ); $latest_with_thumbnails = new WP_Query( $args ); </code> | How to query posts with featured images | wordpress |
Since WordPress 3.5, the core developers have decided to keep xml rpc enabled by default and there are no options in the Admin to disable it. This blog post explains how to disable it by modifying the xmlrpc_enabled filter <code> add_filter('xmlrpc_enabled', '__return_false'); </code> But this doesn't seem to work, I s... | To remove the HTML link: <code> remove_action( 'wp_head', 'rsd_link' ); </code> To stop all requests to <code> xmlrpc.php </code> for RSD per XML-RPC: <code> if ( defined( 'XMLRPC_REQUEST' ) && XMLRPC_REQUEST ) ) exit; </code> This is plugin territory. stackexchange-url ("Never use this code in a theme"). | xmlrpc_enabled filter not called | wordpress |
I am trying to make contact form 7 pop up in a thickbox modal window. I can either use <code> do_shortcode </code> or the shortcode but I'm not sure how to set it up. Can someone push me in the right direction? From the Thickbox page , it looks like I should be using either inline Content, iFramed Content, or AJAX Cont... | A solution I can think of is creating an almost empty page template that contains the bare minimum <code> header </code> , <code> body </code> (your shortcode) and <code> footer </code> . Create a page with this template and load iFramed. Like: <code> <?php /** * Template Name: Almost Empty Page for Thickbox */ // R... | How do I make Contact Form 7 pop up in thickbox? | wordpress |
I'm working on a client project and they would like to use posts much like we would traditionally use pages due to there being a limited number of pages one WordPress install can handle and the ability to categorize posts more efficiently. The problem I'm running into is the client would like there to be child posts fo... | Use pages for pages and posts for posts. Both post types are specialized for their use case. They use different permalink settings and list tables. The number of pages is not limited. I have seen site with more than 50.000 pages running smooth. In earlier days, the permalink parsing for pages was slow under some circum... | Using Posts Like a Page | wordpress |
I am using the below wpdb-> prepare function in a sql statement. I am passing in several variables some field names and some values. When I try to use the %s for the field name it puts single quotes around it. How can I prevent the single quotes around the field name? The sql statement will not execute with the single ... | You cannot suppress the quotes in $wpdb. Run <code> mysqli_real_escape_string() </code> in your script on these variables. | wpdb-> prepare function remove single quote for %s in SQL statment | wordpress |
This question has been a pain in my side for the last few days. I am using a function to display page numbers and next/previous links with WP_LINK_PAGES. The code I'm using (below) is a shortened version of the code found stackexchange-url ("here") - to the best of my knowledge, it is correct. (Go easy on me, just divi... | In my opinion CSS isn't the right way, it should be a "real" space. Also there is no class to target the differents links in the string. Try this code: <code> function wp_link_pages_args_prevnext_add($args) { global $page, $numpages, $more, $pagenow; if($page-1) # there is a previous page $args['before'] .= ' '. _wp_li... | Adding an Unlinked Space in a Custom Function | wordpress |
In previous installations of WordPress it was possible to number images in <code> attachment.php </code> using the code below, which was originally provided stackexchange-url ("here"). However, I'm finding that this code no longer works as the image numbers are inaccurate. Is there a new code available? <code> <?php... | There is no complete solution possible. And that is not new. Any image can be a part of a gallery in a post that is not that image’s parent. So the post parent is not a useful parameter. The new interface makes such galleries easier to create, but they were possible in earlier versions too. Even if the attachment’s par... | Image Gallery Numbers for 3.5 | wordpress |
I would like to construct a query to show a list of custom posts ("podcasts") with the urls to their respective attachments. Each custom post_type ("podcast") has 1 attachment (the mp3 file belonging to it's post_parent). I would like an unordered list showing podcast's title, and it's attachment url (guid of the attac... | Trust us on this one, you want to use WordPress' query solution. It provides a whole bunch of awesome extras, such as object caching, autoloading of metadata, etc. Plus, it's almost guaranteed to be forwards compatible. So. How to do what you've inquired about. Something like this ought to do the trick: <code> <?php... | Show list of custom posts with respective attachments? | wordpress |
In WordPress 3.5, when images are inserted into posts, the title attribute is not included in the image tag. The Lightbox plugin I am using requires the title tag to be present on images; besides, I like having a hover tool-tip. Is there some way to restore the previous behaviour of including the title attribute? | You can hook into the <code> media_send_to_editor </code> filter and add the title tag to the generated HTML image tag: <code> function wpse_78529_restore_image_title( $html, $id ) { /* retrieve the post object */ $attachment = get_post( $id ); /* if the title attribute is already present, bail early */ if ( strpos( $h... | Restore Image Title Text | wordpress |
I have this Wordpress plugin file structure with "myfolder" as the main folder. There is another subfolder inside this main folder named as "resources". Inside this resources folder contains two subfolders: a) JS b.) images Inside images folder I have one image "myimage.png". Inside JS file, I have a script named "mysc... | For this purpose you can use <code> wp_localize_cript() </code> function, like this: <code> function localize_my_script() { $image_url = plugins_url( 'resources/images/myimage.png', __FILE__ ); $localizations = array( 'imageURL' => $image_url ); wp_localize_script( 'my-script-handle', 'localizedVars', $localizations... | Plugin: Relative URL to images in another folder accessed inside a JS file | wordpress |
I want to get the right link format for the second link, i tried many time to move the a open tag but no way the result is as the image below. <code> foreach( $terms as $term ) : echo '<div class="one_half last">'; $customposts = new WP_Query( "taxonomy=$taxonomy&term=$term->slug&posts_per_page=2" ); e... | First of all you have the PHP syntax all messed up. Second, you misused some WordPress template tags - you already echo the entire link like so you need to return post permalink and title, but right now <code> the_permalink </code> and <code> the_title_attribute </code> functions echo the code. Here's your code fixed: ... | Fix html inside a for loop | wordpress |
I was wondering what is the best way to translate some longer texts with html formatting. There was a couple of solutions I came across, but did not know what would be the best one. Writing a couple of html files with language extension (e.g. maintext_en.html, maintext_de.html, ...) and import this files. Pro : It's ea... | Most translation tools are really hard to use when you try to handle a long text, so the translators have to use a HTML editor anyway. Use separate files, but use the language prefix as directory name: en main.html help-main-options.html help-special-options.html de main.html help-main-options.html help-special-options... | Translating long texts with html formatting | wordpress |
I'm asking for your help to develop a system average. I have a website video games and I created a function that automatically calculates the average for each review. It works very well. The problem is that I would like to display in my sidebar Rated 5 games. Unfortunately, I can not ask WP to calculate and compare eac... | You can accomplish this via the <code> save_post </code> action: <code> add_action( 'save_post', 'wpa78558_save_average_meta', 100 ); function wpa78558_save_average_meta( $post_id ) { if ( !wp_is_post_revision( $post_id ) ) { $graphics = get_field('graphics', $post_id); $gameplay = get_field('game-play', $post_id); $li... | Calculate and save an average in a meta | wordpress |
I use a shortcode handler in my plugin. The shortcode can have different (optional) parameters. And it should be possible to use for example 2 shortcodes on a static WordPress page with text before, between and after the shortcodes. An example could be: <code> Lorem ipsum dolor sit amet, consetetur sadipscing elitr <... | Without seeing your <code> show_sticky_posts, show_lastest_posts, show_lastest_missions,show_all_posts_from_categories </code> i can guess that the shortcode content is always before the post content beacuse this functions are echoing/outputing the result and a shortcode should return content instead so you can try usi... | Wrap text around shortcode | wordpress |
Has anyone had experience capturing video from a webcam and adding it to a users album inside of BuddyPress and BuddyPress Media? BuddyPress Media isn't necessary if there's a better solution BP Media has a premium FFMPEG add-on for converting video which I think will be needed if this is possible; but I have no real e... | I'm from the team that developes BuddyPress Media. Till now, capturing a video involved expensive (in various ways) setups. It depended on flash and silverlight which could reach the hardware (mic and webcam) . Html5 is the way to go, now. However, the support isn't wide enough. This might help you: stackexchange-url (... | Capture Webcam Video within Buddypress (and BuddyPress Media) | wordpress |
It's usual that WordPress stores comment author name and email in the user's browser cookies, so next time the visitor has to comment, they have their name and email already filled in automatically. My question is: Is it possible for WordPress to store a visitor's comment cookies on two computers at different locations... | The cookies are fine. The secret is caching . The blog owner has set up a server side output caching that doesn’t stop when someone sends as cookie. It should – as you can see, because caching pages with personal data is … odd. Lesson: Don’t cache personalized output. | Can WordPress store comment cookies on two different computers? | wordpress |
Can the wp-plugins (Must Use Plugins) URL be targeted for use in functions.php? I have a mu-functions.php file in the mu-plugins folder. One function calls a javascript file ( <code> alerts.js </code> ) located in <code> example.com/wp-content/mu-plugins/js/ </code> . How can I target the mu-plugins folder in my functi... | Use the <code> WPMU_PLUGIN_DIR </code> and <code> WPMU_PLUGIN_URL </code> constants :) <code> function load_my_alerts(){ wp_register_script( 'my_alerts', WPMU_PLUGIN_URL . '/js/alerts.js', array( 'jquery' ) ); wp_enqueue_script( 'my_alerts' ); } add_action('admin_enqueue_scripts', 'load_my_alerts'); </code> | Can the wp-plugins (Must Use Plugins) URL be targeted for use in functions.php? | wordpress |
I searched a way to automatically load all attached videos in a custom post type as SublimeVideo playlist. After some time I got it working and here I'll share the code with everyone who is interested to do it the same way. | First of all get all video attachements of the post or page: <code> <?php $attachments = get_children( array('post_parent' => get_the_ID(), 'post_type' => 'attachment', 'post_mime_type' => 'video') ); if ( $attachments ) { ?> </code> 2nd: Load the videos into the playlist code with a unique ID ( http://d... | Sublime Video: Playlist which gets all attached videos | wordpress |
I am creating a plugin. In this plugin I have shortcodes that provide some logic and content for pages. This way I have created 'Page A' and 'Page B'. Both of the pages will redirect user to external page. The external page is not written by me and will not process any of my $_GET or $_POST values. Then this external p... | I really have no idea what you're implementing here - I don't know how a plugin "has pages," for instance. As such, I'm afraid I cannot offer you much help in the way of an example, but I'm confident that what you ask could be accomplished using the Transients API , or its ascendant the Options API (preferably Transien... | Passing variables trough 2 pages | wordpress |
I'm building a new theme. I'm now working on to figure out which file is needed to show the "whole" post for a specific date which displays when you click on a date in the built in WordPress calendar widget? Somebody who has a clue which it is? | <code> archive.php </code> is used to display author, search, category, tag and date archives. As clicking on a calendar day will take you to the date archive for that day, then the file you're looking for is <code> archive.php </code> . More specifically, WordPress will check for these files in this order, stopping wh... | Which file displays the date archive? | wordpress |
I am using following functions to display pagination on archive pages of my site. <code> <?php previous_posts_link('< Previous', $loop->max_num_pages); ?> <?php next_posts_link('More >', $loop->max_num_pages); ?> </code> And it is working very fine on my localhost. But not on my server, the issu... | You could filter <code> get_pagenum_link </code> . The parameter has to be <code> paged </code> , not <code> page </code> then. <code> add_filter( 'get_pagenum_link', 'wpse_78546_pagenum_link' ); function wpse_78546_pagenum_link( $link ) { return preg_replace( '~/page/(\d+)/?~', '?paged=\1', $link ); } </code> But I wo... | Change permalink structure for pagination only | wordpress |
I would like to have a separate page to submit/edit tags. Any user can edit or submit tags. But it should be published only after admin approval. Is there any function available like <code> wp_insert_tag() </code> ? Update: After Kaiser's answer I've tried like this. <code> $x = wp_insert_term( 'test', 'post_tag', arra... | In case that I have understood your (very brief) question and you're not actually talking about the <code> post_tag </code> -taxonomy then you have <code> wp_insert_term() </code> , which is the underlying API function. Edit As to the comment, there's the need of meta data for a term and administrator approval. WordPre... | Frontend tag edit/submit form | wordpress |
I am using the wordpress Advanced Custom Fields plugin . This question is about the select field , and in the documentation only tells me how to output the value, not the label/name. I can't see this functionally in the documentation and was wondering if anyone had any ideas? For example, to create Select field content... | Please see this thread for answer... http://support.advancedcustomfields.com/discussion/comment/12690#Comment_12690 | Advanced Custom Fields select field : How to echo the label, not the value? | wordpress |
There is a plugin that's conflicting with mine when the user loads the admin pages of my plugin, therefore I want to deregister and remove the conflicting script on these pages. Here is the code for the conflicting script:- <code> add_action( 'admin_head', 'function_name' ); function function_name() { if ( is_admin() )... | Yep, it's possible, but you want to use <code> wp_dequeue_script </code> . Try this: <code> <?php function admin_hc_deregister_conflicts() { wp_dequeue_script('script_name'); } </code> | If a Script has been enqueued but not registered can I still removed it? | wordpress |
I'm trying to establish a blog with NGINX and PHP-FPM. I wonder if my version of PHP should work with WordPress <code> /usr/bin/php-cgi -v PHP Warning: PHP Startup: magickwand: Unable to initialize module PHP 5.2.17 (cgi-fcgi) (built: Sep 17 2012 00:15:25) Copyright (c) 1997-2009 The PHP Group Zend Engine v2.2.0, Copyr... | According to the official system requirements , PHP version 5.2.4 or greater should work. However, some plugins and / or themes may require PHP version 5.3, though. BTW, PHP 5.2 has reached its End of Life a couple of year back (in 2011). | Which version of PHP-FPM is necessary to work with WP 3.5? | wordpress |
<code> <?php if( $settings['logo']) : ?> <a href="<?php echo esc_url( home_url( '/' ) ); ?>" title="<?php echo esc_attr( get_bloginfo( 'name', 'display' ) ); ?>" rel="home"><img src="<?php echo $settings['logo']; ?>"/></a> <?php else if ( $settings['logo_option'] == 'image' ... | Remove the spaces in your <code> else if </code> s such that they become <code> elseif </code> s. PHP interprets <code> else if </code> as though it were an <code> if </code> conditional nested within an <code> else </code> , and as such is expecting the <code> else : </code> to match your <code> if : </code> when it e... | Conditionals: What is wrong with my if/else statements? | wordpress |
I just wondered what this row in the Wordpress Database refers to? <code> 32 gzipcompression 0 </code> I stumbled upon it in the WP options table. What if I set the value to <code> 1 </code> . I do already have gzipcompression enabled via htaccess, so I simply wondered what this is? Thank you for your answer. | It's set in <code> schema.php </code> , the WordPress Administration Scheme API . You can also find it in the Codex . As you can see from a search through core, there's (as far as my search went) exactly no use case for it, aside from defining it as <code> 0 </code> when adding that option to the DB. If you want to kno... | Wordpress DB: options-table –> 32 gzipcompression? | wordpress |
I'm trying to delete all comments from posts in a certain category in a Wordpress database. The Wordpress database is rather complicated so this must be probably some join of <code> wp_posts </code> , <code> wp_comments </code> and <code> wp_term_relationships </code> as the categories are not stored with neither posts... | The wordpress database seems fairly straight forward and is extremely well documented: http://codex.wordpress.org/Database_Description It seems to me that all the category information is stored in the table wp_term_relationships . So you should select from the comments table, join it with the posts table and then the t... | How to delete ALL comments from certain category in Wordpress database? | wordpress |
I would like to know how to access my website using Ip address instead of domain. Like 173.252.100.16 can used to access facebook. My Website is: www.jijojose.me Server have multiple websites hosted. | Open a Terminal or CMD and type <code> ping www.jijojose.me </code> then press Enter. The IP address listed it's the server's IP address. However You won't be able to access you website this way (e.g. <code> http://173.252.100.16 </code> ) unless: You know the folder where it is located on the server, and your server h... | How to access my site using IP Address? | wordpress |
I'm building a site that doesn't want any styling applied to the entry-content, because it should keep the formatting of the text. Bizarly, it works on old entries, but new entries via the front-end system fail: <code> http://madebylars.nl/music/?page_id=373 </code> Example: This one works: <code> http://madebylars.nl/... | The pages you are linking use two different characters, one is the <code> &mdash </code> and the other I don't know the name, it does not translates into an Html entity... Original: <code> 2——-2——-7——-7——-| </code> <-- Mixed characters Using the character that works: <code> 2---2---7---7---| </code> <-- This ... | Formatting with | wordpress |
StackExchangers! I have searched the internet left right and center and still cannot find a way to alter the search results that are displayed. Basically I would like no posts and only child pages of this parent page to be displayed in the search results of my WP Site: http://universitycompare.com/university-guide/ Oth... | Try the following approach. Get the page using <code> get_page_by_path() </code> http://codex.wordpress.org/Function_Reference/get_page_by_path <code> $page = get_page_by_path( 'university-guide' ); $search_query['post_type'] = 'page'; $search_query['post_parent'] = $page->ID; </code> The following snippet was taken... | Display just child pages of a certain page in search results | wordpress |
Is there anyway of telling wordpress, by some plugin or whatever, not to show Recent news from Category X, on my home page? Or I may do it only by modifying the <code> home.php </code> code? | Assuming this is the default main query, see the example for <code> pre_get_posts </code> , which shows how to exclude a category from the main query: <code> function wpa78465_exclude_category( $query ) { if ( $query->is_home() && $query->is_main_query() ) { $query->set( 'cat', '-1,-1347' ); // IDs of ... | Homepage custom recent news | wordpress |
I've noticed WordPress has some illogical differences between wp_link_pages and paginate_links. Specifically, WP_LINK_PAGES does not automatically add a class to the current page like paginate_links does. Anybody have a quick functions fix? | This is what I use as a replacement for <code> wp_link_pages() </code> . Instead of a separate class it uses another element for the current page, because a page should never link to the current URL. <code> /** * Modification of wp_link_pages() with an extra element to highlight the current page. * * @param array $args... | Add a Class to Current Page WP_LINK_PAGES | wordpress |
I have the following code in my functions.php file to display post shortlink in my posts (I prefer not to edit theme files if possible)... <code> function add_post_content($content) { if ( is_single() ) { $content .= '<p>Shortlink: ' .wp_get_shortlink(); '</p>'; } elseif ( 'portfolio' == get_post_type() ) {... | Reorder the logic, and fix the minor syntax error in your appended string: <code> function add_post_content($content) { if ( 'portfolio' == get_post_type() ) return $content; if ( is_single() ) return $content . '<p>Shortlink: ' . wp_get_shortlink() . '</p>'; return $content; } </code> | exclude custom post type from running a function | wordpress |
I'm using paginate_comments_links() to get all the comments by the current user: <code> <?php global $current_user; get_currentuserinfo(); $userid = $current_user->ID; $args = array( 'user_id' => $userid, 'number' => 2, ); $comments = get_comments($args); foreach($comments as $comment) : echo('<br />'... | <code> paginate_comment_links() </code> actually does some magic setup for comments and then calls the standard wordpress <code> paginate_links() </code> . I believe that part of that magic utilizes the result of <code> wp_list_comments() </code> . So even though your code is works great - you cannot use the built-in p... | paginate_comments_links() not working | wordpress |
The code i use calls for all attachments that are uploaded to be in the post. I added the Gallery custom post type but nothing shows. It shows on my "pretty-little-liars" post type though. What am I doing wrong. <code> <?php if ( 'pretty-little-liars','gallery' == get_post_type() ) { //condition to show gallery on p... | <code> <?php if ( 'pretty-little-liars' == get_post_type() || 'gallery' == get_post_type() ) { // ... } ?> </code> | How do I add multiple post types to this query? | wordpress |
Where you can add your menu in under appearance > menus, I have descriptions in. In my page, I want to be able to echo out that description. Not in the menu, but in my page. How can I access this information? EDIT: @toscho How do I edit my custom walker? Does the object $item have access to the page excerpt? <code> cla... | I don’t like the idea to parse the menu items again. As an alternative solution I suggest to store the description during the first run: <code> add_filter( 'walker_nav_menu_start_el', 'wpse_78483_get_current_items_description', 10, 2 ); /** * Get nav items description. * * @wp-hook walker_nav_menu_start_el * @param str... | How can I access the "description" of a menu item? | wordpress |
I would like to list tags with count in author profile page just like stackexchange-url ("this page") If the user click the tag, then I would like to list the tagged posts. Can someone help me? | Here you go: <code> function get_author_post_tags_wpa78489($author_id,$taxonomy = 'post_tag'){ //get author's posts $posts = get_posts(array( 'author' => $author_id, 'posts_per_page' => -1, 'fields' => 'ids' ) ); $ts = array(); //loop over the post and count the tags foreach ((array)$posts as $p_id) { $tags = ... | list tags with count in author profile page | wordpress |
I would like to know if there's a way to do a query filtered by a custom field result. In this case, I have 6 posts I would like to retrieve, but only if they have "true" selected in a custom field I've previously created. The name of the custom field is called "featured". Here's my code <code> <?php $recentPosts = ... | Here's the corrected code, thanks @Milo! <code> <ul> <?php $recentPosts = new WP_Query(); $recentPosts->query('showposts=6&cat=1&meta_key=ticker&meta_value=yes'); ?> <?php while ($recentPosts->have_posts()) : $recentPosts->the_post(); ?> <li> <?php if ( has_post_thumbnail... | WP_Query based on a custom field result | wordpress |
How can i count the post added in relationship field. The relationship field is a plugin (http://www.advancedcustomfields.com/docs/field-types/relationship/) In my admin i have a MetaBox i create to link the post from another post type to my posts. please see picture below in the link http://i.imgur.com/PFFY8.jpg Subti... | The relationship field will return an array of post objects, so just <code> count </code> them: <code> $related_posts = get_field( 'trailere_filme' ); echo count( $related_posts ); </code> | How can i count the post added in relationship field, theme display | wordpress |
I am Writing a plugin, with many shortcodes. Now I do not want to include all shortcodes source files to every page. So my questions are: Where should I include the source? Is it back-end or front-end How to add it on that specific page? thanks HoGo | The pattern I use is: break code into modules using classes use spl_autoload_register() to load classes (thereby only included when used) have a class that is the plugin controller, with a method for each shortcode those methods generally do nothing but create instance of shortcode class and pass params Works for me, s... | How and when to include shortcode source files | wordpress |
I want the content before the <code> <!--more--> </code> tag in one column and the rest in another column ( <code> single.php </code> ) only. I don't want to use plug-ins where I would need to edit all the posts to get it as I want. I've done the following and added it in <code> functions.php </code> : <code> // ... | I am guessing, at least partially, but it sounds like the FaceBook content is loaded as a filter on <code> the_content </code> , which you run on both blocks of content. The quick fix, keeping most of your code intact, would be to remove the FaceBook filter for the first array, then put it back for the second. <code> $... | Split the content of the_content(); | wordpress |
I have this code that should return all the posts that related to the taxonomy id, but it returns the last 5 posts. <code> <?php $leaderships = new WP_Query(array( 'post_type' => 'posttype', 'posts_per_page' => 11, 'tax_query' => array( array( 'taxonomy' => 'taxonomy-name', 'field' => 'id', 'terms' =&... | Thanks every one for help, I discovered that that the problem is from my theme admin that was limiting the posts to 5 and fixed now. | Get all taxonomy posts by id | wordpress |
I'm creating custom wordpress theme. How can I enable "Description" metabox for menu items (on nav-menu page) by default programmatically? | Remove the <code> description </code> from the user meta value <code> managenav-menuscolumnshidden </code> : <code> add_filter( 'manage_nav-menus_columns', 'enable_nav_menu_description_by_default' ); function enable_nav_menu_description_by_default( $columns ) { $desc_key = 'managenav-menuscolumnshidden'; $hidden = get_... | How to activate "Description" metabox for menu item programmatically? | wordpress |
I've seen a few plugins (subscribe2, subscribe to comments) that allow people that have commented to receive emails containing follow up comments. What I want to do is slightly different. I want to post to have a 'Subscribe' button. Clicking this would then allow the user to receive by email subsequent comments to that... | Subscribe To Comments Reloaded allows subscribing without commenting. It uses a link instead of a button, though. Screen shot: It shouldn't be too hard to customize. | Subscribe to a post's comments without posting a comment yourself | wordpress |
I need a way to get just the comments that aren't top level i.e. where parent is not 0. I've tried: <code> $args = array( 'parent' => -0 ); $comments = get_comments($args); </code> I know the parent comment id's (44 and 48) of all the comments I require, so I tried: <code> $args = array( 'parent' => array(44,48) ... | You cannot do that with a parameter for <code> get_comments() </code> , but filtering <code> 'comments_clauses' </code> should do it. Sample code, not tested: <code> add_filter( 'comments_clauses', 'wpse_78490_child_comments_only' ); function wpse_78490_child_comments_only( $clauses ) { $clauses['where'] .= ' AND comme... | get_comments() where parent is not 0 | wordpress |
I have an old Wordpress site that I no longer maintain but keep online anyway. I have a cron job setup on the server that backs up the Wordpress database once a month. I am noticing a continuing growth in the size of the database backup. For example, if I go back a few years, the database size was under 3MB. It has kep... | Some plugins aggregate data over time without ever cleaning up. I remember Broken Link Checker did that back in the days when I was using it … The first step: Find all tables, count their size (data, indexes and total size). Sample query, <code> DB_NAME </code> is the constant from your <code> wp-config.php </code> : <... | Wordpress database growing dramatically in size despite adding no new content | wordpress |
I have a site running WP 3.3.2. The backend shows a bar saying "WordPress 3.5 is available! Please notify the site administrator." Funny thing is that I'm logged in with an admin user, I double checked that. When trying to access the update page (at wp-admin/update-core.php) I get this error: "You do not have sufficien... | Try to make a new admin user in the db. Follow these steps you should be able to create a new admin user, then update and then you can give your old user admin rights again. Or use the new user. Your old user might have wrong setting in the DB http://www.dnawebagency.com/how-to-add-an-admin-user-to-the-wordpress-databa... | Admin user can't update WP | wordpress |
I have a function that I thought should find the first article with a featured image in it, and then return that image. Not sure if this is the best way to go about it, as it's giving me a 502 Bad Gateway... <code> function get_category_post($cat_id){ $finished = false; $postcount = 0; $post_args = array( 'numberposts'... | The ID of the featured image is stored under the meta key <code> _thumbnail_id </code> , so we can do a query for a single post that has this key: <code> $args = array( 'posts_per_page' => 1, 'meta_key' => '_thumbnail_id', 'cat' => $cat_id ); $latest_thumb = new WP_Query( $args ); if( $latest_thumb->have_po... | How can I find the first post in a category that has a featured image and then return the get_the_post_thumbnail()? | wordpress |
By default, wp_link_pages (the code which allows you to breakup posts into multiple pages) creates spaces between each number. Is there a way to remove these spaces via functions.php? | Just replace <code> a> <a </code> with <code> a><a </code> : <code> echo str_replace( 'a> <a', 'a><a', wp_link_pages( array ( 'echo' => FALSE ) ) ); </code> If you want to remove the spaces around unlinked numbers too, I suggest a separate function in your theme’s <code> functions.php </code>... | Remove Spaces From WP_LINK_PAGES | wordpress |
I have a main parent page with multiple sub-pages. The main parent page has some custom fields (meta boxes?) with specific values. My intent is to add dynamically these custom fields and their values to all sub-pages. I searched a solution but without success. Is this possible? And how? | The parent post ID is stored in <code> $post->post_parent </code> . So you can access the parent data by using that ID in <code> get_post_meta() </code> . To get the ancestors use <code> get_post_ancestors( $post->ID ) </code> . It returns an array of parent IDs, the last one is the highest. Let’s invent a helper... | How to add dynamically the main parent pages's custom fields and their values to all sub-pages? | wordpress |
I am trying to remove the action hooks added by SEO ultimate plugin for some pages. The way it is added in the plugin's class is <code> //Hook to output all <head> code i changed the priority to 2 add_action('wp_head', array(&$this, 'template_head'), 2); </code> The SEO plugin creates a global variable like t... | You have to use the same priority, and you need access to the global variable: <code> function remove_seo_header() { remove_action( 'wp_head', array( $GLOBALS['seo_ultimate'], 'template_head' ), 2 ); } </code> | Remove Actions added by SEO ultimate Plugin | wordpress |
I currently have a button like this, that takes a user to their 'mentions' page <code> <a href="http://my.url.org/mentions/<?php global $userdata; get_currentuserinfo(); echo( $userdata->user_login );?>">button</a> </code> What I'd like instead is that a user can see their 'mentions' when they log ... | You have to add action to, for example, <code> template_redirect </code> action hook. The action would perform your desired checks and redirect user using the <code> wp_redirect() </code> function. The code could look something like this: <code> function my_redirect_function() { // Check if home page is being displayed... | How can I do a url redirect to include a wordpress username? | wordpress |
I have a custom post type called books. The books publication date is from between 1700 and 1900. I want to set the post date to these dates(so i can query the results sorted by year) but i can't seem to have a date set before 1970 january 1. Is it possible to somehow do that? | Do not use the <code> post_date </code> field for anything it isn’t made for. Use a post meta field instead. The <code> post_date </code> is post_date_gmt </code> , you would get strange side effect even you could get an earlier date into that. So create post meta fields and query those per tax query. Ignore the defaul... | Set post date before 1970 | wordpress |
This is more of a conceptual question, but it has actual ramifications. Going through the various SEO plugins I found nowhere a PHP tag that should be embedded in the actual HTML page and echo the meta data. How does it work then? Simply saving it to the DB doesn't seem enough. What is the mechanism through which the p... | In case you are talking about adding meta tags and changing the title they rely on <code> wp_head </code> action being fired at theme header before the <code> </head> </code> tag is generated. For changing the title they probably use the <code> wp_title </code> filter. Older versions of "all in one seo" used to b... | The inner mechanism of WP SEO plugins | wordpress |
There are 3 menus in my wordpress(3.5) now. Main menu (default from wp) Footer menu (default from wp) Test menu Now I have kept test menu as default. Where does Wordpress store this thing? I want to know where wordpress stores about current menu that is displaying in the front end. | Menu by itself is a taxonomy in WP. It means that you can find all menus in <code> wp_terms </code> table, by running following query: <code> SELECT * FROM wp_terms AS t LEFT JOIN wp_term_taxonomy AS tt ON tt.term_id = t.term_id WHERE tt.taxonomy = 'nav_menu'; </code> Menu item is custom post type in WP. They are store... | Wordpress default menu in database | wordpress |
Hi i'm using this code to call for a different stylesheet for a single post type but the problem is, It won't call the stylesheet. It's in header.php, i also tried placing it in single.php <code> <?php if ( ! is_home() ) { if ( is_single() == 'pretty-little-liars' ) { echo '<link rel="stylesheet" href="http://www... | <code> is_single() </code> returns <code> TRUE </code> or <code> FALSE </code> , not a string. Additionally, you can test for a specific post with <code> is_single() </code> function by putting the post slug into the function call: <code> if ( is_single( 'your-post-slug' ) ) { # do something } </code> If you want to te... | is_singular won't call my functions? | wordpress |
Is it possible while adding post through wp_insert_post also upload images to this post from url. | You can attach images to a post from URI via the <code> media_sideload_image </code> function: <code> $post = array(); // your post data $post_id = wp_insert_post( $post ); $url = "http://s.wordpress.org/style/images/wp3-logo.png"; $desc = "The WordPress Logo"; $image = media_sideload_image( $url, $post_id, $desc ); </... | Add file while inserting post | wordpress |
I would like to use underscore in my permalinks instead of hyphen. Current permalink: <code> www.example.com/2013/01/hello-this-is-a-test-post/ </code> Desired permalink <code> www.example.com/2013/01/hello_this_is_a_test_post/ </code> I have tried stackexchange-url ("some solutions") mentioned here in stacexchange. Bu... | stackexchange-url ("Toscho") advised me like this. Google treats - as word separator, but not _. You will hurt yourself. :) He was 100% true. Here is an article that explains it. So I dropped the idea. But if you still looking for a solution here is the answer. Answered by stackexchange-url ("this stackoverflow user") ... | Convert hyphen to underscore in permalinks | wordpress |
i have previously asked it in stackoverflow, but there was no answer! I wish to change the title of Tags pages of my wordpress blog. What I want to do is to keep the Tag name as it's title only. For example: If a tag name is "Wordpress Tag Pages Tutorial" then that tag should have the same title "Wordpress Tag Pages Tu... | Use … <code> if ( is_tax( 'post_tag' ) ) echo single_term_title(); </code> I would just call a naked <code> wp_title() </code> and change that title per filter. See stackexchange-url ("example 1"), stackexchange-url ("2") and stackexchange-url ("3"). | How to change tag Title to its name? | wordpress |
I'm creating a madlib style checkout form using WooTheme's Customizing checkout fields using actions and filters . Billing fields in the checkout template <code> form-billing.php </code> are displayed with this call: <code> <?php foreach ($checkout->checkout_fields['billing'] as $key => $field) : ?> <?ph... | Thanks to Dbranes for the answer. Replace: <code> <?php foreach ($checkout->checkout_fields['billing'] as $key => $field) : ?> <?php woocommerce_form_field( $key, $field, $checkout->get_value( $key ) ); ?> <?php endforeach; ?> </code> With: <code> <?php // order the keys for your custom or... | How to reorder billing fields in WooCommerce Checkout template? | wordpress |
What I am looking to do is check if a page is private, give the users the option to register and see the page. Here is what I have now: <code> <?php if (have_posts()) : /* Print the most as normal */ else : if ($post->post_status = 'private') { /* Print login/register box */ } else { /* Print page not found messa... | When a POST is set to private, non-logged in users will receive a 404 message. If you dump the global variable <code> $wp_query </code> , <code> var_dump($wp_query); </code> ..you will notice that no <code> post_status </code> is present in the parameters returned therefore using the slug (or <code> name </code> parame... | How do I check if a post is private? | wordpress |
This: http://codex.wordpress.org/Changelog/3.5 is not a changelog. This: http://codex.wordpress.org/Version_3.5 gives a few changes, etc, but no list of files added and removed. Where might I find a list of 'breaking changes'? Actions and Filters that work differently? | You can always use GitHub. WordPress has an official (view-only) GitHub repository , and GitHub has an excellent comparison feature. Here's the GitHub comparison of WordPress 3.4.2 vs 3.5 . | Where is the changelog for 3.5? where is the list of added removed files? | wordpress |
Hi I have this function to install the plugin and create database table: <code> function sortresult_install() { //install sort_search_result options to the database global $wpdb; $sortsearchtitle_db_version = '1.0'; $table = $wpdb->prefix."sortsearchresult"; $structure = "CREATE TABLE IF NOT EXISTS $table (id INT(9)... | First of all I want to reference you to the WP codex article about Creating or Updating the Table with Plugin . Note that the dbDelta function is rather picky, however. For instance: You must put each field on its own line in your SQL statement. You must have two spaces between the words PRIMARY KEY and the definition ... | My plugin won't create table in wordpress 3.5 | wordpress |
probably a rather straight forward question. my "homepage" is not the blog-page. I have a <code> page-template </code> named <code> page-knowledge.php </code> which has the following loop on it. <code> <?php echo '<ul class="blog-items">'; $args = array( 'post_type' => 'post', 'posts_per_page' => 5, ); $... | <code> get_pagination_links </code> is looking at <code> $wp_query </code> , whereas you want pagination for your query object named <code> $loop </code> . So instead, use <code> paginate_links </code> Something similar to this code, which is based on <code> get_pagination_links </code> , alebit with wp-query swapped o... | Pagination for normal (standard) posts on a page with a custom loop? | wordpress |
Whilst (patiently) waiting for proper documentation and/or a few tutorials on the new media uploader I'm still using the <code> media_upload_tabs </code> filter to add a tab to the uploader. Here's my (working) code: <code> <?php add_filter( 'media_upload_tabs', 'olab_add_media_tab' ); function olab_add_media_tab( $... | You need to en-queue your styles and scripts in your media upload hook and then clal <code> wp_iframe </code> function. Just do it like this and it will work: <code> <?php add_filter( 'media_upload_tabs', 'olab_add_media_tab' ); function olab_add_media_tab( $tabs ) { $tabs['bildarkiv'] = __( 'Bildarkiv', 'bildarkiv'... | 3.5 media manager add CSS / JS to new 'tab' iframe content | wordpress |
I use the twenty twelve theme and I would like to change the background color manually by modifying the right files in the <code> plugins </code> folder. However, I can not find what to change in the style.css file. I even tried to modify the background color through the Wordpress interface to #e50000. After that, I lo... | The background is a option. You can set colors and also images. See in the Administration area, Appearance --> Background Also you can use the Live Preview link on the theme and customize the background and other otpions. | Change Twenty twelve theme background color | wordpress |
I have a shortcode that display an image when you use the image url inside it. <code> function image_code($atts, $content = null) { return '<img src="'.$content.'" class="user-imgs"/>'; } add_shortcode('img', 'image_code'); </code> So when I use the code like this: <code> [img]https://www.google.com.br/images/srp... | You can reuse the <code> $content </code> parameter: <code> function image_code($atts, $content = null) { $url = esc_url( $content ); return "<a href='$url'><img src='$url' class='user-imgs' /></a>"; } </code> Or pass the URL as parameter in case you want to use a different URL: <code> function image_... | Wordpress display image link in shortcode | wordpress |
How to change wordpress login url without using .htaccess, should be a manual process, so <code> example.com/login </code> will not redirect to <code> example.com/wp-login.php </code> so <code> example.com/login </code> will be the login page? | I wrote a post about it a few weeks ago <code> WordPress Easy Login URL whiteout htaccess </code> , but if you dont want to read then here is the code in a plugin form: <code> <?php /* Plugin Name: Nice Login URL Plugin URI: http://en.bainternet.info Description: Simple plugin to redirect login/register to a nice ur... | Changing wp login url without .htaccess | wordpress |
In WordPress' core code, you often see this: <code> if (1 == $someVar) </code> as opposed to this: <code> if ($someVar == 1) </code> I don't know if the first way is a WordPress-centric style of coding, but I've only noticed it in WP code (either core or 3rd-party code). | This coding style is known as a Yoda Condition, and it's nothing specific to WordPress. I've used the same style in C++, C#, and even JavaScript code. The main benefit of a Yoda Condition is that it prevents accidental value assignment from a typo. Consider the following (often-seen-in-the-wild) typo: <code> if ( $some... | Why does WordPress reverse conditional statements? | wordpress |
I'm trying to implement the JAIL javascript into my WordPress install. The javascript requires me to add a data-attribute and change the output html of images. I have been looking through the codex for filters or hooks that can help me, but i can't find anything. Anyone have a solution? | Your better off adding your custom image data when you insert it into a post using <code> media_send_to_editor </code> , the caveat is this will not be applied to any existing images, only ones inserted after adding the function. To apply it to to existing content you will have use <code> preg_match </code> on <code> t... | Alter image output in content | wordpress |
I created a plugin to add some shortcodes in my WordPress site. But I'm a PHP newbie, so I believe it may have some errors or ways to optimize it. It's working fine, and apparently there are no problems. Memory usage is at 00.04MByte. Could you please take a look? Thank you very much! <code> add_action( 'wp_enqueue_scr... | There is a very important programming principle: DRY – Don’t repeat yourself . Whenever you realize you are repeating almost the same job try to write an abstraction. For your <code> pad* </code> shortcodes this means: <code> function get_padding( $atts ) { $args = shortcode_atts( array( 'num' => 10 ), $atts ); retu... | Optimize shortcode callbacks | wordpress |
I've got this in my theme <code> <article <?php post_class('archiveMain'); ?>> </code> But for tags and categories it adds tag- or category- before the slug, any way to remove that? Example: tag-sales would just be sales, category-webinar, just webinar | You can filter <code> post_class </code> and change these class names: <code> add_filter( 'post_class', 'wpse_78237_post_class' ); function wpse_78237_post_class( $classes ) { $out = array (); foreach ( $classes as $class ) { if ( 0 === strpos( $class, 'tag-' ) ) { $out[] = substr( $class, 4 ); } elseif ( 0 === strpos(... | post_class remove tag- or category- from slug | wordpress |
How to create the custom login/Registration form using AJAX. | Here is a simple shortcode that gets the job done: <code> add_shortcode('ajax_login','ajaxlogin_shortcode_handler'); function ajaxlogin_shortcode_handler($atts,$content=null){ if (is_user_logged_in()) return; $retval = '<p id="message" style="color:red"></p>' .wp_login_form(array('form_id' => 'ajaxloginf... | Custom Login and Registration form in Ajax | wordpress |
I'm working with some quiz script which is using javascript to init the script, the data structure which I working on is look like this <code> var quizArray = { 'contents': [{ 'question': 'First Question', 'answers': ['First Option', 'Second Option', 'Third Option', 'Fourth Option'], 'correctAnswer': 1 }, { 'question':... | If it where me id store each question as a 'question' type meta as a stored array. Wordpress automatically serializes your array before storing it. So then when you use get_post_meta($post_id, 'question') it will return an array of serialized strings.(I think, Im pretty sure it wont unserialize it for you if there are ... | Need Advice to Working with Custom Post Meta | wordpress |
With the WooCommerce plugin, I'm trying to get a different template/look to apply to the individual product page depending on what category the product is in. In other words, I want a product within the "A" category to have one look, and another product within the "Z" category to have another separate look. I realize t... | Instead of getting all terms, looping over them and then searching your array, you can use the <code> has_term </code> conditinal tag ex: <code> if( has_term( 'z', 'product_cat',$post->ID ) ) { ?> <div id="post-timer"> <p class="timebuy">Time Left To Buy:</p> <div id="timer-wrap"> <?php... | Trying to place shortcode/css/html into an IF conditional statement | wordpress |
Not sure if this makes sense but I'm trying to attach hotlinked images to their posts/pages with no lucky, most plugins such Cache images works ok but only to external domains, I need to auto-attach hotlinked images in the same domain/server. Addendum : This happened duo copying-pasting content from static html files i... | Thanks @toscho, I think I figured how your code can work (that can take time hahah), firstly import images files within server ( Add form server plugin can do this or can use a custom script), find image paths within every post/page that match filenames now in media library, then attach them. I can't use this because t... | How can I attach hotlinked images in posts/pages within the same server? | wordpress |
WordPress has a file called <code> pluggable.php </code> which contains a list of functions you can override in your plugin. The problem I am facing (I am overriding <code> wp_authenticate </code> ) is for each blog in my network I try to activate this plugin, I get: failure, can't re-declare wp_authenticate which was ... | Wrap your function in <code> if( ! function_exists( 'wp_authenticate' ) ) </code> to get rid of the error and successfully activate your plugin: <code> if( ! function_exists( 'wp_authenticate' ) ){ function wp_authenticate(){} } </code> This is necessary because in the context of activating a plugin, the function does ... | Override pluggable functions in a plugin? | wordpress |
Is it possible to remove the quick edit function for a custom post type? I have 14 custom taxonomy with hundreds of terms in each and it takes too much time and resource to load all of them into the source-code of the page. I tried to find a solution using google but most of them just hides the quick edit button, but t... | Check out the builk actions page in the codex. I believe the proper action to unset is inline. This will remove the "Edit" bulk action, which is actually quick edit. <code> <?php function remove_bulk_actions( $actions ){ unset( $actions['inline'] ); return $actions; } add_filter('bulk_actions-custom_post_type_slug',... | Remove quick edit for custom post type | wordpress |
With help of other relevant posts here, I have put together a code which allows the users to send me a list of selected posts via e-mail and it is working fine. Now, I would like a confirmation text eg. 'THANK YOU' appear to the user, once user has clicked the "send email" button. This could appear below the submit but... | Simply add a Success callback to your Ajax function: <code> $('#sendEmail').click(function(){ $.ajax({ type: 'POST', url: 'www.example.com/email.php', data: { content: $('#email-data').html()}, success: function(data) { //data variable can be used if your ajax call returns something do_stuff_here(); } }); }); </code> I... | need a confirmation text to appear on email submission | wordpress |
I have a custom login form working properly on my home view. Nice. But what I want is when user try to view some page, be redirected to my home view instead of wp-login. Im trying to do this way: <code> add_action('template_redirect', 'redirect_to_login'); function redirect_to_login(){ if(!is_user_logged_in()){ wp_redi... | <code> template_redirect </code> is called on every page load including the home page so your code will redirect the user to the homepage even when user is visiting the homepage You could add another condition there, <code> is_home() </code> or <code> is_front_page() </code> , depending on the setting in admin, but i r... | Force user to login in home page | wordpress |
If I go in <code> Dashboard -> Settings -> Media </code> I don't see field where I can change upload folder. Is it possible now? For example my website is <code> myblog.tld </code> , by default all media content uploads into <code> wp-content/uploads/year/month </code> . I want uploads all media to <code> sub.myb... | In WordPress we can change the default location of the wp-content folder by defining a couple constants in wp-config.php about it here on Codex So if the structure on the server looks like this: <code> /root/ 1. myblog.tld - its own directory 2. sub.myblog.tld - its own directory </code> You can use this in your wp-con... | How i can upload images to another folder? | wordpress |
Iv got this code in my blog.php: <code> <?php wp_get_archives( array( 'type' => 'monthly', 'limit' => 12 ) ); ?> </code> It links to: /2013/01 My page only loads the header and footer - I think its the main loop - what do I have to do, do I need another file? Or say where to output the code? Thanks.. | The <code> date.php </code> , <code> archive.php </code> , and <code> index.php </code> files control the date archive output. You need to check the contents of those files, in respective order, to find the problem. If WordPress can't find <code> date.php </code> , it will check for <code> archive.php </code> , and loa... | wp_get_archives() output | wordpress |
Forgive me for knowing next to nothing about coding. BUT, I am calling jQuery in functions.php, which I have been told is the best way to include jQuery: <code> //Get jQuery function modify_jquery() { if (!is_admin()) { // comment out the next two lines to load the local copy of jQuery wp_deregister_script('jquery'); w... | First, don't unregister and reregister jQuery. There's no reason to do that at all. Second, you're enqueuing on the wrong hook. Instead, use this in your functions file: <code> // Enqueue Scripts function wpse78227_enqueue_scripts() { wp_enqueue_script( 'jquery' ); } add_action( 'wp_enqueue_scripts', 'wpse78227_enqueue... | Add a jQuery Function | wordpress |
I'm trying to customize twentyten theme. this is part of header.php: <code> <body <?php body_class(); ?>> <div id="wrapper" class="hfeed"> <div id="header"> <img id="topL" src="images/img01.png"/> //this img I cannot insert ! </div><!-- #header --> </code> No errors. Simply - n... | Don't use a relative URL. If you look at the source you are probably trying to load the image from <code> http://sitename.com/images/ </code> when what you likely want is <code> http://sitename.com/wp-content/themes/themename/images/ </code> . Assuming the image is in the theme directory in a folder that shares a direc... | How to place an image into header.php? | wordpress |
I've created my own theme based on a very lean template. My theme is not parsing the <code> [caption]...[/caption] </code> markup to the correct html. It's just showing the text without any markup around it. Here are the relevant observations for my situation: When editing the post it shows <code> [caption]...[/caption... | That <code> caption </code> shortcode is built into WordPress . It should generate the same markup for any theme, unless the theme or a plugin has unregistered it and registered a replacement. I don't know if that is the case with your theme or with TwentyEleven. Look for 'img_caption_shortcode' in your theme files, pr... | How do themes render caption texts in extended markup (e.g. "wp-caption" paragraphs) | wordpress |
I bascially need to just be able to show the polish translated menu or the english menu. The best way I can think of it is: <code> if($languageCookie=='polish'){ wp_nav_menu(use the navigation label rather than the page title) }else{ wp_nav_menu(use the page title rather than the navigation label) } </code> That is bec... | I found the answer was to create my own walker with a little help from this article. This is it. The most important part being when it checks for the <code> $language </code> value (which is got from a cookie), and assigns the value of either <code> $item->title </code> or <code> $item->description </code> . <cod... | How to call either page name as the nav link or navigation title? | wordpress |
I have a custom-post-type named <code> my_project </code> . This post-type has two meta-boxes: <code> is_featured </code> <code> is_featured_position </code> So essentially in my backend of the post-type I can set a checkbox for <code> is_featured </code> and enter a number for <code> is_featured_position </code> This ... | You'll need to use <code> meta_query </code> along with <code> meta_(key|value|compare) </code> to interact with two different keys and get the order you want. <code> <?php $q = new WP_Query(array( 'post_type' => 'my_project', 'nopaging' => true, // same as posts_per_page => 1, 'order' => $order, 'orderb... | loop through custom post-type with two meta_keys | wordpress |
When closing the Thickbox (by clicking on the cross), I am invoking the following function, by hooking it to the <code> tb_unload </code> action. However, the action is being called twice for some reason, and I don't know why. Is there a way to stop the functino running more than once? Or better yet, finding out what i... | A very basic fix would be to use <code> one() </code> instead of <code> bind() </code> . But why the function is called twice is still open. Ask your browser’s JavaScript inspector. | Thickbox 'tb_unload' function being called twice | wordpress |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.