question
stringlengths
0
34.8k
answer
stringlengths
0
28.3k
title
stringlengths
7
150
forum_tag
stringclasses
12 values
My theme's <code> search.php </code> currently has a few "IF" statements to deal with the different types of search that my website uses. I have a site-wide search, a species (custom post type) specific search and an advanced species search. For the "species" search, I've simply added an input akin to <code> &lt;input ...
I ended up taking @Simon Scarfe 's advice using <code> get_template_part </code> . Just in case anyone ever needs it, this page (a work in progress) creates an advanced search form, then builds a WP_Query to search a custom post type: <code> &lt;?php if (isset($_POST["act"]) &amp;&amp; $_POST["act"] == "s") : ?&gt; &lt...
Customising wordpress search and using $_GET["s"]
wordpress
I have a wordpress site. Which has the built-in login form with the url http://domain/wp-login.php and register page http://domain/wp-login.php?action=register . As these pages have no sidebar and headers, therefore I want to display these forms on a page which I have created from the backend. Is it possible and how wi...
There are a couple of ways to do this. The most simple is probably to install a plugin, such as Theme My Login . The more complicated but flexible way to do it is to use <code> wp_login_form() </code> to output the form, presumably to a shortcode or something, and then you can style it yourself.
how to display the wordpress login and register forms on a page?
wordpress
I have been using settings API for my plugins for some time and it used to work well. Now it is broken and I can not figure out why. Apparently, the option validation function is not even called. Form data is properly sent and received, though. (Both figured out by <code> echo </code> resp <code> print_r </code> debugg...
<code> &lt;form action="" method="post"&gt; </code> should be <code> &lt;form action="options.php" method="post"&gt; </code> Must have overcompensated for something there.
Options don't save, validation callback not executed
wordpress
So the Next/Previuos on my index page is broken. It goes to page 2 but doesn't refresh the posts. It will work on my categories and it will work on my posts but it just won't work on the from page. Here's my code: <code> &lt;?php get_header();?&gt; &lt;?php include('from.php'); ?&gt; &lt;div id="content"&gt; &lt;div id...
I had the exact same problem a while ago on one of my themes. My problem was that the theme used <code> query_post </code> to filter out some posts. This caused the pagination to fail. I think this was the code that solved it: <code> &lt;?php if ( is_home() ) { $paged = (get_query_var('paged')) ? get_query_var('paged')...
Previous & Next on Index Page broken
wordpress
I have a problem. I've got a PHP script that tracks individual file downloads, and I'm looking for a way to display that number in individual posts. I've got a half-baked solution- a plain ol' MySQL manual connection script, but I'm trying to convert it to use as a Wordpress plugin (I want it to use WPDB). I've tried t...
Instead of using <code> $wpdb-&gt;query() </code> , use <code> $wpdb-&gt;get_results() </code> . This method allows you to specify a return type so the query is returned as an associative array. For example ... <code> $results = $wpdb-&gt;get_results( "SELECT * FROM mb_download_manager WHERE filename='" . $namemeta . "...
Help With MySQL to WPDB Query Conversion
wordpress
I am writing a theme and in it I have a function which creates two metaboxes. The forth parameter of the "add_meta_box()" function I used can be set to ( high, core, default or low). I want the boxes to appear in a particular order ( ie order within one of these 4 groups - eg with both metaboxes being set to 'priority'...
In you PhpMyAdmin query for: (if you have a different database prefix, change that in the query, also change the user_id to yours) <code> SELECT * FROM `wp_usermeta` WHERE `user_id` =1 AND `meta_key` LIKE 'meta-box%' </code> Than delete those values and you will get the original order back. If you only want to change t...
Reset positions of metaboxes in admin
wordpress
I need to unregister all the default sidebars in the Twenty Eleven theme so I can add custom left and right sidebars via the functions.php file in a child theme. This function below is for Twenty Ten; but I don't know where to find the correct strings for the widget areas for Twenty Eleven, which are called Main, Showc...
Found the answer elsewhere: <code> //Remove all Twenty Eleven Sidebars add_action( 'after_setup_theme','remove_twentyeleven_all_widgets', 100 ); function remove_twentyeleven_all_widgets() { remove_filter( 'widgets_init', 'twentyeleven_widgets_init' ); } </code>
Twenty Eleven unregister all default sidebars?
wordpress
I have a custom post type which uses dates and i have my custom columns set up in the admin. I need to be able to do order by that column by default - i have tried this code which I found on the net but after playing with it for an hour i still couldn't make it work and it only seemed to want to sort by title; can anyo...
I had to do this on a program management system. this should do the trick. <code> add_filter( 'pre_get_posts', 'my_sort_posts_listing' ); function my_sort_posts_listing( $wp_query ) { if ( is_admin() &amp;&amp; $wp_query-&gt;get( 'post_type' ) == 'my_post_type' ) { $wp_query-&gt;set( 'meta_key', '_my_date_meta' ); $wp_...
Managing event dates vs published dates in admin custom post type
wordpress
I would like to let users of one of my WP projects to cast votes on certain post types; the type of votes cast should differ slightly according to post type. For example for one post type they might vote for things like "money value", "quality", "comfort" (imagine a hotel...) for other things they might cast votes for ...
i wrote this plugin a while back for a client and never got around to polishing it off for general release. https://github.com/dwenaus/bp-rate-vote-like-anything Myself and another developer plan to launch it soon. But even as it is now, it's totally solid and very cleanly coded. I wrote it because GD Star Rating plugi...
Advice for a voting / multiple rating plugin for post types other than GD Star Rating
wordpress
Is there any way that I can add a short message to the custom posts type page in - ie the page where the posts are listed. I have checked the codex and searched the web to no avail.
Good question. I've often wondered it myself. This will work. You just need to change my_post_type_slug to the slug of your post type. There might be a cleaner way to find the post type other than using $_GET but it's good enough for now! <code> add_action('all_admin_notices', 'my_admin_notices'); function my_admin_not...
Message on Custom Posts Type admin page
wordpress
[NOTE] I had asked this question in wordpress.org's support forum one month ago. But I didn't get any feedback there. And I am not sure whether or not this is right place to ask this question. But I hope there are developers from WordPress on StackOverflow to look at my question and give me some hint. My problem is : F...
Well, someone has to be hosting it, so I recommend tracking them down. I've taken the liberty of doing this for you (using WhoIsHostingThis? ). Your host is IX Web Hosting , contact their customer support and see if you can either get them to do the upgrade for you or, preferably, get them to give you admin access to y...
"WordPress installations is currently out of date" problem with difficult situation
wordpress
I want to select some tags with the same term_group, I tested it in phpadmin, the query get the correct result, but once add $wpdb flavor, it returns an empty array. Any advice? <code> $primary_tag_id = // a function to return term_group, result is 3, comfirmed $terms = $wpdb-&gt;get_col( $wpdb-&gt;prepare( "SELECT nam...
Try this, it worked for me: <code> global $wpdb; $terms = $wpdb-&gt;get_col( $wpdb-&gt;prepare( "SELECT name FROM {$wpdb-&gt;terms} WHERE term_group = %d ORDER BY name ASC", primary_tag_id )); </code> What you are after is <code> $wpdb-&gt;terms </code> not <code> $wpdb-&gt;wp_terms </code>
What's wrong with this wpdb query?
wordpress
Did some research, but I was unable to implement it after all. I have a custom post type accessible only by a new role. I want to filter the post type listing so that each user should see only his records (as Author users can see their posts only). I've tried to filter parse_query but it works for the main listing only...
pre_get_posts is correct. the code from will prevent any non-admin from seeing anyone else's posts. http://blog.rutwick.com/display-only-the-posts-authored-by-the-current-wp-user-on-the-posts-page-in-the-back-end to limit that to only 1 post type you'd add in one more condition and check $typenow == 'your_custom_post_t...
Filter dashboard custom post listing by user
wordpress
Have had an autocomplete field working for months but has stopped working when not logged in? Not sure when but within the last few days or week (not updated wordpress recently). already have; add_action('wp_ajax_filter_schools', 'filter_schools'); add_action('wp_ajax_nopriv_filter_schools', 'filter_schools'); in funct...
Edit: I've kept my original answer below, however, I'm not sure what I was thinking... You should never need to trigger <code> do_action( 'wp_ajax...' ) </code> . While I can't be sure what the issue is, is the code in the question is roughly ok (I think <code> $_POST </code> should be <code> $_GET </code> with <code> ...
ajax stopped working when not logged in?
wordpress
I'm trying to hide specific categories from showing up on a portfolio home page. I was told that this was the concerned line of code on the php template file <code> &lt;span class="entry-skills"&gt;&lt;?php the_terms($post-&gt;ID, 'skill-type', '', ', ', ''); ?&gt;&lt;/span&gt; </code> but there is no way to exclude ce...
I haven't tested this, so it might need to be tweaked (specifically, I'm not sure if I got the names of the params right on the term object), but this should get you most of the way there. <code> //add filter add_filter( 'get_the_terms', 'my_exclude_terms', 10, 1 ); //function to do filtering function my_exclude_terms(...
hide specific categories from showing
wordpress
I have this custom post query to list all the posts within a specific category. For example I have this: <code> $args = array('cat' =&gt; 'home','post_type' =&gt; 'post')); $post_obj = new WP_Query($args); while($post_obj-&gt;have_posts() ) : $post_obj-&gt;the_post(); // do stuff here endwhile; </code> So for this page...
You can use <code> get_comments </code> . Function Reference/get comments <code> $args = array('cat' =&gt; 'home','post_type' =&gt; 'post')); $post_obj = new WP_Query($args); while($post_obj-&gt;have_posts() ) : $post_obj-&gt;the_post(); //display comments $comments = get_comments(array( 'post_id' =&gt; $post-&gt;ID, '...
How to get comments by post ID?
wordpress
I have an interesting problem I am trying to solve here regarding a custom nav menu. Essentially, I have created a custom walker class for my nav menu and I have manually added a menu entry directing users to "/articles" which is a custom post type archive page. (BTW, as far as I know there is no way to have these cust...
When i want to add the classes current-menu-item and current-page-ancestor i always use the wp_nav_menu without any custom walker. I only build my own walker if i want to change lets say the classes to something like "sel" instead. So i add the menu like this: <code> &lt;?php wp_nav_menu( array( 'theme_location' =&gt; ...
Custom Post Type & Custom Menu Walker to append custom class for active post types
wordpress
I am facing a problem. I am not getting the snippet which YOAST plugin showed me. The snippet in Google search is different from what YOAST is showing. Check out the screenshots ( http://imgur.com/a/ko5lQ ). Let me know what is the solution of it?
It is suppose to work this way. Joost's plugin only gives you a great tool for you to optimize your snippet. If you haven't done any optimizations whatsoever, like creating an awesome brief description of what your content is all about, Google will probably try to figure out what's the best bit of content by their own....
Yoast's WordPress SEO plugin is not showing the correct snippet
wordpress
right now I have two foreach arrays - one outputs the artist, the other a track title I would like to combine both so there is a row for each artist and corresponding track for example: Row 1 - Artist 1 Track 1 Row 2 - Artist 2 Track 2 <code> &lt;?php // Get duplicate fields $duplicate_field = get_post_custom_values('A...
if the artist names and track names are in matching order and the same in number then: <code> &lt;?php $artists = get_post_custom_values('Artist', $post-&gt;ID); $tracks = get_post_custom_values('Track', $post-&gt;ID); $i=0; foreach ( $artists as $key =&gt; $value ) { $class = ( $i % 2 ) ? 'alternative' : ''; // modulu...
Combine two foreach Arrays into one table row
wordpress
Good to hear that Sonny (wordpress3.3) has the new editor API wp_editor() that gives us the ability to use multiple instances of the editor in our custom fields with ease. But I needed to customize the default editor (for the main content) and couldn't figure out how to do it with this function. I needed to customize t...
I was looking for a solution to place custom metabox above the default editor and i've found the solution to my old question (how to customize the default editor with the wp_editor)! The solution was to unset the default editor first. Then create another metabox to to place the content then use wp_editor to create new ...
How to customize default wordpress editor?
wordpress
Example: https://github.com/markjaquith/WordPress/blob/master/wp-content/themes/twentyeleven/single.php Isn't single.php's purpose to show single posts?
The idea is to ensure that all the content is displayed properly. Some functions are not available outside of The Loop, as it's called, so depending on what you are doing, it may be advantageous to start the loop, even if you're relatively certain it will only be used for one post object.
Why do themes have `while( have_posts() )` in templates like single.php?
wordpress
I'm trying to create a new role within my wordpress theme that has almost all the same rights as an admin. Basically, it's a cross between Editor and Administrator. One of the issues I'm having is allowing the Editor to "see" the add custom image header submenu in Appearances. I either want to allow the Editor to see t...
For a list of capabilities by user level, check the Roles and Capabilities Codex page . The capability that would allow a user to change a theme header would probably be <code> edit_theme_options </code> , but I bet it would give your editors more capabilities than just messing with the header, though. It's hard to say...
Removing capabilities from cloned admin role
wordpress
Is there a way to get attachments by user? I need a way to display all the images uploaded by a specific user. (I probably need the attachment IDs so that I can use <code> wp_get_attachment_url </code> to display them.)
Use a custom query for this . <code> $user_id = 1; $the_query = new WP_Query( array( 'post_type' =&gt; 'attachment', 'post_status' =&gt; 'inheret', 'author' =&gt; $user_id) ); if ( $the_query-&gt;have_posts() ) while ( $the_query-&gt;have_posts() ) : $the_query-&gt;the_post(); the_title(); endwhile; </code> This will s...
Get attachments by user
wordpress
Anyone know if it's possible to create something similar to the wordpress built in tag cloud (wp_tag_cloud) but instead of displaying tags, display custom post types? Thanks
How about the <code> wp_generate_tag_cloud() </code> function? You'll need to feed it <code> $tags </code> , which is an array of objects with the link and term_id, set something like this. <code> $tags[]-&gt;link = $link; $tags[]-&gt;id = $tag-&gt;term_id; </code> The term_id will only be used in the CSS...so don't sw...
Post type cloud like tag cloud?
wordpress
I Just need some correct results from 6 rss feed I am fetching 6 feeds and maked a news ticker bar at <code> http://thehoopdoctors.com/online2/newfeed/ </code> I am getting results from 6 rss feeds like First getting all posts from <code> http://thehoopdoctors.com/online2/newfeed/", </code> Then All <code> "http://thep...
What you're looking for is probably something along the lines of: <code> &lt;ul id="news-ticker" style="float: left;height: 15px !important; margin-left: 2px; margin-top: 10px; overflow: hidden; position: relative;width: 500px;"&gt; &lt;?php $rsslist = array( "http://thehoopdoctors.com/online2/newfeed/", "http://thepig...
Need correct results from 6 rss (fetch_feed)
wordpress
I am currently writing phpNuke import Wrdpress plug-in. I have a problem with importing posts with images: + I already had written a routine which extracts image tag text and images from source post HTML - I need to replace <code> img </code> tags with the ones imported to wordpress media library. Example: phpNuke post...
My first suggestion is to output a WXR formatted file from phpNuke if possible. I'm not familiar with it, however I'm pretty sure it's possible on any platform with database access. If you aren't familiar with WXR, install a sandbox WP environment, create a few posts, categorize them, create and assign parent pages, up...
How to replace post image url before posting using api?
wordpress
I wish to return a WP user list in my plugin where the email address matches @mydomain.com. The user list I am after is for all mydomain.com users. Does anyone have a code snipit for that? Thanks.
The search parameter can take an email address and can also accept wildcards: <code> $wp_user_search = new WP_User_Query( array( 'search' =&gt; '*@mydomain.com' ) ); $users = $wp_user_search-&gt;get_results(); </code>
WordPress WP_User_Query($args) using Where and Like
wordpress
The goal- include my-script.js (dependant on jquery) in my WP theme. The problem- When I use this code,(in the head element of the header template file) my entire page goes blank when loaded: &#60;?php wp_enqueue_script( 'jquery' ); ?> &#60;?php wp_enqueue_script( 'my-script', "&#60;?php echo get_template_directory_uri...
You don't need to enqueue jquery if it's already being referenced in my 'my-script'. Also you're running php within php, so you can change this: <code> "&lt;?php echo get_template_directory_uri() . "/my-script.js"?&gt;", </code> to <code> get_template_directory_uri() . "/my-script.js", </code>
wp_enqueue_script causes page to vanish
wordpress
Let's say I have a category named "Hidden". I'd like to prevent all posts in "Hidden" from appearing within The Loop on the main blog listing page. Also, I'd like to prevent those posts from appearing anywhere else (category listing pages, archives, etc.) However, I'd still like the posts to be accessible via their per...
Answering my own question here: Is it really as easy as including this within a pre_get_posts filter? <code> $query-&gt;set('category__not_in', $term_id); </code>
How do I hide posts in a category from all listings but still allow the posts to be viewed?
wordpress
So I'm a little confused with this one. A blog I recently set up makes plenty of use of custom post types and custom taxonomies. In the reading settings the blog posts to show is at 100 but I can find no where to tell taxonomy pages to show 100 posts and they are stuck at 10. How do I change it without messing around w...
I fixed the issue by removing the taxnomy.php page and let it fall back to index.php
Taxonomy template shows only 10 posts
wordpress
In the latest WP the admin interface is changed and you have a popup submenu. I really liked the old version better with expandable menu. Is it somehow possible to get that back again for all users?
Yep, believe so. Try this (enqueue in admin styles): Show sub-menus at all times <code> #adminmenu .wp-submenu, .folded #adminmenu .wp-submenu { display: block !important; } </code> Hide Pop-up Navs <code> .wp-submenu.sub-open { display: none !important; } </code> That should get you started with it, otherwise you can ...
Turn on again old expandable menu
wordpress
Many plugins require configuration with sensitive data such as API keys, passwords, etc. When implementing these plugins, this sensitive data is stored using functions such as <code> update_option() </code> and <code> get_option() </code> . It would be trivial to write a trojan plugin that provides a useful function bu...
Actually, there's not too much you can do. If an intruder has direct access to your site - where they can run <code> get_option() </code> or perform direct SQL queries - then you've already run into a problem. The safest bet here is to exercise your best judgement when installing new plugins. In other words, the best p...
How to prevent plugins from sniffing/stealing other plugins' options?
wordpress
I would like to prevent Twenty Eleven from changing to mobile version when seen on an iPhone. Any way of doing this?
You can remove everything following the line <code> /* =Responsive Structure ----------------------------------------------- */ </code> up until in the style.css for Twenty Eleven <code> /* =Print ----------------------------------------------- */ </code> and it will get rid of all the media queries which are based on ...
Twenty Eleven Theme Adjusts for iPhones. How to stop this feature?
wordpress
I want to get the full local filename of an uploaded image so that I can copy it to a new directory and process it with my own image processing scripts. Which hooks/actions should I look into to achieve this? Thanks
The <code> handle_upload </code> hook is called after wp_handle_upload is run, and it sends in a named array consisting of 'file', 'url' &amp; 'type'. You could possibly use code like this to utilise it, depending on what you need to achieve: <code> function process_images($results) { if( $results['type'] === 'image/jp...
Hook to get image filename when it is uploaded
wordpress
Not sure how hard this is but i'll try and explain it as simply as possible. I have a custom post type called: "Movies" with an taxonomy term called "Actor" For example purposes suppose were on the taxonomy page "Tom Cruise" which will output a load of posts(movies) that Tom has been in. What i'm trying to work out is ...
Just banged this out real quick, it should be a start at least. The basic concept here was to get ALL the posts tagged with the main person (in this case, Tom Cruise, you'll have to setup that variable on your own. Once you have those, iterate through them, and <code> foreach </code> movie (Top Gun, Tropic Thunder, Mis...
Related terms - Terms that feature in post of current term
wordpress
Basically I'm putting together a magazine site that wants a strong focal point on the homepage for users who haven't signed up, if the user is logged in we need this content to show something else, is this possible? Basically I need a function to show X if the user is logged in and if not to show Y, the code will be pl...
Yes it's possible, just use the is_user_logged_in() function as descibed in the codex for this. It would go like this: <code> &lt;?php if ( is_user_logged_in() ) { echo "you are logged."; } else { echo "You are not logged"; } ?&gt; </code>
Is it possible to display a DIV to not logged in users and then change it for users who are logged in?
wordpress
I am building a child theme based on Thematic. Rather than use widgets, I would like to hard code my sidebar but I can't figure out how to do this. Any help appreciated! Thanks
You can... 1. Enter your sidebar.php file and remove everything.. (better to just remove the code that calls the widigtized sidebar see examples) example 1 (it might look like this): <code> &lt;?php if ( function_exists('dynamic_sidebar') &amp;&amp; dynamic_sidebar('pages') ) : else : ?&gt;&lt;?php endif; ?&gt; </code>...
How can I hard code my sidebar?
wordpress
I design my site in win7 system, and today before a server rent, I moving my blog from win7 to my another computer witch is installed CentOS 5.5 for a last test, I have reference the article http://codex.wordpress.org/Moving_WordPress moving my site from <code> d:/www/ </code> to <code> /var/www/html </code> , and my s...
I have solved this strange problem by myself. Share my experience to all. Find these 2 lines in <code> /etc/php.ini </code> <code> upload_max_filesize 16M post_max_size 16M </code> Add common before, so that change as: <code> ;upload_max_filesize 16M ;post_max_size 16M </code> And final, do not forget restart apache: <...
moving server can not login
wordpress
I would like to redirect all login and signup links to an external site. I would prefer to do this in a plugin, or somewhere that isn't affected by WordPress upgrades or theme changes. What is the best way? Thanks!
I solved this problem by putting the code below into a plugin. <code> class My_Class { public static function go_to_login() { global $pagenow, $theme_my_login, $redirect_to; if ( 'wp-login.php' == $pagenow ) { $url = ( false === strpos( $redirect_to, 'wp-admin' ) ? $redirect_to : site_url() ); wp_redirect( 'http://www....
Change All Login/Signup Links in Plugin
wordpress
I'm using wordpress multisite. I installed Multisite user management plugin. If a user register in my main sites then that user automatically added in all my sites. My problem it doesn't copy the profile datas. I don't want my users to fill the same data in all 50 sites. So is there any code available to sync the datas...
This code works, but please note that it is provided as is. It had only been tested in a localhost development. There's a function extracted from the plugin Multisite User Management , which is based on the <code> get_blog_list </code> function, that has been deprecated. No alternative available. For performance reason...
How to synchronize user profile fields in multisite?
wordpress
I am considering moving away from Drupal and drupal-cod due to the lack of good themes. The two major features I am looking for are: Ticket sales (PayPal), with receipts sent to attendee Sponsorship sales (PayPal with different options: Gold, Silver, Bronze by price-range) Secondary features: StackOverflow style forum ...
I recently used http://wpeventticketing.com/ for WDC2011 in October, I didn't look to far in to all the options but I think it can do everything you're looking for. I'd suggest also using MailChimp for emailing attendees as it is far better than anything I've found to plugin to WordPress.
Conference website with ticket-sales + sponsorship sales with WordPress?
wordpress
I have searched alot for finding the list of Full documentation for buddypress Hooks (action, filtrs) and functions but not satisfied with that limited documentation provided by Buddypress . Like if i want to find the detail about bp_directory_groups_search_form() there is no specific detail about this mehtod and same ...
and here is the almighty output for buddypress 1.5.2! <code> bp_activity_setup_globals bp_activity_setup_nav bp_activity_directory_activity_setup bp_activity_screen_my_activity bp_activity_screen_friends bp_activity_screen_groups bp_activity_screen_favorites bp_activity_screen_mentions bp_activity_screen_notification_s...
Buddypress Full documentation
wordpress
I am using a custom post type + taxonomies in a podcast solution for a client. The setting (settings > > discussion) for comments is set to "allow comments". When I add / edit posts under the "posts" tab, comments are enabled by default. However, when I add / edit posts under the custom post type (podcast) - comments a...
Ok - so I solved this. Here is what appears to be the problem. Comments are disabled by default for custom-post-types. This happens even if you have them enabled in the overall settings To fix it, all I had to do was the following: In SETTINGS > DISCUSSION uncheck the "Allow people to post comments on new articles" set...
Why are the comments disabled by default on my custom_post_types?
wordpress
The following is not working to call posts from a specific category and only grab the number of posts selected. I'm using more than one loop on a page as I am using this to create a "featured content" section on my homepage. <code> &lt;?php ('cat=111&amp;posts_per_page=1'); if (have_posts()) ?&gt; &lt;?php while (have_...
You're not actually running any queries. Need to run wp_query() , query_posts() or get_posts() . All are covered in great detail within the codex. Though you already have your parameters listed up ;)
Calling Posts from Specified Cat
wordpress
I'm using heavily-customised WordPress to drive a fishkeeping website. I have two separate search areas: a site-wide search and a fish species search. The latter also has advanced search features which will search certain meta values in the "species" custom post type (to allow users to search for fish that can be kept ...
Looking on line 1857 of WP_Query's code , it seems as though sanitization is done for you, so just run with whatever search term is put in. Current version of wordpress is 3.3, in case the code changes down the line.
Sanitizing search data for use with WP_Query
wordpress
I have a subdomain network installed at, say http://example.com . I need to have my webmail running at http://webmail.example.com . When I go to this domain it redirects to a page for creating a new site: http://example.com/wp-signup.php?new=webmail . I know there are some entries WP uses in the .htaccess file, but how...
I found this article: http://codex.wordpress.org/Configuring_Wildcard_Subdomains_for_multi_site_under_Plesk_Control_Panel I had used it originally when setting up the wildcard subdomains on my Plesk server. At first I didn't need to worry about the webmail section, but now I do, and here's what I did: <code> $ cd /etc/...
In a subdomain network, what .htaccess settings can I use to have WP ignore requests to one subdomain?
wordpress
I might be thinking too hard about this problem and i'm thinking the solution might be easier than we're i'm heading. Here's what i'm trying to accomplish: there a winery website built on wp and uses custom post types for "Wines" -> every wine has it's own description, picture, etc (cabarnet 2005, cabarnet 2006 etc...)...
You can have a look at this plugin: Custom Post Types Relationships (CPTR) . It lets you create relationships between posts, pages and custom posts types. There is also the Zig connect plugin that has a very nice feature of reciprocity (no need to edit the second post, it will automatically be related to the first one)...
Is it possible to associate different kinds of custom post types one to the other?
wordpress
I noticed (using Little Snitch) that WordPress' installer calls a distant Web page when installing ( <code> api.wordpress.org </code> ), why is that?
Ok, just browsed through the source code for <code> wp-admin/setup-config.php </code> :) Apparently the distant call is made to generate SALT secret keys: <code> $secret_keys = wp_remote_get( 'https://api.wordpress.org/secret-key/1.1/salt/' ); </code> Calling this URL generates code like this: <code> define('AUTH_KEY',...
Why is WordPress' installer "phoning home" during the install script?
wordpress
I would like to build a mobile version of my WordPress site. To avoid the problems and costs with developing for native platforms, I'd like to go for an HTML/CSS/jQuery approach that would be accessible from the Webkit browsers. The main site is already developed in WordPress, and content can be directly taken from the...
Have a look at the WordPress Mobile Pack plugin. Amongst many features, it allows you to map a (sub)domain to another theme.
Developing mobile version of WordPress site
wordpress
I have embedded a Google Map iframe in my theme and I'm trying to center a Google Map location in the middle of the map. All works fine except that my location is always shown to the upper left corner not the center This is my website: http://tommelopp.no/kontakt/ The pop up is made using javascript to center it. Happy...
I googled some more and found out that the problem was that the <code> &lt;div&gt; </code> element containing the iframe was <code> display:none; </code> in my css. My solution to this problem was to insert the iframe using jquery after i change the display type to block (also using jquery). Hope this helps someone els...
Google map iframe into wordpress theme
wordpress
I have a page on my site that lists all posts for my custom post type 'Literature'. However when I click on one of the posts, the highlighted active menu item changes to 'Blog'. How do I assign these posts to the menu item 'Literature'? Thanks
You should use wordpress's built in menu manager for this, along with a specific template file for listing the custom post types (for instance template-literature.php).
current_page_item and custom post type?
wordpress
I have in my themes some code which will set a session variable. For the sake of example, it's a geolocation routine which will set to either USA, UK or ROW, resulting in: <code> $_SESSION['region'] = 'USA'; </code> and I have a custom taxonomy of 'regionok' which any or all of the same terms are set. I wish to use the...
If you want to apply this term filter to all queries on the site, then you'll want to use the 'parse_query' action. This action will accept the WP_Query instance as a parameter, which will allow you to add a term filter based on the $_SESSION variable.
Replacing a placeholder term with a session variable value in taxonomy filter
wordpress
I'm trying to determine the best way to expand on WP. I love the base of WP for a website... it has pretty much everything needed for a website. But now and again I need to be able to create some custom "pages" or small apps within the WP framework. For example, I've created a small app within a sub-directory of my WP ...
I think you could do that by creating a plugin that you can integrate into a page. E.g. mingleforum uses a shortcode, which you can use to create the forums. You create a page, with the URL you want, e.g. "CUSTOMAPP" page with URL "example.com/customapp", and then within that page use the shortcode to instantiate your ...
Custom Module, Extending WP with a Plugin?
wordpress
I want to create a custom rss feed <code> &lt;?php /* Template Name: Custom Feed */ function filter_where($where = '') { //posts in the last 30 days $where .= " AND post_date &gt; '" . date('Y-m-d', strtotime('-2 days')) . "'"; return $where; } add_filter('posts_where', 'filter_where'); $args=array( 'post_type' =&gt; '...
Never tested this ,but i believe you need to add WHERE clause to your query with time difference like so : <code> $timediff .= " AND post_date &gt; '" . date('Y-m-d', strtotime('-2 days')) . "'"; </code> you can find it also in the codex http://codex.wordpress.org/Class_Reference/WP_Query#Time_Parameters If you do not ...
Collect posts from last 48 hours
wordpress
I couldn't add defer tag in plugin javascripts. Google developer pagespeed test suggests me to add defer tag in contact form 7 javascripts. This is how contact form 7 includes javascript in header. <code> add_action( 'wp_enqueue_scripts', 'wpcf7_enqueue_scripts' ); function wpcf7_enqueue_scripts() { // jquery.form.js o...
There is no dedicated filter available … at least I cannot see one. But … <code> wp_print_scripts() </code> calls <code> WP_Scripts-&gt;do_items() </code> which calls <code> WP_Scripts-&gt;do_item() </code> which uses <code> esc_url() </code> which does offer a filter: <code> 'clean_url' </code> . And here we go: <code...
How to add defer="defer" tag in plugin javascripts?
wordpress
I have a custom taxonomy called 'product_type' and a a custom post called 'product'. I have a cron job that is pulling in data from an external system and adds products as custom posts using <code> insert_post($post) </code> . This returns the post id. I now need to assign the product to the 'DVD' product_type in the t...
$object_id is supposed to be a post's ID, make sure first that $post-> ID would even output an ID, if not, the problem lies there.
Assign Custom post to Custom Taxonomy
wordpress
I've tried Private Messages for Wordpress, but are there any alternatives?
I found the following ones with good or fairly good ratings: WP Private Messages Cartpauj PM
Is there a decent private message plugin for Wordpress?
wordpress
After installing several new plugins I discovered my site is getting slower. Is there a way to know which plugin utilizes the most resource without using the obvious method of activating/deactivating each plugin one by one?
Try this plugin: http://wordpress.org/extend/plugins/p3-profiler/
How do I know which plugin uses the most resource?
wordpress
This issue is driving me nuts since weeks :(( Please help me. The comments are assigned to related posts and are visible on other posts also. For ex. The page redirects to post "Sports" when I post the comment on "Food" But the same comment is visible on all the other posts like "Tours", "News" etc., Most likely, the c...
try to add <code> wp_reset_postdata(); </code> after the <code> endwhile; </code> of the 'related posts' loop.
Comments are assigned to wrong or related post
wordpress
I am currently using the wp_login hook to run a php function when a user logins. However, I want to show users who login notifications (a pop up with recent posts, etc) and I was planning to do this by running a javascript function. Is it possible to edit the page shown to the user after login? This is the code I have ...
<code> add_filter( "login_redirect", "my_login_redirect", 10, 3 ); function my_login_redirect( $redirect_to, $request, $user ) { return home_url( "/your_page/" ); } </code> Should about do it for you. Modified from a script that I had running in wp3.3.1. Docs: <code> home_url() </code> , <code> login_redirect </code>
Edit page shown after login in Wordpress?
wordpress
I am trying to load jquery-ui using wp_enqueue_script. I can check that jquery is loaded. jquery-ui is registered i.e. output of var_dump( wp_script_is( 'jquery-ui-tabs', 'registered' ) ); is bool(true) which indicates it is registered but it does not get included to the page. I am using wordpress version 3.3.1 What is...
Here's an alternative way to load a popular script like jquery-ui (using google api's) <code> &lt;?php // first, check to see if jquery-ui is already loaded if( !wp_script_is('jquery-ui') ) { // you don't have to use googleapi's, but I think it helps. It saves the user's browser from loading the same script again if it...
using wp_enqueue_script to attach jquery-ui
wordpress
According to the Codex docs , wordpress uses the query string and the template hierarchy to determine which template to use for a certain page. First, WordPress matches every Query String to query types — i.e. it decides what type of page (a search page, a category page, the home page etc.) is being requested. Template...
It's stored in post meta under the key <code> _wp_page_template </code> .
How does wordpress link page templates to individual pages
wordpress
I was using the javascript function convertEntities in a plugin that worked great until recently and now the function seems to have vanished under 3.3 - Is there a substitute function I should be using? I am tempted to just copy the function into my script - is there a reason that is a bad idea?
<code> convertEntities </code> was removed because strings are passed to JavaScript via <code> json_encode() </code> now: http://core.trac.wordpress.org/ticket/11520
What happened to convertEntities?
wordpress
I'm working on an email system, and I'm onto the unsubscribing stage. Since most of my users would not know their user ID, I'm asking them to put their email into a text box (definitely preferred, since this IS an email system). In order to change their user meta (their subscribed status), I need to know the users ID. ...
You are probably looking for the <code> user_exists </code> function. http://codex.wordpress.org/Function_Reference/email_exists This function will check whether or not a given email address ($email) has already been registered to a username, and returns that users ID (or false if none exists). If the email address doe...
Get user id from email?
wordpress
I'm developing WP as a heavily bespoke CMS. One of the five plugins required is already 2500 lines of code and isn't quite finished. I work between two machines - my laptop and my home PC. Generally, my working method involves FileZilla and Notepad++. I log on to whichever machine I need to use; download all of /wp-con...
Dunc, glad you asked about this before it was too late for you. You have heard the right words. You are right, unfortunately the articles tutorials are not very much newbie friendly. Frist let me try to clear some terminology for you. The thing you need to manage your code and keep track of all the changes you make to ...
Subversion, github, etc.. version control systems/repositories
wordpress
Trying to properly indent a theme I wondered if it would be possible to create a new line <code> "\n" </code> directly after <code> &lt;?php the_content(__('Continue reading &lt;span class="meta-nav"&gt;&amp;rarr;&lt;/span&gt;', 'mytheme')); ?&gt; </code> ? Edit: At the person who did a -1 on this topic, could you perh...
Why not just do: <code> &lt;?php the_content(__('Continue reading &lt;span class="meta-nav"&gt;&amp;rarr;&lt;/span&gt;', 'mytheme')); echo "\n"; ?&gt; </code> That?
new line after the_content
wordpress
EDIT: Turns out I had a permalink issue that was causing the 404 error. Original Posting below: I am creating a page programmatically using $wpdb-> insert() and the resulting page returns a 404 error. A few things to note I am using a $wpdb object to create the page because I am creating it on a separate WordPress webs...
Permalink Error I thought I was using a basic permalink, but forgot that I had used a custom permalink structure on this particular website. The custom permalink I used was <code> %postname% </code> . I switched it to the month and name option and now everything works. Sorry for the bogus question.
Programmatically Creating Page using $wpdb and getting 404 error
wordpress
I'm using a more or less fresh local install of WP 3.3.1. A few days ago I set up a couple menus (Appearance > Menus) without a hitch. Today I tried creating a new menu and add a page to it, but the page was never successfully added to the menu; the spinner just went on forever. I thought maybe the menu name was confli...
OK, I looked through the error log in MAMP and discovered a bunch of weird garbage. After Googling some pertinent strings (i.e. "caught SIGTERM, shutting down"), the best advice I got was to reinstall PHP with MAMP; now it's working as expected.
Why am I timing out when using the Menu Editor?
wordpress
I have set up a slideshow running on the front page of my site that runs on images attached to a page called 'Home'. I would like to be able to adjust its contents and order from the admin area. And lo, I can do this, by going to the 'Home' page in pages, clicking on the Media Library, going to the 'Gallery' tab and re...
The Gallery tab of the Media Uploader for an individual post is located at this link: http://example.com/wordpress/wp-admin/media-upload.php?post_id=999&amp;tab=gallery (change the post ID as needed.) I have no idea how robust this is, but I did a quick test on my own site, and the changes I made were saved correctly.
User-friendly link to attached images for a certain post?
wordpress
Is there a specific reason why we can find max-width:97.5% instead of 100% in common themes such as Twenty Eleven?
Since the TwentyEleven theme also includes some default padding and a border for (fluid) images (see CSS below), a width of 100% would push the image outside of its container's width. This is because of how the box model works: border and padding are added to the width/height. <code> img[class*="align"], img[class*="wp...
Why max-width:97.5% on content images?
wordpress
As soon as I enable the option Performance --> Browser cache --> 'Set expires header' to true I get a 500 Internal Server Error. Then I have to SSH into the server and delete the new entries to make the site work again. I have googled a lot and it seems nobody has this problem. ANd yes I have already sudo a2enmod expir...
The best way to deal with issues like this is referring to the manual. http://httpd.apache.org/docs/1.3/mod/mod_expires.html#expiresactive Syntax: ExpiresActive On|Off Context: server config, virtual host, directory, .htaccess Override: Indexes Status: Extension Module: mod_expires Look at the Context and Override synt...
Getting "Internal Server Error" when enabling 'Set expires header' in W3 Total Cache
wordpress
Does anyone know the steps needed to add a custom format to the blockformat (p,h1,h2,h3 etc.) dropdown in the tinyMCE editor in Wordpress? I've found a lot of different ways to do that, which seem to either contradict each other or have absolutely no effect. I've had very little interaction with Wordpress as a develope...
<code> function extend_tiny_mce_defaults( $config ) { // comma separated list of any block-level HTML tag $config['theme_advanced_blockformats'] = 'h1,h2,h3,h4,h5,h6,p,code,address'; return $init; } add_filter( 'tiny_mce_before_init', 'extend_tiny_mce_defaults', 100 ); </code>
Adding to he format dropdown menu tinyMCE in Wordpress
wordpress
Is it possible to run a function every time a post is deleted. The function has to be run when the post is deleted from the admin or by the wp_delete_post() function.
Yes, by adding an action to the before_delete_post , delete_post , or deleted_post actions.
Run a function when post is deleted?
wordpress
Hi i'm trying to adopt the <code> get_template_part() </code> method for looping post formats as in: <code> if ( have_posts() ) : while ( have_posts() ) : the_post(); if( ! get_post_format() ) { get_template_part( 'format', 'standard' ); } else { get_template_part( 'format', get_post_format() ); } endwhile; endif; </co...
You have to edit format.php &amp; format- type .php files according to your get_template_part() usage.
Smart post format loop problems
wordpress
Anyone know of a plugin that can, or have an idea how to, allow a user to drop in separators/dividers between certain nav menu items? Google only seems to bring up rookie CSS tips for first/last child selectors, I'm after something very much like Firefox bookmarks ;) UPDATE: I do appreciate all input so far, but I'll e...
Use a stackexchange-url ("custom walker"). Extend <code> start_el() </code> to print <code> &lt;li class="menu_separator"&gt;&lt;hr&gt;&lt;/li&gt; </code> if the menu title is just a <code> '-' </code> . functions.php <code> function wpse38241_setup_menu() { register_nav_menu( 'main-menu', 'Main Menu' ); } add_action( ...
Nav menu separators?
wordpress
I would like to add a custom field "NOTES" to the user profile. This custom field should not only be updated,saved and display the current value but be displayed as ongoing (previous and current) notes on the user profile. For example: 1/1/2012 user xx wrote: Lorem ispum ispum 1/2/2012 user xx wrote: Lorem ispum ispum ...
it would be easier to create a custom post type Notes, than on a user page just get all notes of a specific author and than display them. By creating a custom post type you may easily create a interface and all saving/handling functions. If you would like to do it as a custom field in the user edit screen it would take...
Add Custom Profile Field as Notes
wordpress
is there any plugin that will add new quicktag, says: <code> [hidetext]some text to hide[/hidetext] </code> and any text inside those tag is hidden from frontpage/archive/etc. It only shown on single post page.
<code> add_shortcode( 'hidetext', 'my_hidetext_shortcode' ); function my_hidetext_shortcode( $atts, $content = '' ) { if( is_single() ) return $content; else return; } </code> Docs: <code> add_shortcode() </code> , <code> is_single() </code> Solution is untested.
plugin to hide selection of text from post from frontpage
wordpress
I am using the syntaxhighlighter plugin, which is nice, but creates a horizontal scroll bar if the code is too "broad". I am thus looking for a theme with for wordpress which has much space in the horizontal direction (no sidebar, maybe). Secondary a "codish" look would be nice. I have looked at http://theme.wordpress....
Syntaxhighlighter is by far the best plug-in, so it's just a matter of editing the CSS that comes with it (as that will give you total control). The horizontal scroll doesn't seem great at first either, however your readers will appreciate that important code structure doesn't get the "word wrap" treatment (thus, break...
Are there any wordpress themes specifically designed for blogs on code?
wordpress
I have this code <code> add_action( 'delete_post', 'my_delete_function' ); function my_delete_function() { global $wpdb; $wpdb-&gt;query(" DELETE FROM wp_votes WHERE post=".$thePostID." ;); } </code> How can I get the id of the post being deleted? Additionally, will this still work if multiple posts are deleted in the ...
I haven't tested so I'm providing you with two possibilities, Inside a loop, use the following: <code> $post_id = get_the_ID(); </code> Outside a loop, use the following: <code> global $wp_query; $post_id = $wp_query-&gt;post-&gt;ID; </code> Or: <code> global $post; $post_id = $post-&gt;ID </code> Or you can pass the p...
Get post id in wordpress action?
wordpress
I need to find plugin or create listing of all uploaded images for some post in custom metabox. And i can click to thumbnail for add image to editor in custom format. I downloaded a lot of photos to default upload box, and each time i will do a lot of clicks for insert new image to editor. It is very uncomfortable.
Faster Image Insert ? Moves built-in Media Manager down in a meta-box, right next to main editing panel, so you have full control of the manager: opens it, makes it collapse or hidden from the interface completely. Best of all, is now you can insert image(s) much faster, and precisely where you want them to be.
Adding uploaded images to editor from metabox instead of default popup uploader
wordpress
I'm in the technical planning stages of a project which i intend to implement a 'Single Page Layout' on. I've setup the pages 'people', 'clients', 'contact', 'case studies' etc and taken the content into my Front Page template using the get_page() function, feeding it the page IDs. This works OK. I'm intending to have ...
You can handle that with a hash (the way javascript does by default) and have the url become example.com#people, or any other delimiter really. It should be as simple as changing the character you're parsing the url for. UPDATE: Example code as per comments <code> $args = array( 'label' =&gt; 'Your Label', 'labels' =&g...
URL conflict with a 'Single Page Layout'
wordpress
I'm confused, because there are a lots of functions about attachments . I've tried a lots of functions. I'm setting a featured image for my every blog post. I have to get different sizes of this image. FOr example a need this variations of featured image 600px*400px 300px*150px 64px*64px (Images can be cropped). I'm ad...
Since you have defined the featured image for each post with using <code> &lt;?php the_post_thumbnail( 'custombig' ); // or another custom size name ?&gt; </code> should be enough, for info you can read: http://justintadlock.com/archives/2009/11/16/everything-you-need-to-know-about-wordpress-2-9s-post-image-feature htt...
Getting Different Size Of Attachment Images
wordpress
I am loading scripts like this: <code> //load scripts //wp_register_script( $handle, $src, $deps, $ver, $in_footer ); add_action('wp_enqueue_scripts', 'load_scripts'); function load_scripts() { if (!is_admin()) { wp_register_script('modernizr', get_bloginfo('template_directory') .'/scripts/modernizr-latest.js',false); ...
Just a note before I get into the solution, <code> get_template_directory_uri() </code> is preferred to <code> get_bloginfo() </code> because it is a filtered output. That said, in the corrected code I have left it the way you had it, to save you typing in the case that you had a reason for leaving it that way. Your is...
wp_register_script not loading as expected
wordpress
I've disabled pretty much every button in the visual editor, besides bold and underline. The problem is that the functionality of the other buttons are still there with the keyboard shortcuts. Is there someway to disable the keyboard shortcuts. I don't need them at all.
Not really a wordpress question - but have you tried <code> tinyMCE.init({ .. custom_shortcuts : false }); </code> ?? (might have a problem with IE though , on which case, you can override them with a foo function.) <code> function disableShortcuts(){ tinyMCE.get('elm1').addShortcut("ctrl+b","nix","foo"); tinyMCE.get('...
Disabling TinyMCE keyboard shortcuts altogether
wordpress
In my footer, I have a set of links labeled Meta, it has... Register Log in Entries RSS Comments RSS Wordpress.org How can I remove just the wordpress.org and and comments rss link from the meta links?
Depending on your theme, they may be hard coded into a sidebar or footer file. If this is the case, you will need to get your hands dirty and edit your theme files. But you can usually remove them by adding a widget, as these items often only show up when no widgets have been added. So go to Appearance -> Widgets and a...
Remove Wordpress.org Meta link
wordpress
I'm trying to set up a new CPT called news (see code here: http://pastie.org/3148081 ) and I'm specifying the has_archive parameter. I've set up a new template called archive-news.php and single-news.php but its not being used when I go to /news/ or the permalink on the site. Instead the default archive.php and single....
Your custom post type is <code> je_news </code> . This means that your single and archive files should be called single-je_news.php and archive-je_news.php . The <code> has_archive </code> option enables you to change the archive url, but it doesn't override what the templates should be named.
Custom Post Type with has_archive ignores my custom archive and single template
wordpress
My website is displaying, if print_r, two different ID for the same post. If i ask: <code> &lt;?php echo $post-&gt;ID;?&gt; </code> in the single.php it gives me a number. If i do the same thing in the sidebar it gives me a completely different one. This is what I get with the print_r on the single.php <code> stdClass ...
do you have a query pulling those related posts at the bottom? the 4 squares? it looks like you need a wp_reset_query() after those as the final square is titled "prova 3" which is the post you are showing the object data for in the sidebar.
Print_r displaying two different post-> ID if placed in sidebar or single.php
wordpress
I have a custom page that calls a function - say generatelist the generatelist functions call get_pages() and loops through the array using for each and building a list containing various data from the meta data of the pages (yes pages, not posts! for a reason) the functions returns the list (actually a catalog of page...
I suggest using get_posts because you are able to set "paged" parameter there. <code> &lt;?php // Posts Per Page option $ppp = 3; // find out on which page are we $paging = isset( $_GET['list'] ) &amp;&amp; ! empty( $_GET['list'] ) ? $_GET['list'] : 1 ; // arguments for listed pages $args = array( 'posts_per_page' =&gt...
pagination in a custom list created with get_pages function
wordpress
I'm writing a plugin with a settings/option page and I want some php code to be executed whenever someone saves the settings on that page and that page alone. Which actions do I need to hook into to accomplish this?
If you're using Settings API , then you should use a sanitize callback: <code> register_setting( $option_group, $option_name, $sanitize_callback ); </code> The myth is that the <code> $sanitize_callback </code> actually is a filter for your options when it's saved in the database. This is the place where you can do som...
Which to use to execute code during the saving of a plugin settings page?
wordpress
Is it possible to set certain settings from the theme functions file for example the setting <code> Enable threaded (nested) comments </code> ca I set it to allow <code> 2 </code> as the answer without having the user go into the admin panel and setting it for there wordpress comment settings?
I am satisfied with Nikolay Yordanov's answer. Just generalizing the solution. Yes, we can update WordPress options programmatically. WordPress saves options in wp_options table. wp_options holds two rows option_name and option_value to store key and value respectively. We need right option_name and a way to save value...
Set Wordpress settings programmatically
wordpress
I just noticed, in a theme file, I can access custom functions I add to my functions file, however I can NOT access variables I set in my functions file. I have a few variables I set inside my functions.php file for example... <code> $feedburnerUsername = 'username'; </code> Now in my sidebar.php file If I try to acces...
Whilsts @Shaon's answer is perfectly valid, I'm of the opinion you really shouldn't be throwing configuration settings around as global variables - use a constant instead. <code> /* Constants are in the global scope, but can only be defined once. */ define( 'FEEDBURNER_USERNAME', 'my_username' ); define( 'FEEDBURNER_PA...
How to access variables from Functions file in theme files
wordpress
I'm using the wp_mail function to send emails in WordPress. Before I run the function, I retrieve a heap of data from a session and some others from a form that was just submitted. For example: <code> $first_name = $_SESSION['first_name']; $last_name = $_SESSION['last_name']; $phone_number = $_POST['phone_number']; $me...
It sounds like you don't have your code wrapped into an <code> if </code> statement that'll check it only gets executed if the form was actually submitted, i.e. it gets run when you first view the page ( <code> GET </code> ) and again when you submit the form ( <code> POST </code> ). You can use the below snippet to en...
wp_mail is sending two emails when used after retrieving session data
wordpress
I have a WP 3.x site that I'm using mainly as a CMS. The menu links to the various WordPress pages. One of the pages, "News", is the "posts" page. However, when clicking on one of the posts on the News page, the "News" item in the menu loses highlighting because the post isn't treated as a child of "news". Is there an ...
Since I assume you're using <code> wp_nav_menu() </code> , there should be a class <code> current_page_parent </code> which is applied to your posts' page menu item when viewing a single post. You can use this class to style the 'active' state, much like you're probably doing with <code> current_page_item </code> at th...
Overriding the currently selected menu item
wordpress
I'm just wondering if this is possible because the variation names listed in the products have text which is not really necessary even though I have deleted the category, its still appearing. Hope you guys can help get out of this stuff.
I'm not sure if there's a WordPress-specific way to do this, but you can do a quick find-and-replace for the offending terms. I don't know if it follows a pattern, but if you have access to the site through SSH you could do a MySQL dump and find/replace/reimport easily. Try this: <code> mysqldump -uDBUSER -p DBNAME &gt...
Multi Quick Edit - Possible Or Impossible?
wordpress
I have a page called Food which displays posts from 2 custom post types - Recipes and Restaurants. How do I add 'food' to the permalink just for those two custom post types? - e.g. www.mysite.com/food/recipes/thepost
Check out the rewrite parameter for register_custom_post_type . You may specity a slug that will be added before. So if you have two separate post types for recipes and restaurants set for one '/food/recipes' and for the second one '/food/restaurants'. You must visit the Settings-> Permalinks after this is done so that...
Change permalink for custom post type?
wordpress
I got a metabox that hold a monthly budget per client... that meta box is inside a custom post type called clients. Inside that metabox the only thing entered is numbers. I want to get the sum of all the clients. Any ideas? Altough i think its pure php.. somehow using foreach - to the request of @Fahd Murtaza i am tryi...
Asuming that you have a variable called <code> $posts </code> that contains all the posts (or easier: Post IDs) from some query. You can then work with <code> $result </code> and process everything you need. Calling post data is easy, as the key would be the post ID. <code> // For other arguments look into @link http:/...
How to sum values from all custom posts metabox
wordpress
Can someone help me figure out the Buddy Press plugin. I have a magazine Wordpress website created with an open source theme and style and very slight html alterations and customizations. I've downloaded all the necessary BuddyPress plugins: **BuddyPress BuddyPress Sliding Login Panel BuddyPress Template Pack** And it ...
Have you tried logging out first, then going to the register page? It won't show if you are logged in
Using BuddyPress > 'Register page'
wordpress
I'm working on a plugin for a system to use Wordpress as the authentication backend, so that I can use my existing Wordpress users in another application. The plugin works great when running in single website mode: <code> include /path/to/wordpress/wp-config.php global $wpdb; // SQL and code to select user and compare ...
You'll want to include the wp-load.pphp, not the wp-config.php. Depending on how you're doing it, you may also have to set $_SERVER variables if they aren't already set to prevent WordPress from trying to redirect you. For example: <code> $_SERVER = array( "HTTP_HOST" =&gt; "http://mysite.com", "SERVER_NAME" =&gt; "htt...
Bootstrapping Wordpress MultiSite Outsite of Wordpress - No $wpdb
wordpress
I am trying to create a post (well, in the end, multiple posts) from a metabox using the 'save_post' hook. I executed the script once, creating 3900 or so new posts before I crawled into posts.php and discovered that wp_insert_post() calls the 'save_post' hook. Does anyone have a creative solution around this to create...
I figured it out, what I ended up doing was as follows: <code> function my_metabox_save() { //do this just once if( MY_DOING_SAVE != 'my_doing_save' ) { define( MY_DOING_SAVE , 'my_doing_save' ); //data authenticity check //process &amp; sanitize data //create posts for( $i=0; $i&lt;$count; $i++ ) { $args = array( 'pos...
Is it possible to create a post using a metabox?
wordpress
Say I put the following code in functions.php <code> function add_my_query_vars($qvars) { $qvars[] = "new_var"; return $qvars; } add_filter('query_vars', 'add_my_query_vars'); </code> If somebody requests <code> my.site.com/?new_var=[MALICIOUS CODE] </code> , can they cause any damage? If not, why not? Edit for clarity...
Regardless of whether you registered <code> new_var </code> as a query_var, all GPC data (GET, POST, COOKIE) should be considered tainted. Basically, this data is user input. This means that you will need to clean and validate the data anyway. Common cleaning methods include casting the variable to a certain type (like...
Does using a custom query_var create a security hole?
wordpress