question stringlengths 0 34.8k | answer stringlengths 0 28.3k | title stringlengths 7 150 | forum_tag stringclasses 12
values |
|---|---|---|---|
I am trying to edit the activity on Buddypress (1.7 and running latest Wordpress) for when a new blog post is created. By default it displays the excerpt and shows any attached images, it also strips any code (I think). What I'm trying to achieve is to show the full blog post, including things like galleries. Doing som... | First, a note on how the filter functions work. If a developer has something that they want to filter/let others filter, then they apply any filters they/others have to it by calling <code> apply_filters() </code> . If you have a certain function that you want to filter something with, you add your function to that fil... | Buddypress: Edit activity when new blog post | wordpress |
I want make all my blog thumbs the size of 227x133. I need images width have 100% (for responsive design). Some images have width greater than the other and vice versa. I'm using this code to show the thumbs of my blog: <code> / / Post thumbnails sizes add_theme_support ('post-thumbnails'); add_image_size ('blog-page',... | Intermediate image sizes are discrete, not variable. When you define an image size, with specific dimensions (whether hard-cropped or box-resized), WordPress will create a discrete image, with the specified dimensions. Otherwise, if width could be defined dynamically, WordPress would have to create a prohibitively larg... | Thumbnail with different sizes | wordpress |
I've settled on a theme for one of my blogs. Is it possible to just wrap your stylesheet (style.css on most themes) in @media queries, and make your entire theme responsive , or fluid , so it works well on all browsers and screen resolutions ? If so, does anybody know how I can accomplish this? Or is there a better, ea... | You can use media queries to change the styling per element depending upon specifications. You would have to add these to the bottom of your stylesheet, so that it overwrites your default styles depending upon the screensize This following media-queries template from bootstrap is only based on screen size. You can use ... | How would I use a media query to make my entire theme responsive or fluid? | wordpress |
I have a hierarchical custom taxonomy that I add terms to programatically using the following code in a loop: <code> -- SNIP -- $args = array( 'description'=> '', 'slug' => str_replace(' ','-',preg_replace('/[^\00-\255]+/u', '', $term)), 'parent' => $parent ); $term_id = wp_insert_term( $term, 'widgets', $args... | I encountered a very similar situation, and I believe it may very well be the same situation you are experiencing. Please read the WPSE question stackexchange-url ("Programmatically insert hierarchical terms & set terms for post causes glitch?") and follow up with the stackexchange-url ("answer") provided by @Manny... | Custom taxonomy only showing top level terms in admin? | wordpress |
I was creating a child theme today and needed to overwrite a php file which was included using this code in the themes functions.php file <code> require_once( get_template_directory() . '/function-includes/theme-functions.php' ); </code> I tried using <code> require_once( get_stylesheet_directory(). '/function-includes... | Generally speaking, Child Themes were originally intended to be able to do two things: Override parent Theme CSS Override parent Theme template files I doubt that the Theme developer intends for the <code> /function-includes/theme-functions.php </code> file to be overridden by a Child Theme. Functional files are usuall... | Should I ask a theme developer to use locate_template rather than require_once | wordpress |
I am trying to upgrade my version of Wordpress but I get this error: Destination directory for file streaming does not exist or is not writable. | This is a read-write permission error. Fix this by changing the "wp-content" folder's permissions to 755 . If this doesn't work checked the wp-config.php file and if it's not already defined, add <code> define('WP_TEMP_DIR', ABSPATH . 'wp-content/'); </code> | Destination directory for file streaming does not exist or is not writable | wordpress |
I'm using filter like this to add <code> rel </code> attribute in <code> wp_get_attachment_link() </code> <code> add_filter( 'wp_get_attachment_link', 'sant_prettyadd'); function sant_prettyadd ($content) { $content = preg_replace("/<a/","<a rel=\"prettyPhoto[slides]\"",$content,1); return $content; } </code> The... | <code> add_filter( 'wp_get_attachment_link', 'sant_prettyadd', 10, 6); function sant_prettyadd ($content, $id, $size, $permalink, $icon, $text) { if ($permalink) { return $content; } $content = preg_replace("/<a/","<a rel=\"prettyPhoto[slides]\"",$content,1); return $content; } </code> Update: function sant_prett... | wp_get_attachment_link() add rel attribute if the link points to direct image | wordpress |
I have a problem with menu organization. I have a Pages with url "pressroom" and have a Category with the same name. I want to make it a one menu item. Pressroom <code> (sitename.com/pressroom/) </code> page 1 <code> (sitename.com/pressroom/page1/) </code> page 2 <code> (sitename.com/pressroom/page2/) </code> category ... | Check nav menu target URL for '/pressroom/', then check if it's a post. If it fits, add custom class to that menu item. <code> <?php function my_add_posts_page_ancestor_class( $classes, $item ) { if( false !== strpos($item->url, '/pressroom/') && is_single($item->ID) && !is_page($item->ID) )... | Organizing the Navigation Menu | wordpress |
I edited the plugin WP User Frontend (for editing posts from frontend) to have two different edit pages for two different post types. Here's the original function which handles the edit_link. <code> function wpuf_edit_post_link( $url, $post_id ) { if ( is_admin() ) { return $url; } $override = wpuf_get_option( 'overrid... | Instead of using <code> $post = get_post($post_id); </code> , you can call <code> global $post; </code> which will load the value of the current post assuming that you have not triggered any other loops. | Call current post parameters inside a plugin | wordpress |
I added bbpress forum pluggin in my site to handle discussions, forum or comments. The bbPress CSS file is added to every page of my blog. Now, I want to load it only on forum directory to consider page speed. Is there any way to do this? | The styles are enqueued in the function <code> enqueue_styles() </code> inside the file <code> /wp-content/plugins/bbpress/templates/default/bbpress-functions.php </code> . It's a matter of using is_bbpress() </code> and <code> wp_dequeue_style </code> . Only one of the styles is enqueued, but here we're removing all 3... | Loading bbPress CSS file only on forum directory | wordpress |
I'm a total wordpress noob and ran into my first problem. I downloaded this theme. My question is how do I change how the <code> p#logo.h1 </code> is shown. I would like to put a <code> <br /> </code> in the middle of my title, and half in a custom . So the html of the title should be something like: <code> <p... | In your header.php file, replace this line: <code> <p id="logo" class="h1"><a href="<?php echo home_url(); ?>" rel="nofollow"><?php bloginfo('name'); ?></a></p> </code> with your custom line: <code> <p id="logo><h1>This is a<br /><span id="customtitle">Big tit... | Custom title, Bones theme | wordpress |
I'm trying to filter my content and on matches on flow I would like to change my html structure, but my rule doesn't really apply. I have the following filter which searches the first image of posts and on rule match attaching a css container. The <code> preg_match_all </code> is working but the <code> str_replace </co... | Change, <code> str_replace($to_search , $replacement, $post->post_content); </code> to.. <code> $content = str_replace($to_search , $replacement, $post->post_content); </code> | Content filter won't work | wordpress |
Working on a tool outside of Wordpress to query the wordpress database by POST_ID and return the Category Name associated. This is for a real estate website, and the Categories are called "mi_neighborhoods" and are referred to by wp_term_taxonomy.taxonomy. In one of my other queries to get all the Category names I use:... | You can try this SQL query for the taxonomy ' <code> mi_neighborhoods </code> ' and let's take <code> POST_ID = 1304 </code> <code> SELECT t.*, tt.* FROM wp_terms AS t INNER JOIN wp_term_taxonomy AS tt ON (tt.term_id = t.term_id) INNER JOIN wp_term_relationships AS tr ON (tr.term_taxonomy_id = tt.term_taxonomy_id) WHER... | SQL QUERY needed to get POST category (taxonomy) ? - MUST be SQL statement | wordpress |
I'm using a theme that gets updated pretty frequently. For this, it has added a custom.php file to include modifications. Now, in this theme, under the functions.php, the developer has included his own meta section which is added using the following function: <code> add_action('wp_head', 'theme_metas'); </code> I want ... | Your <code> remove_action </code> has to have a priority matching the priority used in <code> add_action </code> . Important: To remove a hook, the $function_to_remove and $priority arguments must match when the hook was added. This goes for both filters and actions. No warning will be given on removal failure. http://... | remove_action in a theme | wordpress |
I activated the All in one Favicon and then uploaded my Favicon in the settings but it does not show up in any browser (my under construction site: http://www.kheemh.com/ ). Any help will be highly appreciated. | You have to delete de cache of your browser | Favicon does not showup | wordpress |
I have a localhost site that I heard I can migrate the site by just copy and paste the whole site from local to host if I changed WordPress Address (URL) and Site Address (URL) to my current hosted site address and then upload it to the host. Now my hosting server's site after pasted with my local host site seem sql db... | Read http://codex.wordpress.org/Moving_WordPress#When_Your_Domain_Name_or_URLs_Change You've only moved the PHP files. That is only part of the process. Migrating the databse would mean: Create a database, if there isn't one already Move the database from your local server to the remote one. Edit/alter key values in th... | Error establishing a database connection After Copy localhost wordpress site (with site url directly to hosting server's url before copy) | wordpress |
I'm fairly new to PHP/wordpress, and this is actually the first time I haven't been able to answer a question through google! I'm working on getting up to speed with PHP/WP generally, but I can't seem to learn fast enough to keep up with what we need to accomplish already. Please have patience with my ignorance. I'd ap... | Looking at your code, it appears all meta keys are prefixed with <code> _cmb_ </code> . Your start time key is <code> text_datetime_timestamp </code> , so combined with the prefix, you want to fetch: <code> get_post_meta( get_the_ID(), '_cmb_text_datetime_timestamp', true ); </code> Note the third parameter, which will... | How can I display my custom metaboxes on a custom post template? | wordpress |
I have a custom post type <code> myposttype </code> and it's taxonomy is called <code> myposttype_categories </code> . <code> myposttype_categories </code> have multiple terms inside, such as <code> foo </code> and <code> bar </code> . The tricky question is - how do I list all myposttype posts that belong to <code> fo... | What about doing a <code> tax_query </code> ? <code> $args = array( 'post_type' => 'myposttype', 'tax_query'=> array( 'taxonomy' => 'myposttype_categories', 'terms' => array('foo'), 'field' => 'slug', ) ); $loop = new WP_Query( $args ); var_dump($loop); </code> Facepalm question, you are sure that these ... | List all custom post type posts from a given category? | wordpress |
This is a cross post from the WordPress forums, which I apologize for, but it has been almost a week and not getting any response there so hoping someone here can help. If I do get a reply in either place I will update the post with a link to it. I am attempting to extend functionality to my client's custom theme, and ... | This is not a tought quest, but you'd have to read carefully the Codex. Especially tax_query part of WP_Query . Your proposed query_posts call is wrong. This should look like this: <code> query_posts( array( 'post_type' => 'myportfoliotype', 'paged' => $paged, 'posts_per_page' => 80, 'tax_query' => array( a... | Filtering custom taxonomies | wordpress |
I'm wondering why my link: <code> http://localhost/?page_id=3433 </code> returns TRUE on <code> is_home() </code> usage: <code> if(is_home()){ var_dump(is_home()); die('test'); } </code> It clearly has template-mycustomtemplate.php set under Pages > This Page in Admin Panel. Can anyone shed some light on that? UPDATE: ... | I discovered that it isn't actually a bug. In the loop <code> is_home() </code> will refer to the currently looped object and not to the page that you accessed. In fact that's handy! | is_home() returns TRUE on page template | wordpress |
I have a loclhost site that I heard I can migrate the site by just copy and paste the whole site from local to host if I changed WordPress Address (URL) and Site Address (URL) to my current hosted site address and then upload it to the host (which I am doing now) Problem is that now when I try to login my local site it... | It sounds like you change the configuration on the local server. You need to put it back. that local configuration information needs to remain unchanged if you intend to continue working on the local copy, which you should. Breaking a local development version of the site is a lot less painful than breaking the live ve... | Website Address Keep redirect to website after migration attempt | wordpress |
I'm trying to create a custom button and link it to a file within the plugin. How do I get this link pointing to the path of my choice? I've tried the following but it does now work. <code> function _pfund_register_types() { $pfund_options = get_option( 'pfund_options' ); $template_def = array( 'public' => true, 'qu... | I'm not sure where you got the idea that adding 'download_donors' would do what you want, it's nowhere in the documentation, and it IS being bundled with the labels, it's just that nothing makes use of it. The labels when registering a post type are not definitions for admin menus. If you want to add an admin menu, you... | How do I set the link in the Custom Post Type admin menu? | wordpress |
My theme currently has the following line in the function.php file: <code> if ( $_GET['activated'] == 'true' || $_GET['preview'] == 1 ) </code> If this statement is true the code runs a function. I am getting a php error that says Notice: Undefined index: activated in and Notice: Undefined index: preview in. I am sure ... | Try <code> if ( isset($_GET['activated']) && $_GET['activated'] == 'true' || isset($_GET['preview']) && $_GET['preview'] == 1 ) </code> instead of <code> if ( $_GET['activated'] == 'true' || $_GET['preview'] == 1 ) </code> Edit: You should wrap the if-sentence in the functions.php file into a function a... | Theme Functions run a function upon activation or preview | wordpress |
I would like to echo out the term name from a custom taxonomy <code> 'recipes' </code> but all I get is the word "recipe" when it should say eg "pizza recipe". Is <code> name </code> the right argument here or I am mistaking it for <code> slug </code> ? <code> <?php $term = get_terms( 'recipes' ); echo '<div clas... | I managed to solve this and I will post the answer: <code> <?php $args = array('number' => '1',); $terms = get_terms('recipes', $args ); foreach( $terms as $term ){ echo '<div class="title">' . $term->name . 'recipe</div>'; } </code> | Echo custom taxonomy term name | wordpress |
I have hundreds of images in my media library, most have which have no titles. In the media library, the "(no title)" message is displayed along these images. Since I generally have one image per post, I would like to auto-populate the library titles, by grabbing the associated post name. I don't mind if I overwrite so... | If you can do SQL manually then try: UPDATE wp_posts p INNER JOIN wp_posts q ON p.post_type = 'attachment' AND p.post_mime_type LIKE 'image/%' AND (p.post_title IS NULL OR LENGTH(p.post_title) = 0) AND p.post_parent = q.ID SET p.post_title = q.post_title; If you need a PHP function then try: function set_image_without_... | How can I autopopulate titles in the media library? | wordpress |
I have a custom post type <code> recipes </code> which uses the <code> archive-recipes.php </code> template automatically. I have a Wordpress page called <code> Top Recipes </code> which is set to use the <code> archive-recipes.php </code> template in the CMS. When browsing to <code> www.mysite.com/top-recipes/ </code>... | Your recipe archive itself doesn't have a post or page to attach meta such as featured images to. Since you posted no code and my psychic powers are not working today, I'm going to assume that one of these is your situation: Top recipes and the recipes archive are identical with no difference Top recipes uses pre_get_p... | Assign CPT archive page attributes | wordpress |
Some of my pages/posts have very short custom stylesheets at the beginning of them. I know this isn't great practice, but it's worked very well thus far. The problem, however, is linking on Facebook: Facebook auto-generates a preview of the page, and it includes a picture, the page title, and a snippet from the beginni... | You can use Open Graph Protocol to define the data Facebook fetches from your site: http://developers.facebook.com/docs/opengraphprotocol/ The metatag for the description has this form: <code> <meta property="og:description" content="my custom description for single post" /> </code> You can use plugins, like http... | Hiding styles from Facebook | wordpress |
I am using ajax in a theme not written by me. This ajax gets the link clicked and then slides that page into view. it works good. In order for it to do it's thing, I had to make a custom walker for wp_nav_menu that adds two characters to the link so my links look like this in the nav <code> http://my-site.com/#!/post-1... | I solved this issue by adding this code to my walker <code> if( !is_home()){ $item->url = get_bloginfo('url')."/#!/page_".$temp_url; } </code> | custom walker nav issue involving ajax | wordpress |
A client has a successful UK site based powered by Wordpress and is launching a US arm. While the US sub-sites are built, he has a holding page that is visible to US visitors, who are redirected to it from the usual home page by the Geo Redirect plugin. I've just realised that Geo Redirect is also redirecting Google's ... | Search Help Google to determine the site language and to serve the right page for the users in different countries. Mark up language attributes correctly. Use <code> <html lang="en_UK"> </code> and <code> <html lang="en_US"> </code> . Use <code> <link rel="alternate" hreflang="x" /> </code> in page <c... | Redirection based on location but without affecting search bots | wordpress |
I'm using Bill Erickson's "Add Extra Code to Any Menu" function: <code> <?php /** * Add Extra Code to Any Menu * @author Bill Erickson * @link http://www.billerickson.net/customizing-wordpress-menus/ * * @param string $menu * @param object $args * @return string modified menu */ function be_menu_extras($menu, $args)... | I think the reason is <code> echo </code> vs <code> return </code> : The function <code> posts_logout_link </code> from http://plugins.svn.wordpress.org/logout-password-protected-posts/trunk/logout.php is using echo. Your code is therefore both returning and echoing values. ps: You could consider using output buffering... | do_action appearing outside of menu? | wordpress |
I'm helping someone with a custom plugin and they need it to be WPML compatible. Using the method from WPML I was able to register a string in WPML and output it on the other end. However, when the plugin was initially activated I got a Call to undefined function icl_register_string() error. It worked, but threw a fata... | You should always use the wpml functions as following: (the HowTo linked by you actually suggests this :-) <code> if( function_exists('icl_register_string') ) { icl_register_string( 'Match Previous Order' , 'match_order', 'Do you want these items to match a previous order from Direct Linen? If yes, use "Additional Note... | WPML icl_register_string() throws fatal error but works | wordpress |
What is the proper way to display User Meta in the BP Loop using this line from codex? <code> <?php get_user_meta($user_id, $key, $single); ?> </code> I added that line to the profile loop and switched those values with ones from my DB and nothing happened. What am I doing wrong? <code> <?php $user_id = 9; $ke... | Inside the loop, you can get the currently iterated user id using <code> bp_get_member_user_id() </code> . Also, it's best practice to use <code> bp_get_user_meta() </code> , because it works better with certain kinds of BP plugins (multi-network, etc). Thus: <code> if ( bp_has_members() ) { while ( bp_members() ) { bp... | How to: get_user_meta - BuddyPress | wordpress |
I have developed a CRM plugin for a client integrated with Wordpress user management and I stored additional information for each user under the <code> wp_usermeta </code> table. However, the client's customer database is growing exponentially, and we are now in the thousands , which gives us several tens of thousands ... | The size of the table isn't really the issue, the queries you're running on that table might be. For example, if you're selecting users based on data stored in the user-meta table, then that query will be highly unoptimized, because meta_value is not an indexed field. In which case you may need to add extra indexes or ... | Wordpress usermeta scaling for thousands of users | wordpress |
I'm making my own theme. In my theme I have a page that display custom post using a custom query. I added a form to this page. The form contain 2 comboboxes that contain values of meta data of my custom post. I want that when the user select values from this comboboxes and click the submit, Wordpress will show again th... | I found the problem and the solution. The problem: Using: <code> <form action="<?php echo get_page_link(SHIURIM_PAGE) ?>" method="get"> </code> is no good. In the generated HTML I can see: <code> <form action="http://mySite/?page_id=66" method="get"> </code> But when submitting the form, the ?page_id=... | Form action redirect to the same page | wordpress |
I like to publish drafts in my 'Uncategorized' category. This category is not linked anywhere on my site. It's great for allowing contributors to an article to read the draft before it is made public. The problem is that after just 2 or 3 days, search engines begin picking up the draft and people start posting comments... | How about something like this on your <code> functions.php </code> : <code> add_action('wp_head', 'no_robots_on_uncategorized_posts'); function no_robots_on_uncategorized_posts() { if(in_category('uncategorized')) { wp_no_robots(); } } </code> This will output the following line of code on the header of your 'uncategor... | How to publish page that can't be detected by search engines? | wordpress |
I'm building a navigation, outside of the main loop, that includes drop downs. I have a custom post type called 'Events', that has its own categories. I would like there to be a drop down if there are posts within that custom post type and category, but I'm not sure what functions I should be using to determine this...... | It all boils down to WP_Query in the end even if you use get_posts, here's my modified version: <code> $hasposts = get_posts('post_type=sc-events&category=40'); if( !empty ( $hasposts ) ) { ..// show the drop down menu } </code> or <code> $query = new WP_Query(array( 'post_type' => 'sc-events', 'category' => ... | Check If posts exist in custom post type category, outside of loop | wordpress |
I've created a site made just with custom fields about famous people in sport. In the post page I've a born date and a death date field using the data picker. What I'm trying to achieve is to show posts of people who have died today in the past, if someone has died the 14th of february 1982 I want to show in a page/wid... | It's a little complicated, but we can do this by directly modifying the query with a filter on <code> posts_where </code> . We'll start with a query for posts with a meta value of today's date, this is assuming a date format of <code> yyyy-mm-dd </code> : <code> $date_today = date('Y-m-d'); $args = array( 'posts_per_pa... | Advanced Custom Fields and date picker, show posts only if the day is today no matter the year | wordpress |
I know that <code> get_queried_object </code> contains the object that was queried for the current page. My question is, what methods of querying affect the contents of this? For instance: <code> query_posts </code> <code> get_posts </code> <code> get_post </code> <code> new WP_Query </code> etc. | As per its laconic source: <code> function get_queried_object() { global $wp_query; return $wp_query->get_queried_object(); } </code> This function retrieves object from main query. As such it is affected by anything that changes main query. From your list that would be <code> query_posts() </code> (reason number um... | Setting get_queried_object | wordpress |
The <code> $content_width </code> GLOBAL in WordPress effects many themes and even some plugins by limiting the size of images and embeds in posts, it is a requirement for themes submitted to wordpress.org. It is set by using: <code> $content_width = 584; // Twenty Twelve example </code> If you insert a large image (de... | Keep in mind that the <code> $content_width </code> global is not only used for images, but also for embedded objects, such as video. So, any solution won't merely be a case of dropping use/support of <code> $content_width </code> itself. Usually a Theme will constrain content-area images in a few ways: Large Image siz... | What is a good alternative to using $content_width for image optimization? | wordpress |
I dynamically create iterations of a form field with jquery, but they all carry the name extrakosten[] for the first variable and the other variable vergoeding[]. The php: <code> $postTitle = ''; // save post title if(isset( $_POST['submit'] )){ // if submit button is present for ($i=0; $i < count($_POST['vergoeding... | You could try something like this: <code> $postTitle = ''; // save post title if(isset( $_POST['submit'])){ // if submit button is present $vergoeding=$_POST['vergoeding']; $extrakosten=$_POST['extrakosten']; for ($i=0; $i < count($vergoeding); $i++) { $new_post = array( 'post_title' => $postTitle, 'post_content'... | posting twice from an array? | wordpress |
I need to add a css class to every <code> <a> </code> element retrieved by <code> the_terms() </code> (or similar function) in order to open the taxonomy permalink in a fancybox modal window. I've been searching this whole afternoon for a Filter that could handle it, with no success. Anyway, I got into this (poor... | The filter you are looking for is <code> term_links-$taxonomy </code> , where <code> $taxonomy </code> is the taxonomy name. This will filter the <code> $term_links </code> links array before outputting by <code> the_terms() </code> : <code> add_filter('term_links-cities', 'ad_filter_links'); function ad_filter_links($... | Add a css class to a taxonomy permalink | wordpress |
I'm trying to use code to show custom field outside the loop in wordpress attachment page (image.php) it's returns nothing. this is the code i'm used to show the custom field: <code> <?php global $wp_query; $postid = $wp_query->post->ID; echo get_post_meta($postid, 'my-custom-field', true); ?> </code> and i... | You already have <code> $post </code> object on <code> image.php </code> . Don't complicate and use following: <code> <?php echo get_post_meta($post->ID, 'my-custom-field', true); echo $post->post_parent; </code> | How to show custom field and parent post id in wordpress attachment page (image.php) | wordpress |
What's the best way of checking if my commenter is also the author of the post that he post comment on? I know there's a css way ( <code> .byauthor </code> ), but how about PHP? How to compare post author with comment author? I was trying with is_author(), the_author() and comment_author() but it just doesn't look righ... | Not sure what you are meaning to do but, if you take a look at the <code> get_comment_class() </code> function that is responsible for generating the <code> .bypostauthor </code> class you can see how it determines if the commenter is the author <code> if ( $post = get_post($post_id) ) { if ( $comment->user_id === $... | How to check if commenter is the_author? | wordpress |
We are about to purchase a site that uses Amazon affiliate links. Naturally, they have their own affiliate ID, Amazon affiliate links look like this: <code> http://www.amazon.com/gp/product/productcode/?tag=affiliateID-20 </code> What would be the best way to alter the ending string for these links' URL's in a Wordpres... | DISCLAIMER : Not a WordPress Developer, Just a MySQL DBA For a given table, say <code> link_url </code> <code> mysql> show create table wp_links\G *************************** 1. row *************************** Table: wp_links Create Table: CREATE TABLE `wp_links` ( `link_id` bigint(20) unsigned NOT NULL auto_increme... | Replacing link URL ending strings via MySQL | wordpress |
Currently, I'm building multi languages blog. As I know, almost WP language translator plugins are based on .po & .mo files. here is a problem. A new language what I'm going to add does not exist with .po & .mo files, it's just a dialect(local) language. That's why I defined in php and grab the language.php fil... | http://wordpress.org/extend/plugins/wcm-user-language-switcher I tried wcm language switcher, it only supports for users, not for guest who are not logged in. anyway thanks to kaiser & brasofilo. Finally, I got a solution with theme switcher plugin http://wordpress.org/extend/plugins/theme-switcher I duplicate my t... | Adding Language Switcher in header , WP | wordpress |
Two ways of doing the same thing: First one: <code> var _custom_media = true, _orig_send_attachment = wp.media.editor.send.attachment; $('.media-upload-button').click(function(e) { var send_attachment_bkp = wp.media.editor.send.attachment; var button = $(this); var id = button.attr('id').replace('_button', ''); console... | you can move the wp.media stuff to an external function which accepts the element as a parameter and call it on the click event like this: <code> jQuery(document).ready(function($){ $('.media-upload-button').click(function(e) { e.preventDefault(); upload_image($(this)); return false; }); }); function upload_image(el){ ... | 3.5 Media Manager - callout in metaboxes | wordpress |
Is there any way to display the Today's date outside any loop/post using WordPress date/time function instead of using the PHP <code> date() </code> function? I'm using the PHP <code> date() </code> function but it does not translate the date (month/day names) in the local languages, so it is not possible to translate ... | Use <code> date_i18n() </code> from <code> wp-includes/functions.php </code> . <code> /** * Retrieve the date in localized format, based on timestamp. * * If the locale specifies the locale month and weekday, then the locale will * take over the format for the date. If it isn't, then the date format string * will be us... | Display Today's date outside the loop? | wordpress |
I know this has been asked many times. But from what i got after searching, i could not understand much. I have used <code> wp_update_nav_menu_item </code> to add menu items programatically. But i don't know how to remove a specific menu item. In one of the forums, it has been told to unset the array element (stackexch... | I think the best way to remove a menu item from a menu is by hooking to <code> wp_nav_menu_objects </code> filter (@Otto answer from the thread you mentioned). And the way you use is first check for the correct menu to filter, and then search for the menu item and remove it by unsetting it from the <code> $sorted_menu_... | Remove a menu item in menu | wordpress |
I am trying to make available a mp4 video of ~500Mb but my connection is too slow to do this at home. To achieve this, I uploaded the video via ssh from school then i used the wordpress media manager to upload a mp4 file of 1 byte. Once this file is uploaded, I went through ssh to its directory then I moved the 500Mb f... | The multisite is using <code> ms-files.php?file=$2 </code> to open uploaded files and at the end of ms-files.php you have <code> // If we made it this far, just serve the file readfile( $file ); </code> So opening a 500mb file could be too much for your php process. You could try to increase the available memory footpr... | MP4 upload ok, but HTTP500 if I update the file (multisite) | wordpress |
I need to get all file attachments which is not an image, 'post_mime_type' only accepts "any" or specific mime types, How to grab all type of attachments, but images? | WordPress has a function, <code> get_allowed_mime_types </code> , which will return all allowed types. We can filter this list and exclude any types containing <code> image </code> , then query for all remaining types by passing them as a comma separated list to <code> post_mime_type </code> . This may not be the most ... | How To Grab All Type Of Attachments, But Images? | wordpress |
<code> $output .= '<li class="recentcomments">' . sprintf(_x('%1$s %2$s - %3$s %4$s', 'thst'), get_avatar( $comment, 48 ), (...); </code> This is my line of code and Wordpress Theme Checker tells me "Text domain problems. You have not included a text domain!" I have included one though, as you can see. What could... | <code> _x() </code> is for string with a context. So your second argument is just the context, and there is no text domain. Suggestion: <code> $string = _x( '%1$s %2$s - %3$s %4$s', # string to translate 'recent comments 1 = gravatar, 2 = … ', # context for translators 'thst' # text domain ); $visible = sprintf( $strin... | Theme Checker Text Domain | wordpress |
I'm trying to generate rewrite rules for a RESTful API. I just want to see if there is a better way to make this work than having to write out every possible rewrite combination. Ok so I have 4 query variables to account for in the URL Indicator Country Response Survey The base url will be www.example.com/some-page/ Th... | I think the best option is an endpoint. You get all the data as a simple string, so you can decide how it will be parsed, and you don’t have to worry about collisions with other rewrite rules. One thing I learned about endpoints: keep the main work as abstract as possible, fix the glitches in WordPress’ API in a data a... | Using the Rewrite API to Construct a RESTful URL | wordpress |
I have a query running which prevents posts without various criteria from appearing, one of these is the necessity to have a featured image. Sticky posts however seem to end up in the query regardless. How can I achieve this? <code> $args = array( 'posts_per_page' => $articles_no, 'meta_key' => '_thumbnail_id', '... | Per the Codex article on WP Query : ignore_sticky_posts (boolean) - ignore sticky posts or not. Default value is 0 - don't ignore sticky posts. Note: ignore/exclude sticky posts being included at the beginning of posts returned, but the sticky post will still be returned in the natural order of that list of posts retur... | Keep sticky posts out of query unless they have featured image | wordpress |
I am trying to add a variation product to my cart directly through a link. I am setting the variation_id with the query string. As far as I can tell I am sending the data the exact same way as the default variation product form does. Here's the code inside of my single-product page: <code> <a href="<?php echo esc... | Figured this one out. I was missing a couple parameters needed to add a variable product to my cart. The missing params are the <code> variation_id </code> and the attribute type that the <code> variation_id </code> is referring to. The variation id can be found in the admin > woocomerce > products and under the variat... | Woocommerce Add Variation Product to Cart from custom link | wordpress |
I have a custom category checkbox on each individual bio attorney page that shows what practice areas these attorneys are involved in. Currently I have them sorting alphabetically. I am wondering if there is anyway to allow each attorney to set their own custom order when selecting their practice areas. Here is a scree... | For those interested I figured it out. I added this to my functions.php: <code> function set_the_terms_in_order ( $terms, $id, $taxonomy ) { $terms = wp_cache_get( $id, "{$taxonomy}_relationships_sorted" ); if ( false === $terms ) { $terms = wp_get_object_terms( $id, $taxonomy, array( 'orderby' => 'term_order' ) ); ... | Allow user to set custom order to a list of custom taxonomies? | wordpress |
I'm currently using a custom made Twentytwelve child theme and would like to display the last 5 posts on the homepage using a shortcode. I have tried using the code below (added to <code> functions.php </code> ) but to no avail - when I add the shortcode to the homepage, it doesn't display anything although as far as I... | The issue is with your <code> $limit </code> var, you can't set a default value like that because WordPress overwrites it with an empty value. Check out the Shortcode API for the correct way to pass and set shortcode attributes. <code> function custom_prev_posts( $atts ){ extract( shortcode_atts( array( 'limit' => 5... | Display latest 5 posts on homepage | wordpress |
I'm trying to display a list of authors by their last name. I can get the list to display but as yet I don't seem to be able to order the list by last name. Any help would be greatly appreciated. Josh <code> <?php $args = array( // search only for Authors role // order results by display_name 'orderby' => 'meta_v... | There is apparently an open ticket about this bug . Here is a workaround that I tested: <code> $args = array( 'meta_key' => 'last_name', 'role' => 'guest-teacher' ); $wp_user_query = new WP_User_Query($args); $wp_user_query->query_orderby = str_replace( 'user_login', 'wp_usermeta.meta_value', $wp_user_query-&g... | Ordering users of a specific role by last name | wordpress |
I set an email button in functions php. The email is sent when clicking on a front-end update post button. The problem is: the email is sent but I can't get the post title to appear in the post. I guess I didn't correctly set the post_title variable... Anyway, here's the code (taken and partially edited from a old wp a... | it looks like you should use <code> $mypost = get_post($_POST['pid']); $ogg = $mypost->post_title; </code> instead of <code> $ogg = get_post($post->ID, post_title); </code> | How to get post meta in functions? | wordpress |
Im trying to wrap a shortcode inside of a "user loggeed in" shortcode. Here are the two shortcodes and my setup in WYSIWYG <code> function wpfc_logged_in( $atts, $content = null ) { if (is_user_logged_in() ) { return do_shortcode($content); } } add_shortcode('loggedin', 'wpfc_logged_in'); function info_box( $atts, $con... | it looks like you have extra spaces in your shortcodes. Try <code> [loggedin] [info_box type='setting']content text[/info_box] [/loggedin] </code> instead of <code> [loggedin] [ info_box type='setting' ]content text[ /info_box] [/loggedin] </code> | How to: Simple Nested Shortcode | wordpress |
I'm working on a site for a client that has a member subscriptions as well as a small store. We're using memberpress to handle subscriptions, and restricting content to certain membership types. For the store we're using woocommerce. The two plugins seem to be conflicting on the checkout page though. Everything works f... | Just solved this. Under memberpress options, we had to uncheck the option to "Keep members out of the WordPress Dashboard". That was it! I think the woocommerce checkout page was using ajax to call "admin-ajax.php". Memberpress was preventing users from accessing this page so it brought up the login redirect page inste... | Memberpress isn't cooperating with WooCommerce | wordpress |
Is there any software that I can run on either a Linux or a Windows server to check for domains that have out dated WordPress installations. I have seen a rise in hacked WordPress sites and in all the cases it was because the clients had not installed updates. | If you can access the files from the server just include <code> wp-includes/version.php </code> from each installation. That file is completely stand-alone, it just defines five variables: <code> /** * The WordPress version string * * @global string $wp_version */ $wp_version = '3.5.1'; /** * Holds the WordPress DB rev... | Software to run on server checking outdated wordpress installations | wordpress |
Currently my text area input (which accepts custom CSS input from a user) in the Wordpress theme options panel are sanitized by esc_html function in Wordpress http://codex.wordpress.org/Function_Reference/esc_html However I am thinking a secure approach, so I would like to add HTML purifier and CSSTidy like it's illust... | If you worry only about the admin panel then esc_html will be enough as it will convert every "<" into &lt; eliminating the possibility of having a valid HTML tags inserted. But if you add the CSS to the generated HTML you might need to strip any HTML tag it may contain by using the wp_kses function <code> $css ... | Using esc_html with HTML purifier and CSSTidy: Overkill? | wordpress |
I have a site that must be deployed in a WP Multisite environment but none of the code in the site uses WordPress at all. How can I intercept WordPress, perhaps at 'init', and tell it to stop doing anything and let me take over? I tried just putting everything in my <code> index.php </code> file and include everything ... | You could hook <code> init </code> and check the current blog ID <code> function wpa85780_my_app_init(){ $my_blog_id = 99; if( $my_blog_id == get_current_blog_id() ): include 'somefile'; exit; endif; } add_action( 'init', 'wpa85780_my_app_init' ); </code> This will exit before WordPress does the main query and loads th... | Stop WordPress Entirely and Run My Own Code | wordpress |
I'm using the standard WP Custom Backgrounds feature, however, the color is defaulting to #166b4c and I'm unsure why. #166b4c does not appear in my stylesheet. Below is my code. <code> add_theme_support( 'custom-background' ); $defaults = array( 'default-color' => '000', 'default-image' => '', 'wp-head-callback' ... | You have to pass the <code> $defaults </code> as the second parameter to <code> add_theme_support() </code> per the Codex <code> $defaults = array( 'default-color' => '000000', 'default-image' => '', 'wp-head-callback' => '_custom_background_cb', 'admin-head-callback' => '', 'admin-preview-callback' => '... | Custom Background: Can't Set Color Default | wordpress |
I like to execute a update_options() and stuff and then redirect to another plugins page? Directly after the user clicks a link in a Admin notice. How would i do that? Ajax? Is that even possible? | You could use <code> /wp-admin/admin-post.php </code> . Link: <code> $url = admin_url( 'admin-post.php?action=somethingunique' ); print "<a href='$url'>Update and redirect</a>"; </code> Then you should register a callback for that action: <code> add_action( 'admin_post_somethingunique', 'wpse_85825_callback... | Is it possible to set a option, and then redirect to another page directly from a admin notice link? | wordpress |
I've set up my new shiny 3.5.1 WordPress using Git, following these instructions: http://clintberry.com/2011/speed-up-your-wordpress-development-cycle-with-git/ (stopping after step 2; I've not created the child theme yet). I would expect the Roots theme to work by itself) What I basically have is the same as the autho... | I took a risk and activated the theme to see what might happen. Roots needs to complete theme activation to add the rules into .htaccess. Until this happens none of the CSS / JS will load and the theme preview lacks stylesheets. It turns the stock .htaccess: <code> # BEGIN WordPress <IfModule mod_rewrite.c> Rewri... | Why do the Roots theme CSS files not load (404)? | wordpress |
I have a bit of a tricky one... I have a hierarchical Custom Post Type ('shows') that represents events. Is it possible for the user to create a new page (ie show), save the page and for Wordpress to automatically create a defined set of child pages with defined names? Ideally each child page would have a specific Cust... | Use the <code> save_post </code> action to run some code when a new show is created, then use <code> wp_insert_post </code> to create your child pages. Here's an example to get you started - First, filter out any saves that are auto-saves, post revisions, auto-drafts, and other post types. Once you know it's your show ... | Automatically create child pages when saving a (parent) page | wordpress |
I'm querying to get a list of all posts, 20 posts_per_page, but the result shows all posts, but with 21 posts per page. If I change posts_per_page to 19, then 20 show. One post is sticky and shows up twice; not sure if that is causing the problem. Code: <code> $allposts = array( 'post_type' => 'post', 'posts_per_pag... | Sticky posts do add to the post count rather than being included in it. You can alter your query to ignore sticky posts though. <code> $allposts = array( 'post_type' => 'post', 'posts_per_page' => 20, 'ignore_sticky_posts' => true ); </code> But you are also missing pagination parameters. <code> $paged = (get_... | WP_Query pulling an extra post per page | wordpress |
I've a very simple <code> index.php </code> : <code> <div id="content"> <? get_template_part('content', get_post_format()) ?> </div> <div id="pagination"> <? previous_posts_link() ?> <? next_posts_link() ?> </div> </code> And my <code> content.php </code> looks roughly like thi... | By the time you reach the template, WordPress has already queried the database and decided what to display based on those results. You're seeing a 404 error because based on the default main query, there are no more posts to show. When you call <code> query_posts </code> in the template, you overwrite that original que... | Pagination with custom post types results in 404 issues | wordpress |
I'm creating my first WordPress theme and I'm new to PHP. I've done some looking around but I can't seem to find my specific answer. In my header.php I want to include some conditional logic to set CSS for all pages except the home page. This is my current code but there must be a better way. Couple of other things I'm... | Instead of <code> <?php if(!is_home() || !is_front_page()) :?> </code> you could use <code> <?php else: ?> </code> This style will not affect the wp-admin part, only the front end of your web since this is used in <code> header.php </code> . A safe way is to use <code> wp_register_style() </code> and <code>... | Setting different CSS for all pages except home.php | wordpress |
I'm using WP to work as the CMS for a website which will be provided to users of a number of different products. I've successfully created a function which will redirect users based on their role: <code> add_filter( 'login_redirect', 'my_login_redirect', 10, 3 ); function my_login_redirect( $redirect_to, $request, $use... | <code> $user->data </code> should have what you want. <code> // snip elseif ( in_array( 'map_user', $user->roles ) ) return home_url( "/mapping/{$user->data->user_login}/" ); // end snip </code> Add <code> if (!is_wp_error($user)) wp_die(var_dump($user)); </code> to the top of your function to see what you ... | Is it possible to incorporate username in a login redirect? | wordpress |
I would like to do a filter that will hook to the main query and filter all the posts by some given taxonomy terms or custom fields. For now I have made the custom filters for the $query to only select the posts that have a custom value for certain taxonomy as follows: <code> foreach($data as $taxonomy => $terms): $... | Have a look at the format of a <code> meta_query </code> in <code> WP_Query </code> . <code> $meta_query = array( array( 'key' => 'price', 'value' => array( 500, 1000 ), 'type' => 'numeric', 'compare' => 'BETWEEN' ) ); $query->set( 'meta_query', $meta_query ); </code> | Hook to main query with filters based on custom fields | wordpress |
I want to add a class to the body tag to all pages EXCEPT the homepage. Right now I have. <code> <?php body_class('interior'); ?> </code> But it adds 'interior' to ALL pages including the home page. What is the best standard way of adding a class to the body tag? | Try it: <code> <?php $class = ! is_home() ? "interior" : ""; body_class( $class ); ?> </code> Or this: <code> <?php body_class( ! is_home() ? "interior" : "" ); ?> </code> | How to add a body class to all interior pages except the homepage | wordpress |
How can I get WordPress to render a page without it adding any addtional html? I'm trying to build a dialog that will work on mobile devices and I only want to show that dialog and not have any of the standard wordpress content around it. | You have to implement your own hook for <code> template_redirect </code> action: <code> add_action( 'template_redirect', 'wpse8170_template_redirect', 1 ); function wpse8170_template_redirect() { global $wp_query; // check if it is not a page or if it is front page, then exit from the hook if ( !$wp_query->is_page()... | render html no formatting | wordpress |
I am using the following <code> query </code> on my <code> category.php </code> template: <code> <?php $paged = (get_query_var("paged")) ? get_query_var("paged") : 1; query_posts("posts_per_page=2&paged=".$paged); ?> </code> The one thing that I've noticed is that this breaks my pagination...with this code th... | <code> paged </code> is correct unless you're using pretty permalinks, however, if you're just trying to alter posts per page for categories, you should be using the <code> pre_get_posts </code> action, there's no reason to use <code> query_posts </code> in the template: <code> function wpa85791_category_posts_per_page... | Paginate WordPress Category Pages | wordpress |
After creating new custom post type with <code> register_post_type() </code> function, I don't see the Tags meta box when adding a page of new post type. It seems that tags metabox should be added manually. If so, how can I add it? | There are essentially two ways to do this. The first is to supply the <code> taxonomies </code> keyword in the <code> register_post_type </code> arguments array, like so: <code> register_post_type('my_type', array( ... 'taxonomies' => array('category', 'post_tag'), ... )); </code> The other is to register your post ... | Tags meta box don't show when creating a new post type | wordpress |
I'm trying to create a plugin that will be able to translate language used in wordpress. Here's my current code: <code> add_action('plugins_loaded', function(){ load_plugin_textdomain('ecom', false, dirname(plugin_basename(__FILE__)) . '/lang'); }); </code> The problem is most of the tutorials that I find in the intern... | This questions was already asked half a year ago: stackexchange-url (""Switch language by the click of a button"") The result of it can now be found as a plugin maintained by stackexchange-url ("@StephenHarris") and me. WCM User Language Switcher It also got a place in the official repo . The development version can be... | How to update the language used by wordpress from a plugin | wordpress |
So I'm trying to get my head round <code> <?php wp_head(); ?> </code> . I understand that it loads in the stuff needed for plugins etc., but I'm using a theme that seems to be using it to load in scripts for theme elements as well. There's a folder within my theme called 'scripts' that appears to have all of the ... | You use <code> wp_enqueue_script </code> for Javascript files in your theme <code> functions.php </code> files. I suggest wrapping up all the requests in a function and hook it like so <code> add_action( 'wp_enqueue_scripts', 'script_enqueuer' ); </code> | How can a 'scripts' directory be hooked into wp_head();? | wordpress |
I'm hoping one of you WP gurus can help me out here... I have a website. Let's call it Jack.com I'm re-branding Jack as a girl, so I've made another website website - Jill.com I want all existing links that are spread out over the net to be redirected to the equivalent, sister page eg. Jack.com/article_12 needs to redi... | I don't think this needs any Wordpress at all. I would set up a single <code> .php </code> script setting the headers as such: <code> header("HTTP/1.1 301 Moved Permanently"); header('Refresh: 5; URL=http://jill.com/name_of_the_article'); </code> And then whatever content you wish. Then I would set up a redirect to the... | Redirecting old site links to new site | wordpress |
I am having no luck with querying a custom post type taxonomy from an array in theme options. My full code is below, would be grateful for some feedback to get it working correctly as I cannot get this to work. <code> // Pull all the custom taxonomies into an array // options.php $options_taxonomies = array(); $taxonom... | You create a new query and assign it to <code> $my_qry </code> , but you never loop over those results. See the codex page for <code> WP_Query </code> , the loop has to reference your new query object: <code> $my_qry = new WP_Query($args); if ( $my_qry->have_posts() ) : while ( $my_qry->have_posts() ) : $my_qry-&... | Cannot query custom post type taxonomy from theme options array | wordpress |
I just installed a new wp installation. I have created a new child theme based on the TwentyTwelve theme. In the child theme functions.php, I have created a new custom post called "news". I have added two posts in the "news" and when I view either of them, I get a "page not found" error. See screenshot: http://pasteboa... | RESOLVED: This is really weird but I have resolved it. It appears I needed to reselect the "Post name" option for my permalinks settings even though it was already selected. Selecting this option again solved my problem. Sorry about any confusion. I went to settings > permalink | Why my custom post posts aren't showing (404 error / page not found) | wordpress |
I setup WordPress on my own server and it's up and running...one thing that I have noticed is that WordPress doesn't generate any images I upload. Usually when I upload an image through WordPress it will generate a thumbnail, medium, and large sized image. WordPress installed without error and everything else is workin... | I figured it out! In my php.ini file I had to uncomment <code> extension=php_gd2.dll </code> , then it started working after I rebuilt the images I uploaded :) Thanks, Josh | No Thumbnails Generated | wordpress |
This is how I'm adding a featured image to my RSS: <code> function featuredtoRSS($content) { global $post; if ( has_post_thumbnail( $post->ID ) ){ $content = '' . get_the_post_thumbnail( $post->ID, 'topImage', array( 'style' => 'margin:0 auto; border: 1px solid #555; display:block;' ) ) . '' . $content; } retu... | You can add this part into your function: <code> $audios =& get_children('post_type=attachment&post_parent='.$post->ID.'&post_mime_type=audio' ); foreach ( $audios as $id => $audio ){ $content.='<a href="'.wp_get_attachment_url($id).'" target="_blank">'.$audio->post_title.'</a> '; } </c... | Add audio attachment link to RSS | wordpress |
I created some custom post types, but I would like to hide them in the dashboard from Subscribers, Authors, and Editors (essentially, just allow administrators to access them). Can I do this without installing a plugin? | I'm sure you could specify some capabilities while registering the Post Type itself. Although, here is a more robust version that can be used widely across the administration dashboard. <code> /** * Hide dashboard administrator menus from disallowed user roles. * * @author Michael Ecklund * @access public * * @return v... | Roles for Custom Post Types | wordpress |
How to localise this string (including html) ? <code> echo "<div class='updated'><p>All options are restored successfully.</p></div>" ; </code> Is this correct? <code> echo '<div class="updated"><p>' . __( 'All options are restored successfully.', 'mytextdomain' ) . '</p></d... | Your example is correct, simply because it works. There are hundreds of ways to localize strings wich are displayed including html, all good and elegant in their own way. I like to do this as follows: <code> printf( '<div class="updated"> <p>%1$s</p> </div>', __( 'All options are restored succes... | Strings including html for localisation | wordpress |
Is there a way to enqueue only plugin styles and scripts without wp_head? I have a plugin I'm working on which overrides the page template, but I still want to include all other plugins without including the theme style. Since theme developers don't always enqueue their styles and often hardcode the link, what's the be... | Since theme developers don't always enqueue their styles and often hardcode the link, what's the best way around this? There is no way around this. Simply said: Let them burn. They're doing it wrong and as a 3rd party code developer you don't have to take wannabe developers into account. | Enqueue ONLY Plugin Styles and Scripts | wordpress |
This code form HTML editor: <code> <code>&#91;shortcode&#93; &#91;bar&#93;foo&#91;/bar&#93; &#91;bar&#93;foo&#91;/bar&#93; &#91;bar&#93;foo&#91;/bar&#93; &#91;/shortcode&#93;</code> </code> Returns: <code> [shortcode]<br /> [bar]foo[/bar]... | Wordpress assumes that you use <code> <code> </code> for inline code and <code> <pre> </code> for a box of code. In your case, then, you shouldn't have any need to use <code> <pre><code> </code> but just <code> <pre> </code> See: Writing Code in Your Posts | Remove line breaks from <code> ? | wordpress |
I'm trying to create a basic affiliation system plugin that for now, will do the following: If it exists, read a $_GET URL parameter in any page (for instance http://mysite.com/about/?affid=1234 ). If not skip the following two steps. Save it in a cookie Redirect to a clean URL ( http://mysite.com/about/ ) My issue lie... | This should work , though untested. <code> <?php add_action('send_headers', 'affiliate_redirect'); function affiliate_redirect() { // it's possible to use 'if( !empty( $_GET['affid']) )' if( isset($_GET['affid']) && '' != $_GET['affid'] ) { if( empty($_COOKIE['affid']) ) setcookie('affid', $_GET['affid'], ti... | Detecting $_GET parameters from any page + Cookie | wordpress |
I want to remove a CSS from loading in the header, this is the code that appears: <code> <link rel='stylesheet' id='my-css' href='http://test.tld/wp-content/themes/mytheme/my.css?ver=3.5' type='text/css' media='all' /> </code> I tried using these functions but it didn't work: <code> wp_dequeue_style('my-css'); wp... | If your stylesheet is registered and enqueued correctly then... <code> function dequeue_my_css() { wp_dequeue_style('my-css'); wp_deregister_style('my-css'); } add_action('wp_enqueue_scripts','dequeue_my_css'); // add a priority if you need it // add_action('wp_enqueue_scripts','dequeue_my_css',100); </code> ... should... | How to remove CSS file in the header using Wordpress functions? | wordpress |
I have a bunch of code that I tend to put into the <code> header.php </code> of every site I do which are specific to Internet Explorer. I was wondering if there was a way to insert code into a 'standard' <code> header.php </code> . Yes, I can simply modify the header. But the idea is to make this a plugin which is gen... | One way to do it is using the <code> wp_head </code> action: <code> function wpse85495_header() { ?> <!--[if IE]> <link rel="stylesheet" href="<?php bloginfo('stylesheet_directory'); ?>/ie.css" type="text/css" /> <![endif]--> <?php } add_action('wp_head','wpse85495_header'); </code> but I ... | Adding custom code into header.php using a plugin | wordpress |
Trying to work out how I could track the time that a field was updated and display that time on a page. So far: Using advanced custom fields and the options page the user updates some fields What I'd like to be able to do Capture the time this happens and output it onto a page Why? Each day the user is inputting prices... | You can use the <code> acf_update_value </code> filter to set a post meta value whenever the field is updated. Here's an example for a field named <code> test_field </code> . Check if the current field is <code> test_field </code> , then get its old value and compare it to the new value. If it has been updated, update ... | How can I track and output when a field is updated? (currently using Advanced Custom Fields) | wordpress |
i have this snippet for specific category it works perfect but i want little modification to show posts by Ascending order. <code> <?php // The Query query_posts( array ( 'category_name' => 'A', 'posts_per_page' => -1 ) ); // The Loop while ( have_posts() ) : the_post(); ?> <li> <a href="<?php t... | Pretty sure query_posts is the worst way to query... Always use get_posts from what I'm constantly told. Remove the arguments that you don't use on the array below. <code> $args = array( 'posts_per_page' => 5000, 'offset' => 0, 'category' => , 'orderby' => 'post_date', 'order' => 'ASC', 'include' => ,... | wordpress loop for specific category | wordpress |
I'm building a theme options panel and so far been successful, except with the "Select" type option. This is my code: <code> array( "name" => "Transition", "desc" => "Choose the type of transition.", "id" => $shortname."_transition", "type" => "select", "std" => '1', "options" => array("0" => "None... | There're several things to note: <code> get_settings() </code> is deprecated and <code> get_option() </code> should be used instead WordPress comes with a function named <code> select() </code> that takes three arguments: Saved value, looped value, echo You're better off saving your key, than the HTML capable "title" e... | Theme Option select values | wordpress |
To improve communication between guest commenters and authors, I am fiddling with a script that sends an email to the author of a comment when it receives a reply. Here is how the code looks so far: <code> <?php /* Plugin Name: Comment Reply Notifier Plugin URI: stackexchange-url 0.1 Author: Christine Cooper Descrip... | Guess you need to use header to perform the sender... by default the sender is wordpress@yousite.domain <code> $headers = 'From: My Name <myname@mydomain.com>' . "\r\n"; </code> ... <code> wp_mail( $email, $headers, $subject, $notify_message, $message_headers ); </code> Edited... source: http://codex.wordpress.or... | Notify comment author upon reply | wordpress |
If we try to access a non-existant Multisite site, e.g., <code> http://site1.example.com </code> or <code> http://example.com/site1/ </code> , we are redirected to <code> http://example.com/wp-signup.php?new=site1 </code> . How to block this and redirect the browser to another page? | [Update] An alternative (maybe better) is to use the following constant in <code> wp-config.php </code> : <code> define( 'NOBLOGREDIRECT', 'http://example.com' ); </code> At the very beginning of <code> wp-signup.php </code> file there is this code: <code> function do_signup_header() { do_action( 'signup_header' ); } a... | How to disable Multisite sign-up page? | wordpress |
In my <code> functions.php </code> <code> function load_scripts() { wp_enqueue_script( 'jquery' ); wp_register_script( 'modernizr', get_template_directory_uri() .'/js/modernizr.foundation.js' ); wp_enqueue_script( 'modernizr' ); wp_register_script( 'jquery.simpleWeather', get_template_directory_uri() .'/js/jquery.simpl... | You don't need <code> if ( !is_admin() ) </code> . <code> wp_enqueue_scripts </code> only runs on the front end. WordPress loads jQuery in "No Conflict" mode . The <code> $ </code> alias does not work. Use <code> jQuery </code> or wrap your script is a function as demonstrated in the jQuery docs: <code> jQuery.noConfli... | Register and load scripts | wordpress |
I get the following error message on wamp after I activated my child theme. what am I doing wrong? <code> Warning: include(C:\wamp\apps\test/wp-content/themes/test/functions/options-panel/customizer.php) [<a href='function.include'>function.include</a>]: failed to open stream: No such file or directory in C... | This depends a lot on the child theme. However, here is the general gist of things. Not all themes are meant to be used as parent themes. Many aren't tested properly and are using the wrong constants and API functions. For example, <code> get_stylesheet_directory() </code> will return the current theme's stylesheet dir... | Error when activating child theme: `failed to open stream: No such file or directory` | wordpress |
I am having some issues with querying the output of custom taxonomies in my theme options. I have included what I think are the necessaries below. Many thanks for your help in advance. <code> // Pull all the custom taxonomies into an array $options_taxonomies = array(); $taxonomies_terms_obj = get_terms('portfolio_cate... | I see three things. <code> if ( function_exists( 'of_get_option' ) ) : query_posts( 'cat=' . $homepage_feature = of_get_option( 'homepage_feature' ) . '&posts_per_page=3' ); </code> You have a syntax error. There is no <code> endif; </code> . Maybe that is a typo, but maybe not. If you are trying to write a one-lin... | Problem with query_posts for a custom taxonomy in theme options | wordpress |
I have this <code> while </code> loop in my product page with Wordpress e-commerce plugin. It is looping through custom post meta. <code> <?php if (wpsc_have_custom_meta()) : ?> <?php $count = 2; ?> <?php while ( wpsc_have_custom_meta() ) : wpsc_the_custom_meta(); ?> <?php if (stripos(wpsc_custom_m... | It doesn't appear possible to loop over the values multiple times without directly manipulating the <code> current_custom_meta </code> class var so that <code> wpsc_have_custom_meta() </code> will return <code> true </code> again. Give this a try before the second while loop: <code> global $wpsc_custom_meta; $wpsc_cust... | Multiple while loops not functioning | wordpress |
I'm trying to delete all wordpress comments with only one word. I found this mysql query to delete all comments at once, but that's not what I want to achieve: <code> DELETE FROM wp_comments WHERE comment_approved = '0' </code> | DISCLAIMER : Not a WordPress Developer, Just a MySQL DBA If you have privileges to login to MySQL and query data you could collect all the <code> comment_ID </code> values that have one word. <code> SELECT comment_ID FROM wp_comments WHERE REPLACE(TRIM(comment_content),' ','')=TRIM(comment_content); </code> You can tes... | Delete all one-word comments | wordpress |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.