question stringlengths 0 34.8k | answer stringlengths 0 28.3k | title stringlengths 7 150 | forum_tag stringclasses 12
values |
|---|---|---|---|
I'm looking to see if I could get pointers in where to look to solve this issue. Issue In Chrome, viewing the blog http://www.bitesizeirishgaelic.com/blog/ in Chrome v21, the page downloads as a file "download", rather than opening normally. The rest of the site on the same server loads fine in Chrome. All pages load f... | The page is sent with: <code> Content-Type: application/x-gzip </code> Change the Content-Type to <code> text/html </code> . | Page downloads as file in Chrome | wordpress |
I am using this code for listing out all authors on the site in my sidebar. It works, except I also need to pull in their Gravatar image. It's working in a loop on the homepage with this <code> <?php echo get_avatar( get_the_author_email(), '80' ); ?> </code> but is there a way I can add it to this list as well? ... | Basic setup <code> <?php $args = array( 'orderby' => 'nicename' ); $users = get_users( $args ); foreach ( $users as $user ) { $avatar = get_avatar( $user->ID, '80' ); echo '<li><a href="' . $user->user_url . '">' . $avatar . '<br />' . $user->display_name . '</a></li>'; } ?&... | Add gravatar to author list | wordpress |
I'm working on a plugin which uses a shortcode to call a JQuery function, and it requires three aspects to work: The JQuery code + its own code, to be included on the pages it will be used on The HTML element it will work on requires an "id" attribute, in order to reference it A reference/initialization in a <code> $(d... | For 2nd, i recommend using the php function <code> uniqid() </code> , takes some of the work of user. For 3rd i think the best way to implement is to keep adding the id's after each shortcode call to a global/static variable in an array & then hook a function to <code> wp_footer </code> that reads from this variabl... | Enumerating shortcode attributes in JavaScript | wordpress |
I am trying to create a menu structure with a simple concept: A horizontal, 1-level deep main menu A vertical submenu, that contains children of the current main menu item (2 levels deep) Of course, the submenu should be shown in the following cases: Viewing the main menu item Viewing a direct child of the main menu it... | Don't know if this is the best way but i would go like this- 1) Hook into <code> wp_nav_menu_objects </code> filter. The function will recieve a list of all menu-items. These menu items will already have the information regarding current page or current page's ancestor(do a <code> var_dump </code> once) 2) From these m... | wp_nav_menu - show children of current menu item only? | wordpress |
I'm not a sql expert, but with some help and copying from queries I've found on the web I got this working one that gets the 20 closest places (custom post type) to a specific latitude and longitude ($lat and $long). How can I edit this query to have also the post thumbnail ID in it? I want to do this to reduce the num... | Haven't tested it, but this should work: <code> SELECT $wpdb->posts.ID, $wpdb->posts.post_title, $wpdb->terms.name, wpcflat.meta_value AS latitude, wpcflong.meta_value AS longitude, 6371 * 2 * ASIN ( SQRT (POWER(SIN(($lat - wpcflat.meta_value)*pi()/180 / 2),2) + COS($lat * pi()/180) * COS(wpcflat.meta_value *p... | Get post featured image id with $wpdb | wordpress |
As per the answer provided in stackexchange-url ("How to create custom URL routes?") I have created the rewrite rule using the same function provided. <code> add_action( 'init', 'wpse26388_rewrites_init' ); function wpse26388_rewrites_init(){ add_rewrite_rule( 'gallery/([0-9]+)/?$', 'gallery?custom_gallery_id=$1', 'top... | first, you need to add your <code> custom_gallery_id </code> to query vars if you haven't already: <code> add_filter( 'query_vars', 'wpse26388_query_vars' ); function wpse26388_query_vars( $query_vars ){ $query_vars[] = 'custom_gallery_id'; return $query_vars; } </code> for your rewrite rule, you need to load a WordPre... | unexpected problem in url rewrite | wordpress |
We have a multisite setup, the primary site needs to have <code> example.com </code> , <code> www.example.com </code> and <code> secure.example.com </code> mapped in wordpress so the primary site's content loads on them. <code> secure.example.com </code> will be over HTTPS. The problem we are facing is everything excep... | In the end I ended using mod_rewrite through .htaccess. The following is what I am using and so far is working well. <code> RewriteCond %{HTTP_HOST} ^secure\.domain\.net$ RewriteRule (.*) http://www.domain.net/$1 [P,L] </code> | How to map secure.domain.com to www.domain.com or domain.com with "WordPress MU Domain Mapping" on the primary multisite domain? | wordpress |
Assuming i've got a bunch of setting sections. I add these sections to my plugin page in the following way. <code> $sections = array('notifcations', 'updates'); foreach ($sections as $section) { add_settings_section( $section .'_section', $section, array( $this, 'disable_callback_warnings' ), 'sgnc' ); } </code> Everyt... | Localize the headings in your initial array: <code> $sections = array( 'notifcations' => __( 'Notifications', 'your_text_domain' ), 'updates' => __( 'Updates', 'your_text_domain' ) ); foreach ($sections as $section => $header ) { add_settings_section( $section .'_section', $header, array( $this, 'disable_callb... | Localise settings section headline | wordpress |
I created a couple of templates for a project, which is in fact a child theme of the Contrast theme . In the Wordpress CMS, I can select the templates I created: http://i.imgur.com/PYKqK.png (Can't post image, I'm too much of a newbie the site says...) In one of the functions of the theme (see background.php below), th... | When you call <code> query_posts($query); </code> in your second template, you overwrite the global variable that WordPress uses to return the correct values for the <code> is_ </code> conditionals. You should basically never use <code> query_posts </code> in the template. For secondary loops, use a new instance of <co... | Why is custom template not seen as page with is_page()? | wordpress |
I wrote WordPress plugin and want to include 2 extra Widgets with it... <code> if( !class_exists('plugin_name') ) { class plugin_name { // plugin code } } // include widgets code require_once( 'include/custom_functions.php' ); </code> ...and Widgets (according to WP codex) should be created like this within "custom_fun... | There's no need to nest classes (and you can't anyway), you just create a new instance of the class. The code below would automatically call the My_Widget class to create a widget based on your existing code. <code> Class plugin_name { // Call the widget class public function __construct(){ $this->widget = new My_Wi... | How do I create Widget within plugin that uses its own class? | wordpress |
Is there a way to limit the creation of pages (custom post type) to a specific depth - e.g. level 1 (where 0 = parent, 1 = child, 2 = grand-child, etc.)? For example, let's create a 'Summer' recipe page (custom post type: Recipe) with a slug '/summer'. Let's now create a 'Pie' page (a child of 'Summer') with a slug '/s... | <code> function my_test($a) { $a['depth'] = 1; return $a; } add_action('page_attributes_dropdown_pages_args','my_test'); </code> Put that in a theme's function.php or in a plugin. | How To Limit Hierarchical Pages Depth (For Custom Post Types) To Children Only | wordpress |
I have setup a jQuery keyup delay function to check the email typed into an input field. It works fine after testing with an <code> alert('Key pressed!'); </code> But I want it to say, for example, 'Yes this email is associated with a user' OR 'Sorry, this email is not in our database' without submitting any page reque... | I would use an AJAX request to a PHP script that does the lookup, which might look something like this on the jQuery side after document ready: <code> // jquery $('#email-input').live('change', function() { //ajax request $.ajax({ url: "email_check.php", data: { 'email' : $('#email-input').val() }, dataType: 'json', su... | How can I check email exists via a jquery keyup()? | wordpress |
I am using loops as means of displaying personal meta and customer information on the frontend. For example, I have a page which displays a user's 'profile' information to edit. Their profile is custom post type that was created when the registered. The loop for the edit screen finds the one cpt based on the current us... | This loop looks pretty sure to me. You aren't exposing any raw SQL anywhere, so injection attacks shouldn't happen. | How 'secure' are loops? | wordpress |
I have an XML feed url I am now using this code to create new Custom Post Type Posts from an rss feed in my functions.php file: <code> /* | ------------------------------------------------------------------- | Schedule and update fashion news with the news rss feed | ----------------------------------------------------... | The RSS feed has all the items in a fixed order(latest to oldest). In this case you can save the date & time of the last post you created, as an option & when you read the feed again, you can check the time previously saved to know which of the posts in the feed are new & insert them, then update the time a... | How do I Import an RSS feed as Wordpress posts without duplicates? | wordpress |
in my homepage I have content boxes with different layouts. Every box has an image and the post title corresponding to a single post. How should I use only one single get_posts() and format the layout of the boxes differently? Example: H1 Post-title 1 Image 1 BIG H2 Post-title 2 Image 2 MEDIUM H3 Post-title 3 Image 3 S... | As @MridulAggarwal already stated, it's a pretty basic PHP task that you're confronted with: <code> $wpse69584_posts = get_posts( array( /* Your Arguments */ ) ); echo $post[0]['post_title']; echo isset( $post[0]->post_excerpt ) ? apply_filters( 'the_excerpt', $post[0]->post_excerpt ) : apply_filters( 'the_conten... | Multiple item layout with one query | wordpress |
I'm trying to create a front-end registration form for my Wordpress website. The registration form is in the header, so any plugins I've seen don't work as they use shortcodes. Look at my website for a better explanation. I want the registration form to work in the dropdown box at the top of the page. http://swen.me.uk... | If you were to use a plugin that uses shortcode you can call it in your template by using this in your template: <code> <?php echo do_shortcode ('[your-shortcode]'); ?> </code> You can also do something similar to this form / code below for a front end login: <code> <form method="post" action="<?php bloginf... | Front-end registration form with password field | wordpress |
I tried to find replacement function for get_user_by_email($email) but no luck. This function I am using to allow user to log in by email address or user id. Is there any replacement function or alternate way to do that? | <code> get_user_by </code> is the replacement for <code> get_user_by_email </code> : <code> $user = get_user_by( 'email', 'user@email.com' ); </code> | Deprecated function get_user_by_email($email) | wordpress |
I'm creating two websites, one radio station and one bands website. I want to add a player (already have a php with the player in it) to the top of the page, like a frame. The main point is to have the player playing music while people can navigate to other pages without interrupting the player. I've created the follow... | Child theme for TwentyEleven: create the child theme folder, <code> twentyhalf </code> create a <code> style.css </code> file with the content: <code> /* Theme Name: Framed Audio Theme URI: stackexchange-url 1.0 Description: Index page with framed content - one frame points to a parent page with the slug of 'sample-pag... | How to create a static player top or bottom of wordpress? | wordpress |
I'm getting an error on my site regarding "headers already sent": Warning: Cannot modify header information - headers already sent by (output started at ........./wp-admin/menu-header.php:161) in ....../wp-includes/pluggable.php on line 881 I read the Wordpress FAQ that discusses this, but - as you can see - this error... | Wordpress provides a way to prevent the header HTML from being rendered, by appending <code> &noheader=true </code> to the url. That will cause the header HTML to wait for you to call it manually, so that you can do a redirect before that. To later render the header HTML from your page, you'll have to use this: <co... | Headers already sent - Wordpress core | wordpress |
I've been trying to create a sidebar widget to display recent comments from specific category. I'm having difficulties in determining how Wordpress knows from which categories the comments are. I have checked the codex on <code> get_comments </code> function but it doesn't seem to allow fetching from specific categorie... | You could get your answer from Kovshenin blog Replace whole <code> if ( $comments ) </code> with this <code> if ( $comments ) { foreach ( (array) $comments as $comment) { $comm_post_id = $comment->comment_post_ID; if ( $category_name ) { if (!in_category( "{$category_name}", $comm_post_id )) { continue; } } $output ... | Recent Comments from Specific Category Widget | wordpress |
Is there a way to automatically insert the current user ID as the post category name or maybe have WordPress display only the post with a category name that matches the current logged user ID? <code> <?php $query = new WP_Query('category_name=current-user-id'); if($query->have_posts()) : while($query->have_pos... | You can get information on the currently logged in user using the get_currentuserinfo() function. For example: <code> <?php global $current_user; get_currentuserinfo(); $username = $current_user->user_login; $user_id = $current_user->ID; ?> </code> You can then use $username or $user_id in your custom loop.... | Logged in user ID as post ID | wordpress |
I have this on my <code> header.php </code> . It checks whether the page is on homepage/frontpage, is on category/children of/has the category of "gamenews", or is on category/children of/has the category of "hobbynews". Basically, if it's on homepage/frontpage, it outputs nothing. On the other hand, if it's on gamenew... | Assuming you're using the function is_category_or_sub() as given on http://valendesigns.com/wordpress/is-category-or-subcategory-wp-function/ That function takes category id as the argument, not the slug. The string "gamenews" here when type-casted to an integer becomes 0 which is an ancestor for every other category. ... | Why is the `if else` not working? | wordpress |
I seem to recall seeing a tip somewhere saying that it was a best practice to save a plugin's version number as an option. I'm working through releasing a plugin, and I'm considering whether to do it, but since all the plugin does is make a widget (right now, it literally has no other options), I'm struggling to unders... | You need to save the version to the database-- aka. save it "as an option"-- so that your script has a comparison case. That is, your script should... Check the database for a version number Compare that version number to the new version number-- a variable or constant in your plugin file. Update things if need be Save... | Save Plugin Version Number as Option? | wordpress |
I'm not quite sure how it works, if you're on a post (single.php), does it count page.php as the page it's on? What i need to do, is get a custom field assigned to a page, from a blog post. I need it because i want the user to be able to change the "Read more" text in the post excerpt. I could get the custom field by j... | I would suggest a different approach. The option for manually adding post excerpt should go in a theme option as opposed to a custom field. Also you should use this hook for modifying the excerpt's more text http://codex.wordpress.org/Plugin_API/Filter_Reference/excerpt_more If the user is supposed to enter custom exce... | Get custom field from page, in a post? | wordpress |
I have written a plugin which can store a table of technical specifications for each post (product) in an own database table. For the search function of the site I want to add a custom parameter to the array passed to <code> WP_Query() </code> . I have no clue where to register this custom parameter so that it is handl... | After further research I figured out a solution. Given the following <code> WP_Query </code> : <code> <?php new WP_Query( array( 's' => 'some keyword', //keyword criterion 'category' => 'some category', //taxonomy criterion '_spec' => 'some value', //custom criterion to be handled by the plugin ) ); ?> <... | Register custom query args parameter for WP_Query() | wordpress |
What I'm trying to do is getting Woocommerce categories and products randomly displayed on one page. The normal settings allow to display categories and products on the same page, but first come the categories and afterwards the products. This is the case because the categories come with the function <code> woocommerce... | as suggested by kaiser, my last working edit as solution: ok, inspired by @s_ha_dum answer i manged to get a solution: <code> //this 1. part is out of the woocommerce-template.php and part of the woocommerce_product_subcategories() $product_cat = get_term_by( 'slug', $product_cat_slug, 'product_cat' ); $product_categor... | Categories and products in random order | wordpress |
Typically I don't utilize comments on my sites, however I'm using the comments functionality as a sort of live-feed testimonials page. To do this, I've borrowed <code> comments.php </code> and the comments portion of <code> functions.php </code> from the TwentyEleven theme. What I'm currently struggling with is how the... | to remove it from the left. Delete the line containing <code> wp_list_comments </code> from comments.php to display user name add <code> comment_author(); </code> , for email use <code> comment_author_email(); </code> & for url use <code> if(get_comment_author_url()) comment_author_url(); </code> . <code> comment_t... | customizing TwentyEleven comments template | wordpress |
I have code in functions.php: <code> function string_limit_words($string, $word_limit) { $words = explode(' ', $string, ($word_limit + 1)); if(count($words) > $word_limit) array_pop($words); return implode(' ', $words); } </code> but i need to limit excerpt in number of characters, could you help me with that? | i used this code in one of my last projects: <code> function ng_get_excerpt($count){ $permalink = get_permalink($post->ID); $excerpt = get_the_content(); $excerpt = strip_tags($excerpt); $excerpt = substr($excerpt, 0, $count); $excerpt = substr($excerpt, 0, strripos($excerpt, " ")); $excerpt = rtrim($excerpt,",.;:- ... | excerpt in characters | wordpress |
Shortcodes are broken. For those of you playing at home, heres an easy step by step to replicate my problem. 1) Open a fresh Wordpress install (3.4.2). 2) Go into twentyeleven/functions.php and add the following: <code> function test() { echo '-TEST-'; } add_shortcode('testshortcode', 'test'); </code> 3) Edit the 'hell... | Shortcode callbacks have to return, not output. So use the following: <code> function test() { return '-TEST-'; } add_shortcode( 'testshortcode', 'test' ); </code> More info: http://codex.wordpress.org/Shortcode_API If you have to use echo you can also do it this way(useful if there's a lot of markup & it's difficu... | shortcodes output before content | wordpress |
I really, really don't get it. On my archive.php and category.php it doesn't find any content. I know the correct templates are loaded, but WP_Query just don't find any content. This is what i've got for archive.php: <code> <?php if($displayMobileTheme){ get_template_part('page', 'mobile'); exit; } get_header(); ech... | The <code> is_single </code> function (used in your excerpt.php file) returns true only when the main query contains one single post. Since you're calling <code> get_template_part </code> from an archives page, your query contains more than one post, so <code> is_single </code> returns false and your excerpt.php file b... | WP_Query() returns null when results exist! | wordpress |
I haven't set a limit to the number of revisions, which makes some of my post have more than 20 revisions, so how to delete these revisions? By the way, I am using WPMU and have many blogs, so how to delete WordPress revisions for all my blogs? | This is a much safer query to use and will remove related entries from the postmeta and term_relationship, unlike deathlocks query in his answer. Change the {id} to the id of each blog posts table. You can combine this query to run all the post tables at once, but try this on one table first. I've used it many times on... | How to delete post revisions? | wordpress |
I am currently trying to perform a custom query on the authors page (author.php). I have two custom fields for posts that I want to query against (post_photographer and post_videographer). What I am trying to do for the author's profile is get all the posts for the current user profile where the user is: the author of ... | For anyone who may have a similar need, I solved this the following way (on authors.php): First I get the author ID: <code> $author = get_user_by( 'slug', get_query_var( 'author_name' ) ); // ID is accessed this way: $author_id = $author->ID; </code> I then created a custom query: <code> $query = " SELECT p.* FROM $... | Author Page Custom Query WHERE author OR [post meta value] OR [post meta value] | wordpress |
I have no idea why, but recently, all new comments on my WordPress site have broken avatar image links. Here is a page that shows the issue: http://joshnh.com/2012/10/12/how-does-line-height-actually-work/#comments Any idea why this is happening? I haven't installed any plugins recently, so why has it started playing u... | Okay, so it turned out that the default path for the fallback image wasn't being set. I have fixed that (in functions.php) and it is working correctly! Thanks to @songdogtech for leading me down the right path. | Broken Gravatar images in comments | wordpress |
I'm writing a loop for multi post types with meta_key filters. The filters are inputs from visitors. When visitor click a link(filter), The form submitted and I get the filter. Now, should I just use <code> $query->set() </code> to change the query args, or should I submit new query? Currently I'm using this functio... | If you can alter a query before it runs, then do so and save the database some work. You might be able to alter the query with <code> query->set() </code> and if not you can use the <code> posts_where </code> , <code> posts_fields </code> , etc filters . It is hard to say whether any of that is best for you without ... | Use query-> set or make new query? | wordpress |
I want to create a $wpdb query that select the closest places (custom post type) near the current coordinates ($lat and $long) but I'm not able to get two custom field values simoultaneously (wpfc-latitude and wpfc-longitude)... how can i change my query to get also the longitude? <code> SELECT $wpdb->posts.ID, $wpd... | You are going to have to JOIN twice on the postmeta table. Something like: <code> SELECT $wpdb->posts.ID, $wpdb->posts.post_title, $wpdb->terms.name, wpcflat.meta_value AS latitude, wpcflong.meta_value AS longitude FROM $wpdb->posts /* First Join */ LEFT JOIN $wpdb->postmeta as wpcflong ON $wpdb->post... | Get multiple custom field values in a $wpdb query | wordpress |
Is there a way of obtaining the user ID of the profile being edited in <code> wp-admin </code> ? I know it's in the URL if you are editing a user, EX: <code> ./wp-admin/user-edit.php?user_id=427 </code> . Could always <code> $_GET['user_id'] </code> to retrieve the user's ID, but what about when you're editing your own... | There is a global variable called … <code> $user_id </code> available on that page. Always. From <code> user-edit.php </code> : <code> $user_id = (int) $user_id; $current_user = wp_get_current_user(); if ( ! defined( 'IS_PROFILE_PAGE' ) ) define( 'IS_PROFILE_PAGE', ( $user_id == $current_user->ID ) ); if ( ! $user_i... | How to obtain the user ID of the current profile being edited in WP-Admin? | wordpress |
I'm initializing a variable with a value in the header.php file. I want access to that value in footer.php, but it doesn't exist upon checking. Example: header.php <code> $status = true; </code> footer.php <code> var_dump( $status ); // is null </code> What's a best practice for doing something in footer.php, or other ... | Avoid global variables, they could be overwritten by other code. You could use a helper function with a static internal variable instead. Sample code: <code> function wpse_69365_var_storage( $var = NULL ) { static $internal; if ( NULL !== $var ) { $internal = $var; } return $internal; } // first call: wpse_69365_var_st... | How to pass code from header.php to footer.php | wordpress |
I need to run a function when a particular post or page is loaded. Is there any hook that lets me check whether a post is being displayed during page load ? | You can use the <code> wp </code> hook and check the <code> global $wp_query </code> object or any conditional. <code> function wpse69369_special_thingy() { if ( 'special_cpt' === get_post_type() AND is_singular() ) return print "Yo World!"; return printf( '<p>Nothing to see here! Check the object!<br /><... | Hook for post and page load | wordpress |
We have a multisite setup, the primary domain needs to have domain.com, www.domain.com and secure.domain.com mapped in wordpress so the primary site's content loads on them. The problem we are facing is everything except secure.domain.com works. secure.domain.com always ends up at: http://www.domain.com/wp-signup.php?n... | In the end I just added the following to .htaccess <code> RewriteCond %{HTTP_HOST} ^secure\.domain\.net$ RewriteRule (.*) http://www.domain.net/$1 [P,L] </code> This appears to be working fine, but I'm not sure of what types of unforeseen effects it may have if any. | How do I map a subdomain in wordpress to the primary domain in a multisite setup? | wordpress |
I'm new to wordpress and trying to make a theme. I'm using a jQuery filter script on a page of posts that filters the posts nested in an unordered list using the HTML data-attribute as a hook in the list items. I want to use each post's tags as the data attribute hook. I've looked up variations of the_tags() functions,... | Use <code> json_encode() </code> : <code> <li class="griditemleft" data-tags="<?php $posttags = get_the_tags(); $data = array(); foreach($posttags as $tag) { $data[] = $tag->name; } echo json_encode( $data ); </code> Later, in your JavaScript, iterate over the <code> li </code> items and for each item use: <co... | How do I list the_tags() into HTML data-attribute | wordpress |
I Have a Wordpress Site with few users who are my college students They Registered using their RollNumbers/HallTicket Numbers as their usernames in Wordpress site Now I Have Another Database with Their Personal Details like Marks, Rank etc Now I want to Integrate this Database to Wordpress so that when student/user log... | You can use <code> wpdb </code> class to query your custom data from MySQL. Depending on your implementation you would either use: global <code> $wpdb </code> object, if your custom data is in same database as WP itself new custom instance of <code> wpdb </code> class if you need to connect to different database for cu... | Integrating Custom Database with Wordpress | wordpress |
Is it possible to create a comment template for custom post types? I want the wording for comments on a custom post type to be different for wording on a regular wordpress post. I tried comments-posttype.php but that didn't seem to work. | In the single template of the custom post type i.e. "single-posttype.php" (create one if it doesn't exist). In the function <code> comments_template() </code> the first parameter represents the filename, so make it <code> comments_template('/comments_file_name.php'); </code> Reference- http://codex.wordpress.org/Functi... | Create a comments template for custom post types | wordpress |
Im trying add a credit link to the footer of all the WP sites i make saying: Designed by ... While this is simple enough, i want to code it so that if this link is removed from the footer, the entire site shows an error or doesn't load up etc. Any one have ideas? | While I believe the premise of this to be flawed and somewhat black-hat, it is a legit WP question albeit a futile exercise. You can do something like the following: <code> add_action('template_redirect', 'foobar_explode_if_no_citation'); function foobar_explode_if_no_citation(){ #Get the absolute server path to footer... | Credit link that if removed stops site from working | wordpress |
I have a custom post with a taxonomy associated to it. That taxonomy only has one term, and posts either belong to it or not, in a boolean fashion. On the search results, I wish to show the custom posts that belong to the taxonomy, and not show the ones that don't belong. I've thought of two ways of accomplishing this,... | After reading your revised question it was easier to comprehend what you are trying to do. My new solution looks like the thing you wanted to do in the first place: it just excludes all posts which are of your custom type but don't have the "yes"-term associated with it: <code> $custom_query = array(); $custom_query['p... | Exclude from search all custom posts which are NOT in a taxonomy term | wordpress |
I'm currently working on a site where there is extensive use of the popular Advanced Custom Fields plugin. However, as a result the page loading time can be quite slow, especially when using the Gallery plugin. Does anyone have suggestions regarding what the best practice is with managing a large number of custom field... | Performance optimization doesn't really work in vaccum, it takes hands-on profiling an looking for actual bottle necks (which often turn out to be different from perceived ones). But it general there are several approaches to the need of lots of database data: Optimize fetching from database, for example by concatenati... | Minimising number of queries on a page when using Advanced Custom Fields | wordpress |
I'm using the Rosario font from the Google Web Fonts in my theme and I want to enqueue the font so that if there was ever a plugin that used a fancy font that there wouldn't be any conflicts or wasted bandwidth. I want to use the Normal 400, Normal 400 Italic, and Bold 700 in my theme. How should I enqueue the font? Is... | You should be able to just use <code> http://fonts.googleapis.com/css?family=Rosario:400,700,400italic </code> which is the "combined" URL given by Google when selecting multiple weights/styles of a font. You can then just register the font once. You don't need to over-complicate the <code> $handle </code> either, some... | How Would You Enqueue A Google Web Font? | wordpress |
How in category.php to output a numbered list of links to pages like: 1 2 3 4 5 when the number of posts in the category exceeds the number of posts to display? | As an alternative to using a plugin like PageNavi(as suggested in another answer), you could also use a wordpress native function http://codex.wordpress.org/Function_Reference/paginate_links Though the plugin solution seems the easiest to setup | How to display numbered pages in a category | wordpress |
Is it possible to sort posts (custom post type) by category / taxonomy (name, desc)? For example my categories would be Season 2012 some post some post some post Season 2011 some post some post some post Season 2010 etc.. | One solution would be- <code> $terms = get_terms('taxonomy-name'); foreach($terms as $term) { $posts = get_posts(array( 'post_type' => 'custom_post_type_name', 'tax_query' => array( array( 'taxonomy' => 'taxonomy-name', 'field' => 'slug', 'terms' => $term->slug ) ), 'numberposts' => -1 )); foreach(... | Sort posts by custom taxonomy name | wordpress |
I am using woocommerce plugin for wordpress to make an eCommerce website. It is working fine with little bit customization. As I have configured shop page as the default product page so that in that page every product can be seen and a user can buy product from that page. But now I want to use some highlights image for... | You can add this to your body tag of your current theme <code> <body <?php body_class('class-name'); ?>> </code> and then specifically target the container. <code> body.post-id #yourdiv { border: 2px solid red; } </code> Always work for me. | Woocommerce product page is not showing custom css | wordpress |
I have made a page template which shows linked subpages using this bit of code: <code> <?php $mypages = get_pages( array( 'child_of' => $post->ID, 'sort_column' => 'menu_order', 'sort_or foreach( $mypages as $page ) { $content = $page->post_content; if ( ! $content ) // Check for empty page continue; $co... | Slightly modify these lines <code> $content = $page->post_content; if ( ! $content ) // Check for empty page continue; $content = apply_filters( 'the_content', $content ); </code> to <code> $content = $page->post_excerpt; if ( ! $content ) // Check for empty excerpt content & fallback to full content $content... | How do I modify this page template to show subpage excerpts (not post excerpts)? | wordpress |
I want to add a checkbox to Edit Post page in Wordpress admin and clicking on that checkbox should select all categories How can I do that? Image description bellow... | try this- <code> remove_meta_box('categorydiv'); add_meta_box('categorydiv', "Categories", 'mycustom_category_meta_box', null, 'side', 'core', array( 'taxonomy' => 'category' )); function mycustom_category_meta_box($post, $box) { $defaults = array('taxonomy' => 'category'); if ( !isset($box['args']) || !is_array(... | How to add “Check all” to Edit post page in WP? | wordpress |
I currently have a members area for subscribers. I have already setup the ability for users to 'favourite' posts and add them to custom folders of their choice. Once they have added some posts to a specific folder, I want them to be able to click download where it will collate that folders posts into a pdf. Doesn't hav... | I've managed to answer my own question. If anyone ever has a simular request, I have now implemented a pretty basic fix. I decided to download the simplest post2pdf plugin I could find. I settled on WP Post to PDF by Neerav Dobaria, based on the TCPDF script. The code is simplistic and tidy so it allowed me to customis... | How can I allow users (subscribers) to download selected posts into a single PDF? (RESOLVED) | wordpress |
Is there a function in wordpress that grabs all the users(user ids) who have commented on a post? I have the post id available. | The get_comments() answer by Poulomi Nag is correct. This will be somewhat more efficient. <code> global $wpdb, $post; $query = sprintf("SELECT user_id FROM {$wpdb->comments} JOIN {$wpdb->posts} ON {$wpdb->posts}.ID = {$wpdb->comments}.comment_post_ID WHERE comment_post_ID = %d AND comment_approved = '1'", ... | how to find user ids of all commenters in a post | wordpress |
Hi I developed a website in wordpress on my localhost then moved it to a live server. Everything is working fine except wp-admin. When I go to domain/wp-admin it shows a white screen. Yet when I go to domain/wp-login.php it allows me to login to the admin. Also if I try to create new post or update any settings it keep... | When you say moved WordPress, what do you mean exactly, Did you copy your entire WordPress installation from your localhost to your remote server without installing WordPress first on your destination host? Did you export your SQL database from localhost then import it to your remote server? Did you install WordPress o... | Moved wordpress from localhost to live and wp-admin shows white screen | wordpress |
Say a site has its main custom CMS on www. and a wordpress blog on blog. Up to now some really good reviews have been posted over years on blog. but believe now they would be best served on www. Is there a way to pull this content in all its glory and still use WP to power it behind the scenes but display on the www? N... | If you are moving content permanently to the CMS I would advise to actually move it, rather than fiddle with integration. Not worth the trouble for static move. As for redirect it is common use case and I would do some digging at <code> redirect </code> tag at official plugin repository . | Pull certain Wordpress posts on custom CMS instead and 301 wordpress to it? | wordpress |
I would like to display the author (username) of the latest revision of a post from inside the loop. I tried <code> get_the_author() </code> , which echoes the username and <code> $post->post_author() </code> , which returns the user_id, but both return the original post author and not the latest revisor . | Try <code> the_modified_author() </code> or <code> get_the_modified_author() </code> , this should give you the display name of the last user that modified the post. | Get the author of the latest revision | wordpress |
Ok i have this code currently. <code> <?php query_posts('category_name=widgets2'); echo "<div id='widgets-wrapper2'><div id='marginwidgets' style='overflow: auto; max- width: 100%; height: 450px; max-height: 100%; margin: 0 auto;'>"; while (have_posts()) : the_post(); echo "<div class='thewidgets2'>... | <code> the_content </code> echoes post content. It does not return a string that you can manipulate. You need <code> get_the_content() </code> Swap those functions and it should work. | wp trim function not working | wordpress |
I've just changed some titles of pages and child pages around, simply I've got Work as top level page, and Blog as a top level, with Play and Work as children. The paths are: /work/ and /blog/work/ However, if I create a menu directing the user to /blog/work/, either using a page tag in wordpress or a direct link it ta... | Afaik, you can't "fix" this, as this is the internal behavior of WP. You maybe could use some other slug like <code> blog-work </code> . Then go and redirect to your desired URI. | Two pages named the same thing, on a different level but conflicting url paths in menus and direct links | wordpress |
I am using Bootstrap with Wordpress and I want to implement the collapse functionality in the content for single pages of a specific custom post type. I know I could create a shortcode, however, with hundereds of posts shortcodes are not going to be ideal. Is it possible to include collapse in the_content of the custom... | The script First you have to enqueue the script. We conditionally load it only for your custom post type and its archive(s). <code> // in your functions.php function wpse69274_enqueue_tbs_collapse() { if ( ! is_post_type_archive() AND 'YOUR_POST_TYPE' !== get_post_type() ) return; wp_enqueue_script( 'tbs-collapse' ,get... | Twitter Bootstrap Use Collapse in Custom Post Type | wordpress |
I have a site that was migrated a week ago from Movable Type 4 to WordPress and ever since then, the posts are not getting indexed into Google News. We used the same meta key that we used on MT4 and we did not change the domain name in the migration. We did, obviously, change to pointer to our multi-site WP installatio... | In order to be indexed by google news you need a unique permalink structure containing a unique number. You seem to have a permalink structure of %postname% that doesn't contain a number. You could change your permalinks for example to %post_id%/%postname% or %post_id%-%postname% in order to comply with google news req... | Wordpress site running on Yoast not being indexed into Google News | wordpress |
I have seen many different parameters or arguments that can be passed to a query. For example, category_ in, category _and term_id to name a few. Some of these can be found by using print_r to print out the object. ( If I have that right ). Others like the category__in I have been unable to find in codex. Is there a tr... | They're all in the codex page for <code> WP_Query </code> . | documentation on arguements? | wordpress |
I'm trying to show profile fields with checkboxes and drop-downs in the members directory loop. Example: Next to each member in the directory I want to show the Gender they selected This code works for text fields: <code> echo xprofile_get_field_data('Full Name', bp_get_member_user_id()); </code> BUT how do I echo prof... | I believe xprofile_get_field_data is unserializing the data for you, but it is still in an array. xprofile_get_field_data can return an array or a comma-separated string. <code> xprofile_get_field_data( $field, $user_id = 0, $multi_format = 'array' ) </code> @param string $multi_format How should array data be returned... | Buddypress Add unserialized Profile Fields in Members Loop | wordpress |
The scenario a custom post type <code> wiki </code> a (hierarchical) custom taxonomy <code> topics </code> a page template <code> archive-wiki.php </code> The situation Posts show up and get ordered by <code> post_date </code> (which is the default). The according core query is: <code> SELECT SQL_CALC_FOUND_ROWS {$wpdb... | This query will handle two levels of hierarchy in your taxonomy. More than two levels of hierarchy and you'll need a recursive self-join. What this does is return the posts in the correct child within parent order. To create the appropriate parent level headings, you'll have compare the current post's parent taxon with... | Order posts by (hierarchical custom) taxonomy terms and term children | wordpress |
I want to use the Google+ and twitter links that can be added in User's profile using the WordPress SEO plugin and display them on the author page. Is there any way I can get those links from the plugin or do I need to fetch them using some other method say directly from database. SEO Plugin @the official repo | I found a way to do it in author.php file Just use the following to display the Google+ and Twitter links: <code> <?php $curauth = (isset($_GET['author_name'])) ? get_user_by('slug', $author_name) : get_userdata(intval($author)); echo $curauth->googleplus; echo $curauth->twitter; ?> </code> | Get the Google+ and Twitter links - Wordpress SEO plugin | wordpress |
I have added some custom user options to the profile page on my site, and most are all OK for the user to modify themselves. These options live in their own section. The users have read access and are able to visit the backend and change some settings in their profiles. There is another per-user option that I do not wa... | You should (if available) submit the code you are working with, even if just a snippet, so we can assess your process in relation to your question. The short answer however is YES , it is safe, so long as you, prevent input fields being displayed on user profile page for certain user roles prevent unauthorized users fr... | Is it safe to store a user setting you don't want the user to ever modify as a user option? | wordpress |
If you paste a Tweet URL to your post, Wordpress will nicely render it. But if I load posts via Ajax, the URL gets replaced by a Blockquote, but not with the nicely rendered one. The class of the Blockquote is <code> twitter-tweet </code> and not, as intended <code> twitter-tweet-rendered </code> with all that extra st... | ok, got it. Need to embed <code> <script src="//platform.twitter.com/widgets.js" charset="utf-8"></script> </code> manually And then fire <code> twttr.widgets.load(); </code> after appending the posts. Thx anyways, Rarst | Embedded Twitter feed won't render nicely when loaded via Ajax | wordpress |
I'm currently working on a gallery plugin similar to the one found on Posterous. I'm needing all images in the gallery in a very small thumbnail-size. Probably only 50px wide. What's the best practice to implement the image resizing? 1.) Adding the Image size via add_image_size()? This method has the obvious disadvanta... | Its best practice to always use internal WordPress API functions that already exist in place of external scripts. You would need to regenerate the thumbnails yourself, which is not overly difficult, if for instance you give yourself a head start and study the source code of existing and similar solutions; Regenerate Th... | Resizing Images for a Gallery-Plugin? | wordpress |
I have two forms. One for adding, one for deleting option values. Deleting and adding works, but I have to manualy reload page to see changes in select part. How to make theme apper after submit? <code> <form method="post" action=""> <input type="text" name="add" class="foo-add" /> <input type="submit" v... | Put the PHP code that handles data at the very top of the page before you print that data. | Select options not reloading after form submit | wordpress |
I've got an interesting issue with my blog page - Currently, I have two test posts- "Test Blog Post" and "Test Blog Post Deux." Test Blog Post displayed as it should, however when I added the second post(Test Blog Post Deux), the post content seemed to have overwritten the older content. You can see this in the post- t... | <code> the_title() </code> section is outside the loop which starts with <code> if (have_posts()) </code> consider reviewing: http://codex.wordpress.org/The_Loop http://codex.wordpress.org/Theme_Development | blog post displaying within older post - loop issue? | wordpress |
For some reason the $wpdb object is not being defined in one particular function. I have four other functions in the file that are using $wpdb and all are working fine except this one simple delete function where I get the error: Call to a member function query() on a non-object... The following is the function in ques... | Okay, new solution. First off, I'd recommend making the link a submit button and making the name something unique: <code> <submit name 'del_gallery' /> </code> Then in the code of your admin page: <code> include 'ga-functions.php'; //checks to see if certain button was pressed if(isset($_REQUEST['del_gallery'] &a... | $wpdb not being defined in function: Fatal error: Call to a member function query() on a non-object | wordpress |
I have added a custom taxonomy called 'Boards' with the following code <code> function add_custom_taxonomies() { register_taxonomy('board', 'post', array( 'labels' => array( 'name' => _x( 'Boards', 'taxonomy general name' ), ~snipped~ ), 'rewrite' => array( 'slug' => 'board', 'with_front' => false, 'hierarchical' => tr... | There are a few parts to making this work. First, we register the taxonomy: <code> function wpa69163_register_txonomy() { register_taxonomy('board', 'post', array( 'labels' => array( 'name' => _x( 'Boards', 'taxonomy general name' ), ), 'rewrite' => array( 'slug' => 'board', 'with_front' => false ) )); }... | Permalink Rewrite for Custom Taxonomy | wordpress |
I'm trying to us <code> get_option </code> in my plugin to choose to load 1 of 3 js files. I started with this (and it works) ... <code> add_action('wp_footer','isotope_vpl_set_style'); function isotope_vpl_set_style() { include("inc/myfile.js"); } </code> then I changed it to ... <code> add_action('wp_footer','isotope... | You had an extra <code> ( </code> before <code> get_option </code> and the if statement syntax was wrong. Here is the revised code: <code> add_action('wp_footer','isotope_vpl_set_style'); function isotope_vpl_set_style() { $style = get_option('damien_style'); if($style == "isotope") { include("inc/myfile.js"); } } </co... | using get_option to add a different js | wordpress |
I've recently seen a new bug appear on a site running WP e-commerce. New products (or certain existing products) get stuck as 'drafts'. Once they are marked as draft clicking 'publish' does not do any good, and the only way to make the products publicly accessible is by directly editing the entry in the MySQL database.... | You probably have some custom functions in your themes functions.php Add a <code> return; </code> on top of this file. If the problem is solved: Move it below the first function. Proceed this way until you've found the function that is causing the problem. If this doesn't work: Go and do the same for one template file ... | posts stuck as drafts | wordpress |
I want to connect two sites which are not on the same domain and allow uses to be logged in to both, by logging in to only one site. I found a huge number of topics and plugins but most of them deal with the subdomains of one parent domain (site1.domain.com and site2.domain.com) which is not what I want. Both sites wil... | Solution: two (same) custom plugins on both sites. Workflow to be triggered on successful login: generate hash and save in DB; expires after 30/60 seconds save initial destination redirect to the other site with ID; make necessary checks there - hash, IP etc. if everything is OK, login the user programmatically redirec... | Single sign on for multiple domains | wordpress |
I have a plugin which I need to include a file in but it doesn't include. Here's the example of the tree: <code> plugin folder /themes /folder2 /somefiles /includeme.php </code> Within themes is <code> /default /theme2 </code> Then within each theme are the files E.g. <code> Header.php Footer.php </code> The plugin sim... | In your main plugin file, use <code> plugin_dir_path </code> to define a constant that you can then use in all of your includes. see the example on the above codex page. <code> // define the constant in your main plugin file define( 'MYPLUGINNAME_PATH', plugin_dir_path(__FILE__) ); </code> then, to include your file: <... | Include files for a plugin not including | wordpress |
How do I approve a post directly from preview mode, instead of having to return to edit mode and/or "list of posts" mode? I'm script-matically uploading several (hundred) posts, but want to live preview them briefly before approval. | Here is something i have laying around: <code> <?php /* Plugin Name: Approve From preview Plugin URI: http://en.bainternet.info Description: Approve from privew is Plugin that lets yo approve posts (draft and pending) from the preview itself. Version: 0.1 Author: Bainternet License: Copyright 2012 Bainternet (admin@... | Approve post directly from preview mode? | wordpress |
I'm using the Fresh & Clean theme and I am wondering how to use this theme for blogging. The theme only shows a summary of a post, you can only show the full text by using excerpts which is a very cumbersome way to compose posts. Is there an another to post full text posts using this theme? | Your question doesn't actually make sense to me; but I think what you're saying is "the landing page for my blog only shows post excerpts, to show the full post I need to view a post as a single page; how do I show the full content of my posts on the landing page?" If that is indeed the case, you'll need to either crea... | How can I use the Fresh & Clean theme for blogging? | wordpress |
I'm displaying Wordpress menu using this function: <code> wp_nav_menu( $args ); </code> Menu is set in wp-admin/nav-menus.php. Can I somehow attach ID of my choice to one of the items? I want the menu to look like: [ Link 1 ] [ Link 2] [ LOGO (that is Link 3 also ] [ Link 4 ] [ Link 5] I know I could style ID of the lo... | Simply use the "Class"-field for styling. Give it a unique class, target it in your CSS file. Done. | Custom ID for certain menu item? | wordpress |
I am trying to make a function that will check the time associated with a future event (cpt) with the current time, to see if the event has past. When I first collect the time it is in seconds and I can then convert it easily with date_i18n() to whatever, but I am not sure how to compare that results with the wordpress... | <code> the_time() </code> doesn't return the current time, it returns the time of the current post, also it echoes the result. If you need the current time, simply use PHPs native <code> time() </code> function. | Comparing Time with the_time(); | wordpress |
currently i know how to make a jquery slider and pull images by get thumbnail . But is there any way to make a option (using custom post types/custom fields/meta boxes) to get a video by id and show that video in the slider? I have seen many theme developers are using flex slider and they included option for users to a... | You could just paste the video( not embed ) link from certain sites directly into the content editor, and wordpress takes care of displaying the video for you, and you don't have to store/serve the large video files on your server. Here's a good little write up on that: http://codex.wordpress.org/Embeds If you have som... | How to integrate video slide using custom post types? | wordpress |
Is there an argument for get_terms which I can fetch terms that only have say over 2 posts associated with it? I have a terms page which lists all my terms for 'artists', the page is huge but a lot of these terms that only have one post so I would like to show only significant terms. | Give: <code> $terms = get_terms("my_taxonomy"); $count = count($terms); if ( $count > 0 ){ echo "<ul>"; foreach ( $terms as $term ) { if ($term->count > 2) { echo "<li>" . $term->name . "</li>"; } } echo "</ul>"; } </code> a shot. It will grab all the terms and then run a check to se... | get_terms with more than x post count | wordpress |
I'm trying to make my links like this: <code> site.com/article-sample-post </code> as "article" is a fixed prefix and "sample-post" is the post slug.. but that prefix affect the category link structure making it : <code> site.com/article-category/sample-cat </code> which is not desired! my question: does there any simp... | If you want to remove the category base <code> /category/ </code> , you can install the WP no category base plugin which will add a new set of rewrite rules for categories. the side-effect of this is that you can set your post permalinks to <code> /article-%postname%/ </code> and it will no longer effect category perma... | prefix to post permalinks without affecting category permas | wordpress |
I wish to restrict the user posting a new article to select only 1 category for that post. It doesn't matter which category he chooses as long as he chooses just one. This way posts are maintained under a hierarchy (and I want to avoid users clicking all categories so that their posts appear everywhere). I don't want t... | I've solved this in the past for a client by using <code> remove_meta_box </code> to hide the default categories meta box, then adding my own meta box via <code> add_meta_box </code> which outputs categories as a drop-down select list, which effectively limits selection to a single item. | How to restrict user to choose 1 category for a post | wordpress |
I can't seem to find this anywhere, Is there a way to retrieve the URL of the post (which is of a custom post type) you are editing. Basically I want to somehow get the same URL that shows up like this: Permalink: (link to post) on the edit screen. | You should have the <code> $post </code> variable (you may need <code> global $post; </code> ) from which you can get the post ID ( <code> $post->ID </code> ). Then <code> $perm = get_permalink( $post->ID ); </code> should give you what you want. https://codex.wordpress.org/Function_Reference/get_permalink | Get URL of Post You Are Editing | wordpress |
I am changing my permalink structure from <code> /%year%/%monthnum%/%postname%/ </code> to <code> /%category%/%postname%/ </code> . Is it possible to redirect old links using old permalink structure to the new link? Possibly via the postname? | Wordpress should handle all redirections correctly, without you needing to worry about them. For example, if your old post was stackexchange-url ("http://example.com/2012/10/11/i-like-stackexchange") any links should auto-magically be redirected to stackexchange-url ("http://example.com/favorite-things/i-like-stackexch... | How to redirect to correct pages after permalink structure change | wordpress |
In my plugin, I'm rendering a shortcode with some inline JavaScript. Wordpress seems to hate the closing CDATA tag ( <code> ]]> </code> ), as it escapes it. I'm using CDATA blocks so as to render well-formed XHTML, which allows other processes to scrape the page content easily (legacy systems which suck and are beyo... | Look at the source of <code> the_content() </code> : <code> function the_content($more_link_text = null, $stripteaser = false) { $content = get_the_content($more_link_text, $stripteaser); $content = apply_filters('the_content', $content); $content = str_replace(']]>', ']]&gt;', $content); echo $content; } </code... | Prevent add_shortcode from escaping a tag | wordpress |
I am having a heck of a time getting wordpress to display all values of a certain meta key correctly. I wonder if I am going about this the wrong way? My end goal is to run a check to see if there is more than one custom field value in a key. If there is, each value should be listed with a comma delimiter, but no comma... | use php's <code> implode </code> to join array elements with a string: <code> <?php if( $bands = get_post_meta($post->ID, 'band') ): ?> <strong>Band:</strong> <?php echo implode( $bands, ', ' ); ?><br /> <?php endif; ?> </code> EDIT- another version of above, pluralizing the label... | Run a check for multiple meta key values | wordpress |
I'd like a way to target only blog-area pages for specific formatting. So far, <code> <?php if (is_home() || is_single() || is_category() || is_archive() ) { ?> </code> works okay, but is there a way to combine all of those into one single function to shorten it up a bit? so maybe in the functions it would set is... | Based on what you described: <code> function is_blog() { return ( is_home() || is_single() || is_category() || is_archive() ); } </code> And then just call the is_blog() function whenever needed. I also found this, which looks like a more specific way to do the same thing https://gist.github.com/1189639 | function to include is_home, is_archive, is_category, is_author etc in one function? | wordpress |
I would like to add a download button link for the full-sized image on the prettyPhoto lightbox when a user views a photo on my site. Currently I use the prettyPhoto Media plugin on my site, and I have also used this code (taken from this post ) in order to allow prettyPhoto to view a smaller image than the full sized ... | So the best option for me, being that I am not a programmer, was just to change plugins. I used this plugin and got the results I needed (it already has a download link). | Add Download Button in prettyPhoto Plugin | wordpress |
Hello everyone I am creating a theme dedicates to hotels display and booking in which I have created a custom post type 'Hotels' so now I want a mechanism to book the hotel rooms and a "book now" button in the hotel page to book the room which will send a request to the admin and also send an acknowledgement mail to th... | This is possible : you can fetch the comments form the database in the admin side in the same way you would do it on the client side with get_comments . Now the question is : where exactly, in the admin side, do you want to display you custom comments ? You can for example create a meta box in the Hotel edit page. Or y... | custom comments form for custom post type | wordpress |
On my main site I have used the search widget in the sidebar. However, the mobile theme I am using ( minileven ) already has a search box built into its menu bar. This results in a second search box in the sidebar (which appears after the post content) due to the widget. How do I stop the search widget appearing on the... | Add a class .hide with property <code> display: none; </code> - specify only for mobile viewports, not in desktop styles assign the class to your widget or to the entire sidebar, as needed | How do I stop a widget from displaying on mobile site? | wordpress |
I have a posts query that queries posts by ID but want to select those posts by enetering a custom field. Here is the query and where I want to put the custom field: <code> $query_args = array('post_type'=>'post', 'post_status'=>'publish', 'include' => '483,454, CUSTOM FIELD HERE', 'orderby' => 'date', 'ord... | I will assume that you(or users) will enter post ids into a posts custom field, comma separated, eg: <code> 11,13,34,54 </code> OR <code> 11, 13, 34, 54 </code> . Then all you need to do is get the custom field value for the loaded post, explode the custom field value by comma(,): and, then you'll have a nice array to ... | Custom field to array? | wordpress |
I want pass current user cookies in wp_remote_get function to get a Draft Post Preview page content. I check already the questions: stackexchange-url ("What URL do you pass to wp_remote_get to load the body of the current post's preview?") stackexchange-url ("How can I call "preview post" from wp_remote_g... | I rarely deal with cookies and not sure about complete mechanics there, but here is basic working example of passing current user's cookies to retrieve preview page source: <code> $preview_link = set_url_scheme( get_permalink( $post->ID ) ); $preview_link = esc_url( apply_filters( 'preview_post_link', add_query_arg(... | Passing current cookies in wp_remote_get to get Draft Post Preview | wordpress |
Here is my url to a custom type : <code> http://host/movie/my-slug </code> When I go to this link, I'm redirected to <code> http://host/movie/my-slug/?post_type=movie </code> which results in a 404 error. I use Rewrite Rule Inspector wordpress plugin for listing the matching rewrite rules. It appears that my url matche... | I think it matches the first one in the array. So you enter specific rules above more general ones. In your case it should be matching the movie rule if it has a lower array index number than the other ones. | How does WP handle multiple matching rewrite rules? | wordpress |
I think the problem essentially relates to sql query structure and I am not an expert.... I need to search for posts (custom post type) by 2 parameters: pd_city pd_country Please note that meta_query relation is 'OR' so if either of above two is LIKE we should have some results. Third key (is_sponsored) is used to sort... | The culprit The culprit of the matter is meta queries not supporting different and/or nested relations - a shortcoming by the way, that has driven me nuts before as well. In a recent instance with a search scenario also. What you want to do simply cannot be accomplished with <code> WP_Query </code> as well as one loop ... | Complex meta query with 3 keys | wordpress |
I have customised my menu in wordpress by extending the Nav_Menu_Walker class and now i cannot figure it out how could i add a class at a specific ul element. I have this function which adds classes by depth: <code> function start_lvl(&$output, $depth) { $indent = str_repeat("\t", $depth); if ($depth >= 1) $outp... | Count the level 0 elements in a static variable in the method and add an extra class if you hit the third. Sample code, not tested: <code> function start_lvl(&$output, $depth) { static $column = 1; $indent = str_repeat("\t", $depth); if ($depth > 0) { $output .= "\n$indent<ul class='subsubmenu'>\n"; } else... | Add a class at specific element in custom Menu Walker | wordpress |
I've been working on localhost and everything looks fine but then when I uploaded my Wordpress theme online, all of the jQuery plugin functions are undefined! One solution that worked (which I haven't tested a lot so I still don't know if it will work in the long run) is to import the javascript file from the plugin's ... | You can use <code> $ </code> but it is advised you don't. Use <code> jQuery </code> or something like the example in your link, if you must use <code> $ </code> you can do so like this; <code> $.noConflict(); jQuery(document).ready(function($) { // $() will work as an alias for jQuery() inside of this function }); //$ ... | "Conflict" with jQuery (or its plugins)? | wordpress |
This displays authors by date of their latest post. I'd like to: add formatting around each author list additional properties (avatar, latest post title and excerpt) <-- I have the bits for this, but not sure where to insert them here. <code> <ul> <?php //List of users sorted descending by date of latest po... | I'm finding it a little hard to follow based on your comments, however if you want to add a <code> <div> </code> around each other then change your second <code> foreach </code> statement to; <code> foreach ($uc as $key => $value) { $user = get_userdata($key); $post_count = get_usernumposts($user->ID); if (... | Add formatting to Array | wordpress |
What is the proper process for setting a page up with a link to it in the footer? Currently, all my pages are in Appearance -> Menu...and of course displayed in the main menu. However I want a batch of them to be in the footer. I have decent HTML,CSS, PHP skills but new to WP. | What may be easier (if you don't necessarily want all the same menu items to appear in the footer) is to: Create a new menu, "Footer Menu" for example Add-in whatever links (pages) are needed there Add a widget (called Custom Menu) to a footer widget position (if your current theme supports it). Let me know if that hel... | Setting a page link in the footer? | wordpress |
I have a link category with the id <code> $id=23; </code> and the slug <code> $slug=friends; </code> . I managed to read all links from that category using <code> get_bookmarks($id) </code> . Now I also want to use the name and the description ob the link category. How geht I get these values? I tried for example: <cod... | http://codex.wordpress.org/Function_Reference/get_term_by example: <code> <?php $link_id = 23; $link_category = get_term_by('id',$link_id,'link_category'); var_dump($link_category); ?> </code> | Get the name an the description of a link category | wordpress |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.