question
stringlengths
0
34.8k
answer
stringlengths
0
28.3k
title
stringlengths
7
150
forum_tag
stringclasses
12 values
I'm using the ClassiPress theme as a base for a new theme. If you have worked with classipress, you should know that classipress handles its own category using the taxonomy <code> ad_cat </code> . That said, I have a category named <code> 7star </code> and the following query to get the posts inside that category: <cod...
Well, I should have used the <code> tax_query </code> parameter. Something like the following: <code> $the_query = new WP_Query( array('post_type'=&gt;'ad_listing', 'tax_query' =&gt; array( array( 'taxonomy' =&gt; 'ad_cat', 'field' =&gt; 'slug', 'terms' =&gt; '7star' ) ) ) ); </code>
How to get posts using category slug in ClassiPress?
wordpress
I'm working on Custom Post Type and Genesis Child Theme. My code is <code> add_action( 'init', 'register_cpt_testimonial' ); function register_cpt_testimonial() { $labels = array( 'name' =&gt; _x( 'Testimonials', 'testimonial' ), 'singular_name' =&gt; _x( 'Testimonial', 'testimonial' ), 'add_new' =&gt; _x( 'Add New', '...
i can't test this as a child theme of Genesis, but i just tested it on a child theme of Thematic and it worked fine. there isn't anything in the code that should prevent it from running. that said, i don't like registering post types as part of a theme... what if you change the theme down the line.... do you just want ...
Genesis Child and Custom Post Type
wordpress
I am using Wordpress as a CMS for a project which makes extensive use of custom post types. I need to display columns in admin panels for each custom post type in a different way. I've already created the necessary columns and populated them. What I need to do is to adjust the CSS a bit. Most importantly I'm trying to ...
I found a solution that works for me! I dropped this code in functions.php : <code> add_action('admin_head', 'my_column_width'); function my_column_width() { echo '&lt;style type="text/css"&gt;'; echo '.column-mycolumn { text-align: center; width:60px !important; overflow:hidden }'; echo '&lt;/style&gt;'; } </code>
Style custom columns in admin panels (especially to adjust column cell widths)
wordpress
In "Main Sidebar" i would like to add a dropdown list of ALL my post. How can i do that? I found various plugins and none of them did what i wanted (for example one only list the post i have on that page). How might i put all my post into a dropdown/menu list in the sidebar?
<code> &lt;?php // query for all posts $your_query = new WP_Query( 'posts_per_page=-1' ); echo '&lt;select&gt;'. '&lt;option value="" selected="selected"&gt;Select a post&lt;/option&gt;'; // loop through posts while ( $your_query-&gt;have_posts() ) : $your_query-&gt;the_post(); echo '&lt;option value="'; the_permalink(...
How do i put a dropdown list of ALL my post in the sidebar menu?
wordpress
On the documentation page it says "The action will trigger when someone visits your WordPress site, if the scheduled time has passed." Is it possible to make this action trigger only when the admin is visited? I am trying to prevent a slow operation from impacting users on the front side.
In your event callback function check to see if the user id the admin then run the function else just reschedule it. So using the example from the codex's page you linked in the question it would be something like this: <code> function my_activation() { if ( !wp_next_scheduled( 'my_hourly_event' ) ) { wp_schedule_event...
wp_schedule_event only when admin is visited
wordpress
wp_list_pages can be a great tool for displaying a tree structure. You can specify the depth, child of, and show_date of when the page was last modified. However, if I want to only show the date for pages that were modified in the last...24 hours say...How can I specify this?
By default the function cannot do this, but you can specify a custom walker when you call the function, and then implement your own walker: http://bugssite.org/blog/2009/12/08/wordpress-custom-walker-tutorial/ http://www.wprecipes.com/how-to-modify-lists-like-categories-and-blogroll-in-wordpress This way you can keep t...
wp_list_pages Format only on Recently Modified Pages
wordpress
<code> &lt;?php $categories=get_categories('taxonomy=galeriak'); foreach ($categories as $category) { ?&gt; &lt;li&gt;&lt;a href="&lt;?php echo get_category_link( $category-&gt;term_id ) ?&gt;" title="&lt;?php echo $category-&gt;name ?&gt;"&gt;&lt;?php the_term_thumbnail ( $category-&gt;term_id, $category-&gt;taxonomy,...
You should be using <code> get_term_link </code> instead, also for consistencys sake and to future proof, use <code> get_terms </code> instead of <code> get_categories </code> . Both work on categories/tags and all custom taxonomies. Also check for the return of a WP_Error object ( returned when an invalid or nonexiste...
get_category_link() is returning nothing
wordpress
I'm trying to work with an old plugin http://wordpress.org/extend/plugins/wp-ecards/ (I'm not the plugin author) and I get this error in the php error log and a blank screen when trying to view the e-card on site: <code> Failed opening '' for inclusion (include_path='.:/usr/share/php:/usr/share/pear') in /home/public_h...
Would it not make more sense to use get_template_part() ? What may be happening is that there is no 404 template: <code> if ( '' != get_query_template( '404' ) ) include( get_query_template( '404' ) ); </code> http://codex.wordpress.org/Function_Reference/get_query_template This may be because pretty permalinks have be...
Error on Include php:/usr/share/pear
wordpress
Currently the WordPress Twenty something themes all have this as the title: <code> &lt;title&gt;&lt;?php global $page, $paged; wp_title('~', true, 'right'); bloginfo('name'); $site_description = get_bloginfo('description', 'display'); if ($site_description &amp;&amp; (is_home() || is_front_page())) echo " ~ $site_descr...
Wrapping everything in strtolower should work: <code> &lt;title&gt;&lt;?php global $page, $paged; echo strtolower(wp_title( '|', false, 'right' )); echo strtolower(get_bloginfo( 'name' )); $site_description = get_bloginfo( 'description', 'display' ); if ( $site_description &amp;&amp; ( is_home() || is_front_page() ) ) ...
strtolower
wordpress
I am using the twenty-eleven theme and every page (except the 404) has a sidebar. However the post permalink page (/2011/11/post-name/) does not. How do i put the sidebar onto it? I tried looking for its php file on codex but it is very unclear which file is the correct one.
The template for the display of a single post is <code> single.php </code> Add <code> &lt;?php get_sidebar(); ?&gt; </code> in the second last line of that file just above <code> &lt;?php get_footer(); ?&gt; </code> and the sidebar will show. Note: This will get overwritten, if you ever update the theme.
How do i put a sidebar on my post permalink page?
wordpress
I've browsed tons of Q/A on stackexchange, google, wordpress forums... but haven't found yet a definitive answer to what looks like to be a common issue since the introduction of custom post types. I've set my permalinks structure from Wordpress admin permalink settings page as: <code> /%post_id%/%post_name%/ </code> s...
<code> function myrules(){ add_rewrite_rule('^yourcptslughere/([^/]*)/([^/]*)/([^/]*)/?','index.php?p=$matches[1]&amp;taxonomy=$matches[2]&amp;name=$matches[3]','top'); } add_action('init','myrules'); </code> Replace the ' yourcptslughere ' with what you wanted, and then add that to functions.php then flush your rewrit...
Custom post type permalink structure
wordpress
How can I get the ID of a post (or page) based on the $query_vars variable? I want to do something like <code> $query_vars['post_id'] </code> But I don't have a reference page that has the list of $query_vars perams. The code will be using the template_redirect action hook.
When viewing a single post, <code> get_the_ID(); </code> used within the loop will return the current post's ID. But I don't have a reference page that has the list of $query_vars params... Dumping it <code> global $wp_query; var_dump($wp_query-&gt;query_vars); </code> would provide such a reference. Where you'd subseq...
get post id using the $query_vars variable
wordpress
I am using this code to show posts in columns. How can I set this part ('cat=3&amp;numberposts=5&amp;offset=0') as so archive page should automatically get posts from clicked catagory? <code> &lt;div id="column1"&gt; &lt;?php $posts = get_posts('cat=3&amp;numberposts=5&amp;offset=0'); foreach ($posts as $post) : start_...
Instead of using the number 3, you get the current category by doing the following: <code> $cat_ID = get_query_var('cat'); $posts = get_posts('cat='.$cat_ID.'&amp;numberposts=5&amp;offset=0'); </code>
Get posts in archive page
wordpress
In my function for saving custom field values I add a few checks to prevent the values from being cleared during an autosave or a quick edit. <code> add_action('save_post', 'save_my_post'); function save_my_post($post_id) { // Stop WP from clearing custom fields on autosave, // and also during ajax requests (e.g. quick...
You can check for a bulk edit by looking at the <code> bulk_edit </code> variable in <code> $_GET </code> or <code> $_POST </code> . Bulk edits are typically GET requests as far as I investigated them. Note that <code> $_REQUEST </code> takes both GET and POST data into account. In <code> wp-admin/edit.php </code> they...
How to prevent custom fields from being cleared during a bulk edit?
wordpress
I trying to set a meta_box with a single checkbox, everything goes fine, however if I uncheck it and save the post, it marks again as checked, I've been taking a look but I cannot find my mistake. Take a look a my code. <code> function am_checkbox_option() { global $post; $custom = get_post_custom($post-&gt;ID); $front...
Here is code I have used before - the main difference looks to me that you are checking if the meta exists rather than what it's value is to determine if it should be checked. <code> // Checkbox Meta add_action("admin_init", "checkbox_init"); function checkbox_init(){ add_meta_box("checkbox", "Checkbox", "checkbox", "p...
Metabox with checkbox is not updating
wordpress
I'm trying to get the custom field data off an attachment and display it following the image tag in a page/post using the get_image_tag filter. I'm using the same function to get the same data and display it on the attachment field as well. That works perfectly using the the_content filter so I know the function is wor...
Turned out my "answer" was that I didn't really understand "get_image_tag." It only runs when you first insert an image. I was thinking that it ran every time the edit interface was loaded. From researching and talking with others, it seems the only way to get the metabox data onto existing images is some kind of regex...
get_image_tag filter not working
wordpress
I'm using Taxonomy Images to associate images with categories. I'm using the following code, one is to display the categories, the other to display the images. Here is the code that displays my categories. <code> &lt;?php $cat_id = get_query_var('cat'); $catlist = get_categories('hide_empty=0&amp;child_of=' . $cat_id);...
Got this working by using the code below. It will show the categories and the image associated with it. <code> &lt;?php $cat_id = get_query_var('cat'); $catlist = get_categories('hide_empty=0&amp;child_of=' . $cat_id); echo "&lt;ul&gt;"; foreach($catlist as $categories_item) { echo '&lt;h1&gt;&lt;a href="' . get_catego...
Using Taxonomy Image code with my get_categories code
wordpress
On the Wordpress site I am working on, subscribers will not be allowed to see anything in the backend at all. Because of that I am creating a custom pages for the Wordpress login page that subscribers can access. On the login form there is a "Lost Password" link. I have managed to redirect most things to my own custom ...
The filter you're looking for is <code> retrieve_password_message </code> . The relevant function can be found in wp-login.php (starting on line 165, wp 3.2.x) , the filter is applied in line 231.
Changing "Lost Password Email Link" to custom password reset page
wordpress
I have a CPT that is justed used for linking to resources on a local drive. I have this code in single-resource.php: <code> &lt;?php global $post; the_post(); $location = get_post_meta($post-&gt;ID, 'sc_stace_resource_location', true); $count = (int) get_post_meta($post-&gt;ID, 'sc_stace_view_count', true); $count++; u...
The above code didn't work because of browser security. I've decided to go with this code: <code> &lt;?php global $post; the_post(); $location = get_post_meta($post-&gt;ID, 'sc_stace_resource_location', true); $count = (int) get_post_meta($post-&gt;ID, 'sc_stace_view_count', true); $count++; update_post_meta($post-&gt;...
wp_redirect to file:// location results in blank page/cannot be displayed page
wordpress
managed to create a custom menu area in the admin but now want to place 2 post types to it. They already exist - questions &amp; answers, but can't find a way to put their menu links into the custom menu. <code> add_action('admin_menu', 'mt_add_pages'); function mt_add_pages() { add_menu_page(__('Competition','comp'), ...
ended up defining it in the register_post_type function... <code> 'show_in_menu' =&gt; 'mt-top-level-handle' </code>
and custom post_types to custom menu
wordpress
I am using qtranslate plugin for my WordPress site to make it a multi-language site. Now I have got a requirement like For English the url should look like www.sitename.com/contact-en For French the url should look like www.sitename.com/fr/contact-fr How can I accomplish this? (qTranslate is the plugin used) Note: Ther...
After thinking for a while I got to go for my own solution. Having the "qtranslateslug-plugin-widget" plugin working in the admin side to store slugs in the slug table, I have put my own code in the user side. In the wp-blog-header.php page I have added my own code just before the inclusion of wp-load.php file. I took ...
Multi-language permalink in qtranslate
wordpress
I wish I knew PHP as well as I do Rails. I'd imagine this is fairly intuitive. Thanks!
Wordpress has an inbuilt function called <code> the_excerpt() </code> which echoes an excerpt of the post content. By default an excerpt is 55 characters. You can set it to 200 like so: <code> function your_excerpt_length( $length ) { return 200; } add_filter( 'excerpt_length', 'your_excerpt_length' ); </code> This sho...
Anyone know a php snippet for showing the first 200 characters of the most recent post?
wordpress
stackexchange-url ("A related WPSE question") asks how to get the term by specifying ID only, without specifying taxonomy. My question is more philosophical. Generally, stuff in WP core is there for a reason. I'm trying to understand why term_id can't be the primary key for the term - why do we need the taxonomy as wel...
I've logged a ticket against this with trac: http://core.trac.wordpress.org/ticket/20536 However, it turns out that for the time being it IS necessary, as WordPress currently (since 2.x) has a bug that DOES associate two terms with the same name to the same term_id! So it IS possible (though incorrect) for a single ter...
Why does get_term() require taxonomy? Are term_ids not unique?
wordpress
I have a WordPress and everything seems perfectly fine but I have this page that has title 77% and it shows error 404 page. How can I fix this? I am kind of sure it is because of the % in the 77%. The permalink uses the 77 but for some reason wordpress still doesn't like that % in the title. What can I do to fix this w...
There is nothing you can do, the % symbol is not a neutral character and whatever 2 characters immediatly follow it are used to represent a character. This is called percent encoding. http://en.wikipedia.org/wiki/Percent-encoding For example, to encode a % you would use %25. Thus the answer is: No, it is not possible t...
Problem with special character WordPress
wordpress
I was going to give users back end access to edit entries but don't like the idea of them having access to the back end. I currently am using/developing with Adminize and Role Scooper and have set up custom editing screens for the users. Users will have access to a custom post type for their user profile and to a singl...
Using a custom template and <code> wp_update_post </code> you should be able to build your own edit/add post pages in your sites frontend. There are also various plugins available that attempt to do similar things. iFrames can be done, but it will need some checks in functions.php to check for a get variable and add co...
front end editing using iFrames, best approach?
wordpress
I noticed that if you put the same widget in two different widget slots (primary and secondary for instance) only the first one will appear on the page. The second slot will be empty. How to solve that problem and allow my widget (a custom menu) to appear twice on my page ?
It sounds like a problem with that particular widget or if not that then your theme. Try again with a default theme and one of the wp widgets. Works fine with those.
How to add the same widget twice?
wordpress
I'm working on a plugin which has bulk post inserts using a spreadsheet. This spreadsheet can have multiple thousand rows, each row corresponding to a post. I'm parsing this spreadsheet, looping over the parsed data and using <code> wp_insert_post </code> to insert the posts. I noticed that when I used a spreadsheet wi...
Something tells me that it could be the maximum script execution timing out perhaps. The amount of memory your inserts are consuming could also be the culprit. Are you getting any error messages, blank screens or anything like that? You could try adding the following above where you're calling the wp_insert_post() func...
How many 'wp_insert_post' calls can be performed in one shot, in a very long 'for' loop?
wordpress
I have set a static page for posts (page id = 110). This page shold only be included in the menu when the user is logged in. The latter is achieved with the following addition to <code> header.php </code> (snippet from inside the <code> menu &lt;ul&gt; </code> tag). <code> &lt;?php wp_list_pages('sort_column=ID&amp;exc...
I think this should work if you are wrapping the condition around the arguments, and not the menu link itself: <code> if(!is_user_logged_in()) { $args = array( 'exclude' =&gt; '100,110,145' ); } else { $args = array( 'exclude' =&gt; '100,145' ); } wp_list_pages( $args ); </code>
How to find out if page_for_posts is showing (in order to style menu item)
wordpress
i have installed buddypress 1.5.1, wp 3.2.1. the registration field shows 5 mandatory fields to be filled, i need to limit this to 3, my site needs username, email, password( just like in tumblr ), how to remove these mandatory registration fields in buddypress registration. Is their any snippet/plugin to accomplish th...
Finally i did find an hack for this problem Make the field fullname, confirm password as display:none Bind the data from username to fullname and from password to confirm password For eg ( a simple binding example ) <code> &lt;html&gt; &lt;head&gt; &lt;script src="http://code.jquery.com/jquery-latest.js"&gt;&lt;/script...
how to remove mandatory required fields in buddypress registration
wordpress
I'm trying to add more rows in the media picker modal window. Is there any clean way to achieve doing this ? Thanks !
my plugin: http://wordpress.org/extend/plugins/mediapicker-more-rows/ I found a way to fix the pagination There is a way you can 'hook' into paginate_links. There is no official hook for it, but you can change the $wp_query-> found_posts variable. What I did here is 'hooking' into the paginate_links by abusing the medi...
Add more rows on media picker
wordpress
I am developing a plugin. To embed the stylesheet I used <code> wp_enqueue_style() </code> . I want the CSS file to be only implemented at the plugin's page. I have already seen solutions with conditional tags, but neither <code> is_page() </code> nor <code> is_admin() </code> are fitting my request. I am able to imple...
Check out this part of the WP Codex: Loading scripts only on plugin pages . The key is to hook in on the <code> admin_print_styles-{page} </code> action. The {page} part, aka hook suffix, is returned from the <code> add_submenu_page </code> function.
How to check via conditional tags for a single plugin page?
wordpress
Ok here's the solution: <code> &lt;?php $wp_user_search1 = new WP_User_Query( array( 'meta_key' =&gt; 'state' , 'meta_value' =&gt; 'NM', )); $listers1 = $wp_user_search1-&gt;get_results(); $lister_ids1 = array(); foreach($listers1 as $lister1) { $lister_ids1[] = $lister1-&gt;ID; } $ids1 = implode(',', $lister_ids1); $w...
<code> $args </code> is a variable and as such should not be wrapped in quotes in the arguments array of <code> query_posts() </code> . Now that should be what's causing the whole thing to fail. That being said, there are a few more flaws I see in your code: I'd recommend using the <code> WP_Query </code> class instead...
Trying to display posts by authors in with specific user meta
wordpress
I've added a theme options page to my site (in my functions.php file): <code> add_custom_image_header('', 'admin_header_style'); </code> My header.php contains this code, which displays the Featured Image as the banner. If a Featured Image isn't provided it uses the uploaded image banner from the custom image header. <...
Try this: <code> &lt;?php //Custom header // Check if this is a post or page, if it has a thumbnail, and if it's a big one if ( is_singular() &amp;&amp; has_post_thumbnail( $post-&gt;ID ) &amp;&amp; ( /* $src, $width, $height */ $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post-&gt;ID ), 'post-thumbnai...
If custom image header does not exist display text header
wordpress
how can i get Custom taxonomy URL by taxonomy ID outside the loop like get_category_link();
The function you're looking for is: get_term_link(); Here is the Codex entry on it: http://codex.wordpress.org/Function_Reference/get_term_link
Custom Taxonomy link out the loop
wordpress
Using jquery, How do I show a checkbox with the list of tags in the sidebar, and only show posts of the checked tag? I cant seem to find this anywhere
Grab and go, buddy! Had fun figuring this one out :) Create a file and upload to your plugins. Call list_ajax_tags() in theme where you want to display these tags. Modify to suit your needs http://pastebin.com/3eZWEv5K (had trouble formatting the code here)
Jquery checkbox -show posts with checked tags
wordpress
I have single.php rendered within Fancybox. For the purpose of resizing an image within single.php I am obtaining the image height in javascript using: var contentheight = jQuery('.postimage').height(); The first load of single.php within Fancybox successfully populates the "contentheight" variable and I am able to res...
Finally I came up with the solution to retrieve the image height using PHP getimagesize() and printing it as the ID of the image. Later, in JS I used: var contentheight = jQuery('.fluidimage').attr('id'); to retrieve the height and perform the necessary action. Here's the PHP code: <code> &lt;?php $imageurl = $pathtoim...
Determine image height within Fancybox
wordpress
Hi Guys and thank you in advance for giving me some attention with this. I have this code in wordpress that I just can't get right. I have the US states in a drop-down form. When the user chooses an option from the select form and presses the "set new location" button, I need a cookie to be written , containing that lo...
If you don't give the cookie an expires time it will only be available during that session. You will also need to destroy an existing cookie if it is already set. <code> jQuery(function() { jQuery('#categoriesform').submit(function(e) { if (jQuery.cookie('my_cookie') ) { jQuery.cookie( 'my_cookie', null) } jQuery.cooki...
Set a cookie in WordPress, using a select form and Jquery
wordpress
I am looking for a way to remove the attachment link from images in the post content. I would like to add this to the functions.php in my theme. I know you can disable this in the post on a per image basis, but I would like to do this just once in my functions.php page. Any ideas? Thanks, Bart
<code> add_filter( 'the_content', 'attachment_image_link_remove_filter' ); function attachment_image_link_remove_filter( $content ) { $content = preg_replace( array('{&lt;a(.*?)(wp-att|wp-content\/uploads)[^&gt;]*&gt;&lt;img}', '{ wp-image-[0-9]*" /&gt;&lt;/a&gt;}'), array('&lt;img','" /&gt;'), $content ); return $cont...
remove links from images using functions.php
wordpress
I'm using qTranslate for multi-language &amp; wp-commentnavi for comment navigation . The style of my base permalinks are like so: <code> site.com/ -&gt; for default language site.com/en/ -&gt; for other language </code> I need help in regards to the following as they keep redirecting to the default language : 1. Comme...
I've figured out the solution to my problems. Here's what I did... Note: This is considering the posts, thus comments, are under the ' Article ' post-type, which thus create the permalink such as this: site.com/article/post-name/#comments . Adjustments should be made for other uses. To fix problem #1 &amp; #3: <code> i...
Comment submission & navigation redirects to default language
wordpress
I have a custom post type where each post can only be seen on the frontend by one specific user. I have figured out how to make an archive template where only posts with the meta _allowed_user = user_ID are queried. But now I gotta create a meta box that lists all users (pretty much like the author box) so the publishe...
If someone wants to clean this up, all the better, but it gets the job done :) If I understood you correctly, you need the ID for the user, yes? For more info on <code> $wp_user_query </code> check out this post which was a partial resource for me writing this code: http://www.mattvarone.com/wordpress/list-users-with-w...
Create a page Meta Box listing all blog users
wordpress
I’m having some problems understanding an error I’m getting. I have a page which is called “pitch” and as such the URL and the slug should be “pitch” as well, so: www.my-domain.com/pitch/ But when I enter “pitch” it not only gives me a 404-Error, my host (Bluehost) itself makes a redirect to their “splash screen”. I re...
The easiest explanation I can think of is that you have a file or directory in your site's directory named "pitch" (such as public_html/pitch or public_html/my-domain/pitch). This can easily be caused by creating the folder for some reason and forgetting about it later or setting up a subdomain such as pitch.my-domain....
Can’t use a specific custom URL (slug)?
wordpress
I'm looking to put widgets in my plug-in settings page like the ones in the WordPress Dashboard. The action to register the widget is <code> add_action('wp_dashboard_setup', 'register_widgets' ); </code> I wonder if it's possible to do the same for your own settings pages.
You would call: <code> add_meta_box( $widget_id, $widget_name, $callback, $screen-&gt;id, $location, $priority ); </code> Where the screen ID is obtained via: <code> $screen = get_current_screen(); </code> Then display each location e.g. : <code> do_meta_boxes( $screen-&gt;id, 'column3', '' ); </code> Here's the dashbo...
Adding a WordPress Widget to a settings page
wordpress
Sorry for a simple question. I'm learning about plugins. I've got some javascript that I want to put in a jQuery file in my plugin. (I've got jQuery and the scripts enqueued, and working fine). Is it okay if I just prepend the javasvript to the jQuery? So, the file would look like this: <code> //regular javasript funct...
jQuery is regular javascript. It is a js library, meaning nothing but that it is a collection of js functions in an object. Hence, going with your terminology, yes, it can be mixed. That being said, calling <code> jQuery.noConflict(); </code> is superfluous, since the library supplied by wordpress is loaded in noConfli...
Mixing Regular Javascript With jQuery in a Plugin
wordpress
I am having some problems with the Nginx rewrite algorithm for WordPress. I am using this for the rewrite and it works good; <code> server_name www.domain.com domain.com; if ($host != 'domain.com') { rewrite ^/(.*) http://domain.com/$1 permanent; } </code> it makes this url; <code> http://domain.com/?author=1 </code> t...
The correct Nginx rewrite rules for WordPress are: <code> location / { try_files $uri $uri/ /index.php?q=$uri&amp;$args; } </code> This sends everything through index.php and keeps the appended query string intact. If your running PHP-FPM you should also add this before your fastcgi_params as a security measure: <code>...
Nginx rewrite rules
wordpress
I'm making a plugin that counts the number of times a visitor visits my site. I want to run the code in the plugin once per page load. What's a good action hook I can use ?
Basic idea is to use javascript to make an AJAX call back to the site which in turn save the hit because if you use PHP alone, then hits for cached pages won't be counted because no PHP is processed at that time. Study the code of WP-Postviews plugin http://lesterchan.net/portfolio/programming/php/#wp-postviews Edit: H...
Run a plugin just 'once' per page reload
wordpress
I know this sounds complicated, so bear with me. I'm trying to add certain custom css styles based on the shortcodes(if any) in the current post/page. <code> function load_shortcode_styles($posts){ //function to check short codes here //regex to get id from shortcode(e.g [item id=""] ) //get custom post meta from the i...
I can only assume that on the page there are either multiple queries or instances of this post, but eitherway it exposes a flaw in the logic, that you're not checking if the style has already been added. Normally one would use wp_enqueue_script which would sort this out, but for whatever reason you may not be able to d...
Anonymous function is executed twice in wp_head while added from the_posts filter?
wordpress
4th EDIT 11/17/2011 I spoke too soon. Now I have all the posts showing up but the total events does not seperate the events by day after I moved the endif; and endwhile; I posted the modified code below and below this is the previously modified code. Before the count was correct for each day. If I had two events from d...
Just an idea: you could save your time values in an array and then sort it with PHP. Example: <code> $keys = array('opening_time', 'film_time', 'artist_talk_time'); $times = array(); $custom_field_keys = get_post_custom_keys(); foreach ($custom_field_keys as $custom_field_key) { if (in_array($custom_field_key, $keys) {...
Unable to sort wp_query by date/time with multiple meta_key s
wordpress
A friend of mine is investigating the use of WordPress for a dynamic site with some hierarchy. Really, at the moment he just wants "nothing fancier than photos and links between pages," but knowing him, it's going to get more complex from there. The tricky requirement, though, is that he needs to be able to archive the...
Turn on pretty permalinks, and run a spider/archiver on the address of your website. This should give you a static site you can place on a CD/DVD/USB drive. You can use a tool such as http://www.httrack.com/ to do the latter part. If you're on linux you can use the following command: <code> # Mirror website to a static...
Create a Static HTML Site from WordPress
wordpress
I had to uninstall WooCommerce plugin (I deleted the tables it created as well) and now I reinstalled the plugin and I doesn't automatically recreate the WooCommerce Pages. Am I stuck having to manually create the pages myself? Is there a way to have it automatically regenerate the pages?
Just had the same problem. First uninstall the plugin. Then you have to delete all rows containing "woocommerce" in the table "wp_options" on your database. Especially "skip_install_woocommerce_pages". Now install the plugin again. The notification for automatically creating pages will pop up.
How do I get WooCommerce to automatically recreate pages?
wordpress
I have around 30 old posts that I want to delete on my blog. Can I just delete them permanently or should I worry about the "errors" I will get on my google webmasters tools and redirect them somehow?
You should submit a request for Google to stop indexing them as soon as possible (accessible through the Google Webmaster Tools interface). I'm sure you know the purpose of posts, but is is that important to delete them? You could just leave them as an archive as posts were originally meant for. If you don't link to th...
Deleting old posts
wordpress
i'm using wp_nav_menu to generate a navigation menu for my theme. It works fine by selecting my created menus. But, what if i want to generate a list from my already created pages and subpages in wordpress ? I tried using wp_page_menu, which does what i want, but i cannot pass a css class parameter to the inside ul, in...
I faced that problem in the past, however I remember my problem was the first link didn't have a class, after some research I solved it working with a structure similar to this one, take a look and let me know if it works :) <code> &lt;ul&gt; &lt;?php wp_list_pages('title_li='); ?&gt; &lt;/ul&gt; </code> UPDATED....
wp_nav_menu with default pages menu
wordpress
I am looking for some modules that implement add meta box as shown here perhaps with some ajax magic. If you have any modules I could check out would be welcome.
I recently published a meta box class named <code> My Meta Box </code> which takes care of most of the metabox creation and data saving and that was forked out of from Meta Box script by Rilwis. Using the class is simple eg: <code> &lt;?php require_once("meta-box-class/my-meta-box-class.php"); if (is_admin()){ /* * pre...
Modules with meta box implementations
wordpress
When I load this URL on my WP e-ecommerce site, it 301 redirects to page 4 which does not exist, and appears as a page with empty contents: Go to this URL: http://comfortboost.co.uk/new/?wpsc_product_category=bath-hoists And there will be a 301 redirect to: http://comfortboost.co.uk/new/?page_id=4&amp;wpsc_product_cate...
I really hate the wp-e-commerce plugin. It turns out that the only products in that category were 'pending', i.e. not published yet. Even if they were moved to trash, and 'hide_emtpy => 1' was used on the categories list, the error still occurred. Only when the products were completely emptied out of the trash did the ...
Why does the first page of one category redirect to empty page 4?
wordpress
I'm starting to love this place more and more, super helpful! Anyway, todays dilemma is as such: I want to display as a list the child terms only, of a specific parent term, of a custom taxonomy, that apply to the current ID within the loop. As such i want to print the children terms of the parent term 'Mens' for the t...
For actual categories: <code> &lt;ul&gt; &lt;?php global $post; // grab categories of current post $categories = get_the_category($post-&gt;ID); // define arguments of following listing function $args = array ( 'child_of' =&gt; $categories[0], // current post's (first) category 'title_li' =&gt; '' // disable display of...
Display Child Categories of Current Post ID
wordpress
I'm building a small tracker and need to send mail notifications on specific actions. Thought-out notifications: Administrator gets a notification email when a new ticket is published Author gets a notification email when the ticket is updated Author gets a confirmation mail when the ticket is published Each notificati...
Unless for some reason you need this to be hardcoded into your theme or have full control over your own plugin, you could use the existing Peter's Collaboration Emails plugin. If installing a plugin is not an option, I'd suggest modifying the above or borrowing some of its code, respectively. It can do all the things y...
3 different mail notifications
wordpress
I'm developing a custom theme which uses categories for positioning, all of which begin with an underscore (e.g. _position1). I have an SQL query as below to get a list of these categories (those starting with an underscore). <code> SELECT name,term_id FROM `wp_terms` WHERE name LIKE '\_%'; </code> How would I go about...
If you use the built in <code> get_terms </code> function you end up with a quick one liner: <code> function get_positional_ids(){ return get_terms( 'category', array('fields' =&gt; 'ids', 'name__like' =&gt; '_')); } </code> no custom SQL, safe and simple.
Wordpress Categories: Function using custom SQL to return array of specific category IDs
wordpress
I am working on a plugin which uses Wordpress Settings API. I notice that the functions <code> do_settings_sections </code> (and <code> do_settings_fields </code> ) display the fields using TABLE. How do I change its formatting? (I want to use DIV instead of TABLE)
There are no hooks to modify the output of <code> do_settings_sections() </code> . Hence the only option you have is to write custom versions of the functions <code> do_settings_sections() </code> and <code> do_settings_fields() </code> . They are located in /wp-admin/includes/template.php , lines 1159-1174 and 1190-12...
Change the display of Settings API (do_settings_sections)
wordpress
I wrote a small WordPress plugin ( mobileesp-for-wordpress ) that will redirect mobile users to the mobile site. It's based on mobileesp . The plugin itself works fine the problem is I added an option to view the full site. This function works by checking for a cookie and if the cookie is there don't redirect the user ...
The <code> setcookie </code> function prepares the HTTP cookie header to be sent at the next page load. That's why the <code> $_COOKIE </code> superglobal is not updated automatically. You could manually update <code> $_COOKIE </code> for use on the current request. Just put this below your <code> setcookie() </code> l...
Set cookie then immediantly refresh the page
wordpress
Before I finally start blogging there's one last question that I need help with. My blog will be photo-focused. We're talking about 70-80% of photos compared to 20-30% of text. There might be some posts with up to 60 photos a ~200KB/file (~600px width). I might also provide a clickable link to a larger version of the p...
You can keep your whole site together, i.e. texts and images, the main suggestion: just don't mix up large image/galleries with your text stream, this will indeed slow down your site loading. While most bloggers want display their pictures at any cost, most visitors just want read a specific text, then this approach be...
Best option for photo/gallery handling?
wordpress
How do I reset a query that generates a list of categories with wp_list_categories? The query below builds a two column list of categories that is then displayed with the second code chunk. I'm using two of these queries (with different category include strings) in a jQuery tab to display different lists of categories....
<code> wp_list_categories() </code> is a simple function that returns (or echos, depending on parameter) a list of links to category archives. It needs not to be reset. When you create a new instance of the <code> WP_Query </code> class you need to reset postdata, because Template Tags otherwise use that query and not ...
How do I reset this wp_list_categories query?
wordpress
I need to attach meta data to every menu item, with a key 'foo'. Is it possible to do that, without editing core WP? A quick look at the nav-menu files showed that no hooks exist near the place I want to add the input box (below Description, here - http://cl.ly/0v2Z0X1n2e1L431t0h1G )
here is a quick code that should do the job, paste this in your theme's functions.php file basically what it does is hide all regular class input boxes and adds a new select dropdown which changes the value of the hidden input based on the selected value. and it looks like this; <code> function menu_item_class_select()...
Add custom meta to nav menu items
wordpress
Working on upcoming events list that returns posts fine in a custom query. In the custom post type 'event' there are multiple events within a date range. I want to display all upcoming events in order. This I can do but I also want to count the events for each day. Right now I am using found_posts to return the post co...
I came up with a way using two post queries. The first one runs through the loop and adds 1 to a variable called $counttest. Then it echos that value and resets it to 0 to begin the count for the next date. This probably isn't the most efficient way to do things. If anyone knows a better way then please let me know. <c...
Count of posts with meta_key filled in?
wordpress
My current code in functions.php: <code> echo '&lt;div class="post_date"&gt;'.the_time('d', '&lt;div class="month"&gt;', '&lt;/div&gt;').the_time('F', '&lt;div class="day"&gt;', '&lt;/div&gt;').the_time('Y', '&lt;div class="year"&gt;', '&lt;/div&gt;').'&lt;/div&gt;'; </code> But it only returns: <code> 20April2011 </co...
Please see this documentation for the usage about <code> the_time() </code> . You are not supposed to add html inside the parameter of <code> the_time() </code> . (edit: use <code> get_the_time() </code> with in string concatenation) To solve this, try this code: <code> echo '&lt;div class="post_date"&gt;&lt;div class=...
How can I wrap html around the output of the_time function?
wordpress
I am trying to search for posts in specific taxonomies but any time I search, I get results from all the other pages instead of Wordpress searching within the selected category in the taxonomy. I named my taxonomy: "publication_categories". It contains all categories for a custom post type which I named "publication". ...
I see a few problems with your code. you are missing post_type field in your form. the name of the taxonomy dropdown should be the name of your custom taxonomy. the form method is set to GET yet you check the selected with POST. so your form should look something like this: <code> &lt;form method="get" id="searchform" ...
How do I search inside specific taxonomies in Wordpress
wordpress
I have an issue that I believe can be solved one of two ways. I am using Featured Images in posts for content on a home page slider. What I would like to have happen is to have the destination links on click to be custom. Not the post or image URL of the post/featured image being used to feed the slider. 1) I thought I...
I cleaned up the code u have given and it should work as you intend. Let me know if your still having problems. <code> &lt;div id="slider"&gt; &lt;?php $c = get_option('wpns_category'); $n = get_option('wpns_slices'); $s = new WP_Query( array( 'cat' =&gt; $c, 'posts_per_page' =&gt; $n ) ); if( $s-&gt;have_posts() ): wh...
Unable to set Custom "Link URL" for Featured Image, and More?
wordpress
I need to clean any links returned from the_author_meta('description') The code I use is simply that: <code> &lt;p&gt;&lt;?php the_author_meta('description'); ?&gt;&lt;/p&gt; </code> I Searched old question but could not find the right anwer.. ideas anyone?
<code> &lt;?php // grab description, // note the "get_", we're not echoing the author meta, we're returning it $user_description = get_the_author_meta('description'); // removing all HTML tags: echo strip_tags($user_description); // removing all tags apart from paragraphs: echo strip_tags($user_description,'&lt;p&gt;')...
Clean links in: the_author_meta('description')
wordpress
I'm sorry if this is an extremely stupid question. I've been looking for ways how to secure my WP and a lot of websites suggest to create a new admin user account and delete the old one. Now, if I use a different screenname as author (when writing comments etc.) - how could hackers still find out what my admin username...
Sorry, if your username isnt admin (older versions) you really dont need to do that. What i would reccomend is for you to install 2-3 plugins ordered here by their importance: wordpress firewall 2 Limit Login attempts Wp Security Scan Wordpress Firewall should stop must hack attempts directly on your site, Limit login ...
Secure Wordpress: Change admin
wordpress
The site that I am working on uses the following "pretty" permalink structure: <code> http://example.com/blog/my-special-post </code> But for a custom post type my client would like to avoid having a "pretty" slug: <code> http://example.com/product/142 </code> How can the post ID be used in place of the slug for the cu...
This is what I use to rewrite custom post type URLs with the post ID. You need a rewrite rule to translate URL requests, as well as a filter on <code> post_type_link </code> to return the correct URLs for any calls to <code> get_post_permalink() </code> : <code> add_filter('post_type_link', 'wpse33551_post_type_link', ...
How to rewrite URI of custom post type?
wordpress
I noticed when you typein the user's “biographical info” on the profile, it shows up in one page! Looks really terrible. So: Is there a way to use tinyMCE or other solution for user “biographical info” without messing with any core file, and without any plugin? Thanks a lot.
Just adding this to the theme's functions.php solve the problem (prevent stripping of the html from the author's bio): <code> remove_filter('pre_user_description', 'wp_filter_kses'); add_filter( 'pre_user_description', 'wp_filter_post_kses' ); </code>
How to use tinyMCE for user “biographical info” without messing with any core file?
wordpress
I'm building a program registration system that will have a complex data structure. There are programs (custom post type, CPT), teachers (CPT), registrations (custom table and meta table), payments (custom table and meta table), and later accommodations (CPT) and lastly Users (wp users table). I want to be able to use ...
You can assign taxonomies to objects saved in tables other than the posts table. WordPress explicitly supports that (e.g. there is the function <code> _update_generic_term_count </code> to update the term count for those types of taxonomies) and even use it for links. I have used it once. Just register your taxonomies ...
using custom taxonomies on non wp table?
wordpress
I want to allow the admin of a site i'm building to highly customize the wordpress user. This will be a highly advanced plugin so I'm fine creating a whole new page in the admin to do this customization (to avoid the weak hooks in the current user admin page). My question is this: how can I enable the admin to easily c...
There is an excellent plugin solution for this: CIMY user extra fields I'm all for control and pro writing your routines, if ready-made solutions are not 100% satisfactory, but in the case of extended user profiles I have never seen the need. I am using this plugin myself on 2 production sites, very happy with it.
customizing wp user with custom fields
wordpress
Is there any way to make my plugin work based on a URL instead of creating a page and attaching a shortcode? IE http://mysite.com/myplugin and that would bring up the starting page of the plugin
You can do this by using the actions generate_rewrite_rules &amp; template_redirect more info can be found at http://wp-fun.co.uk/2007/12/24/creating-custom-urls/#axzz1dXkrd62P
Making a Plugin work based on URL Location
wordpress
I am creating a functionality in WordPress where I need to create a new php page and have to link it in the menu section of my website. Though I can create a page from the dashboard but due to some reasons that option has been discarded. Aim is to create a new page and link it with my existing site. I have created a pa...
I think I understand what you want. You want to add a page to the current theme and for it to appear in the menu. If your page template has a different layout or function than existing ones you can add a custom page template like so: <code> &lt;?php //This part is required for WordPress to recognize it as a page templa...
Create a new page in WordPress theme
wordpress
I have started work on an open source theme framework that pulls in lots of great code &amp; resources from elsewhere. For example it uses: jQuery Option Framework Theme LESS etc etc. Most of these external projects are hosted on Github or SVN. Rather than continually download and integrate the latest versions of these...
What you're looking for is git submodules : Git's submodule support allows a repository to contain, as a subdirectory, a checkout of an external project. PS: Always try to use the jQuery bundled with WordPress.
Tips for managing code when developing a parent theme framework
wordpress
I'm learning how to write a plugin. My plugin is a google map that places markers based on the selected criteria. It works fine. The problem is that it interferes with one part of the theme I'm using. The theme is called Superb. The theme has a uBillboard, basically, it's a slider. For some reason, my plugin prevents t...
The most common problem are JavaScript conflicts, you can debug this by making sure you are using no conflict wrappers . Another thing you can adjust is the load order, sometimes there are errors when one script is loader before/after another. If you are relying on many 3rd party scripts it can be difficult, you might ...
How to Debug: My Plugin Interferes With My Theme
wordpress
I'm very confused. What i did was change my hostfiles so i can access my website on an alternative website and checked it in case i had hardcoded values (i did and they were corrected). I had to use the defines below to get the check to work <code> define('WP_HOME','http://example.com'); define('WP_SITEURL','http://exa...
Nevermind, i actually accidentally didnt put back the url in nginx config file so i only had the new url. I wonder why i got a DB error instead of my generic "Nothing to see here" page
Wordpress database nonsense error
wordpress
How can I change the site's bloginfo description in runtime from a plugin? I tried these, but none of them work: <code> add_filter('description', 'ab_arq_generate'); add_filter('blogdescription', 'ab_arq_generate'); </code> My point would be to make a random quote in the place of the description regardless of the actua...
You're lookign for the <code> bloginfo </code> filter. <code> &lt;?php add_filter( 'bloginfo', 'wpse33522_change_bloginfo', 10, 2 ); function wpse33522_change_bloginfo( $text, $show ) { if ('description' == $show) { $text = 'Some New Description'; } return $text; } </code>
Changing bloginfo description from a plugin
wordpress
Is it possible after a certain amount of posts to close of a list and start a new one, like so... Particularly after 6 posts... <code> &lt;ul id="carousel"&gt; &lt;li&gt; &lt;ul class="inner-items"&gt; &lt;li&gt;Post content&lt;/li&gt; &lt;li&gt;Post content&lt;/li&gt; &lt;li&gt;Post content&lt;/li&gt; &lt;li&gt;Post c...
You could use the following and it should do exactly what you want by checking the value of <code> $loop-&gt;current_post </code> . <code> &lt;?php $loop = new WP_Query( array( 'post_type' =&gt; 'work','posts_per_page' =&gt; '-1' ) ); ?&gt; &lt;ul id="carousel"&gt; &lt;li&gt; &lt;ul class="inner-items"&gt; &lt;?php whi...
Insert html after certain amount of posts?
wordpress
This question follows on from: stackexchange-url ("Can you do a date comparison on a custom field and query two or more custom taxonomies using WP_Query?") and a similar thing here: stackexchange-url ("stackexchange-url I'm trying to compare a start and end date which are custom fields in a post type of exhibitions whi...
This: <code> date( 'Y-m-d', strtotime('-6 hours') ); </code> Is going to spit out something like <code> 2011-11-11 </code> If your date picker is using the format <code> dd-mm-yy </code> , then comparing the two is not going to work. <code> dd-mm-yy </code> , if it's what's in the field on post save/update, is what's g...
Problem with date comparison for custom fields
wordpress
I tried to find a tutorial to do that points to title . I could only find one tutorial several times, but it doesn't work for me. The tutorial is posted in various blogs, so I thought it's working (e.g. here ). It's not. I'm posting it within my single.php and I get the following error messages: <code> Warning: SimpleX...
Chances are your server has magic quotes turned on. Try changing line 76 to: <code> $xml = new SimpleXMLElement(stripslashes($data)); </code> (via DGrigg )
Display feedburner subscribers count in single.php
wordpress
I would like to create a custom post type, but all the tutorials I've found are geared towards making a brand new one and creating meta boxes from scratch. Whereas all I would like to do is copy an existing and add one or two extra entities. I would like to go through the motions of creating a new post type because it'...
If you created a new post type, it would behave like a post unless specified. The problem you have is that the 'post' post type is built in. I suspect you want the other post type to simply be another type of post, and show up in the archives etc etc This isn't possible with a custom post type, and the Wordpress develo...
Create a custom post type based on 'Post'
wordpress
I've run into a bit of a perplexing challenge. I'm working on a WordPress installation where certain posts, without a yet apparent rhyme or reason, throw a white screen when you attempt to edit them in the admin area. Its a large site with lots of plugins. I've tried disabling all plugins to see if that made a differen...
I wound up doing a repair database via phpMyAdmin and that solved the trouble.
Troubleshooting white screen when editing specific posts
wordpress
We have a live site that is using one theme. Then I've got Wordpress Mobile Pack installed to enable a mobile theme which has different functionality and look. The problem I'm running into is that the live site uses a CPT for a "specials" page. This obviously has to be updated in the permalink structure in order for th...
Once again I answer my own question. For anyone having issues...it's flush_rewrite_rules(); Just tag it onto the end of your CPT and VOILA! PRESTO! SHAZZAM! I found it after much searching and much heartache so hopefully someone else will come along and find this helpful.
How do I use CPT and permalinks with a mobile theme?
wordpress
I have a feed from an events calendar that once put in the WordPress RSS widget displays the feed items in reverse chronological order. So the events that are farthest in the future display first, and the events that are coming up soon are displaying last. We are only displaying the title from the feed (the event name)...
This should do the trick. Put the following code in your functions.php and then check out the RSS Widget. It will have an option to reverse the order of the feeds. <code> /** * RSS widget class */ class Reverse_Widget_RSS extends WP_Widget { function __construct() { $widget_ops = array( 'description' =&gt; __('Entries ...
How to reorder and display a feed to be chronological?
wordpress
Is it possible to get page's metabox value within shortcode that is executed on that page? Scenario: I have a sidebar metabox for every page. I have some kind of custom gallery shortcode. My gallery shortcode outputs 600x200 images (I'm using timthumb here). BUT I want it to display 900x300 if there's no sidebar. Norma...
<code> $post </code> is outside the scope of your shortcode function, you have to globalize it first: <code> global $post; $sidebar = get_post_meta($post-&gt;ID, 'metabox_sidebar', true); </code>
Getting metabox value within a shortcode?
wordpress
I have a drop down menu that displays all of the terms for one of my custom taxonomies using get_categories (). It displays fine in alphabetical form. However, what i want to know is how can i have the terms listed in a hierarchial form in a drop down menu, so they appear like this - Parent Category 1 Child One Child T...
<code> wp_dropdown_categories </code> has a hierarchical and depth options available. <code> $args = array( 'show_option_all' =&gt; 'All Tshirt Categories', 'orderby' =&gt; 'ID', 'order' =&gt; 'ASC', 'hide_empty' =&gt; 1, 'child_of' =&gt; 0, 'hierarchical' =&gt; 1, 'depth' =&gt; 1, 'taxonomy' =&gt; 'tshirt_categories',...
Help with a get_categories () drop down menu - I want it to show in heirachial form
wordpress
What function can I use in a plugin to get the dimensions of every image size (in an array preferably) that is defined in a child theme? Just for clarification I am not asking how to create a new image size.
stackexchange-url ("Found it here"). The answer is: <code> global $_wp_additional_image_sizes; print '&lt;pre&gt;'; print_r( $_wp_additional_image_sizes ); print '&lt;/pre&gt;'; </code>
How to get a list of all the possible thumbnail sizes set within a theme
wordpress
I have installed lightbox plus plugin. I want to display my video in a popup. Or you can suggest me any alternate plugin that can display my video in a pop up. video source is from my own local server.
I will suggest you to use pop up generator plugin.
embed video and display in pop up
wordpress
So I recently moved my site to a new server, and now some of my plugins will show only if you are logged in as admin, but will not show to the regular user. However, some plugins still show and work fine. I have already reinstalled and that hasn't done anything. Any ideas? Thanks!
I found the issue. The problem was that there were two plugins I was using (A facebook likebox and a twitter plugin) and apparently these plugins are pretty well known to break other plugins on the site if they are installed. I removed those to plugins and then the rest of my plugins all started working fine.
WordPress plugins not showing after switching servers
wordpress
I am using 20-11 theme and i have the sidebar on the left, the main content center and now i would like to edit a php file (or not) to make a 3rd div to the right of the content. I'm unsure how i'll edit/style that. But my bigger question is after i get that part done, how do i say on this page use this image in that b...
Well... Buidling a second sidebar is a matter of CSS &amp; HTML... all i can say about that is that you should think of the structure you want, then create a div before or after the content (Depends on the position) and change othere containers sizes so they would all fit. If you got something like this: <code> &lt;!--...
How do i put a per page theme in a special box/div?
wordpress
I'm currently trying to implent a new custom column at the page manage screen that will let me change the status (published/pending) of the different pages via an easy toggle link. From what I've gathered I need to use $post-> post_status, ' status 'in someway, probably toggle with jQuery or something. But I can't figu...
here you go: <code> &lt;?php /* Plugin Name: ajaxed-status Plugin URI: http://en.bainternet.info Description: answer to : Custom column for changing post status via ajax stackexchange-url 1.0 Author: Bainternet Author URI: http://en.bainternet.info */ if ( !class_exists('ajaxed_status')){ class ajaxed_status { //consta...
Custom column for changing post status via ajax
wordpress
When i imported all posts and media from a old site to new site which on wordpress multisite. The image links on posts are got broken because how media are stored on a multisite is quite different from a single installation wordpress site. And also the links in the contents are static so it don't change when imported. ...
Try <code> Search and Replace </code> plugin which is A simple search for find strings in your database and replace the string. You can search in ID, post-content, GUID, titel, excerpt, meta-data, comments, comment-author, comment-e-mail, comment-url, tags/categories and categories-description.
Fixing media links after importing to multisite
wordpress
Below is the code i use to output the post tag (taxonomy) count/number. I want to be able to split the count based on post type that the taxonomy features in (rather than the total number). So i have the default "post" Post type, aswell as "blogs", &amp; "pics". I want the taxonomy count to display something like: x po...
I needed to get the number of post per type per term so i created this small function: <code> function get_term_post_count_by_type($term,$taxonomy,$type){ $args = array( 'fields' =&gt;'ids', //we don't really need all post data so just id wil do fine. 'posts_per_page' =&gt; -1, //-1 to get all post 'post_type' =&gt; $t...
Taxonomy count per Post type
wordpress
Does anyone know why some of my websites add a blank line after every line of code, while others on the same host and server leave the files untouched? A few details that might help: PHP Version 5.3.5 Linux Servers MySQL- Client API version 5.1.56 SERVER["HTTP_ACCEPT_CHARSET"] (ISO-8859-1,utf-8;q=0.7,*;q=0.7) NOTE : I ...
I think the difference is probably something to do with the editor you use to edit files, and specifically the line ending characters. DOS machines (like Windows) use a carriage return character and a line feed ("\r\n") as a line ending, and Unix-based machines (newer Macs and Linux included) use just a single line fee...
Cause of Blank Lines Being Added to WP FIles?
wordpress
I've got User Role Editor plugin installed and i want to add a capability for download files. I've got some downloads in a custom post type called 'products'. I want only people who are logged in to be able to download or view these files. If a user isn't logged in they get redirected to a login/registration page, then...
Since you're just checking to see if they are a logged in use, you can just use the <code> is_user_logged_in() </code> function to check if they are logged in and if so, display the download link, if not, don't display the download link.
User role editor - Add download files capability
wordpress
With the 20-11 theme i would like to make the sidebar one long color. I have no idea how long my page are and i need the sidebar height to be the same as the post height. Right now when i do <code> #secondary { background-color: green; } </code> the green is only as long as it needs to be so it is extremely short. How ...
The simplest way to create the solid color side bar is with this CSS: <code> #branding { background-color: #ffffff; } #page { background: #ffffff url(path_to_image) repeat-y; } </code> Replace #ffffff with the appropriate color used in your template (if they are different). The "path_to_image" would need to be pointed ...
How do i make a sidebar background color?
wordpress
I'm working on a CPT but I need to have more control over the layout of the post/edit page (post-new.php and post.php). I thought hacking through admin_init would be the best option, but I can't get the script to work at all. Help? <code> function init_shelf_page() { if (!current_user_can('edit_shelves') &amp;&amp; $_S...
I suggest you just don't use the standard post editing UI. When you register your post type, there's an arg for showing the admin UI. <code> &lt;?php register_post_type( 'some_type', array( // stuff here 'show_ui' =&gt; false ) ); </code> Then just create your own admin page and do whatever you need to do with the inte...
Custom admin post.php page
wordpress
I've setup a custom post type with a series of custom fields using the WPAlchemy class. I'm trying to take the value of one of the custom fields and use that as the post title. So far, though, I've had no success. I've been browsing around and I've tried the following two different blocks of code: <code> function custo...
So, every time you save a post, you want to replace the value of a title that just got saved with another value from a custom field... Seems like you should just put whatever you what the title to be in the actual title field. BUT I'm assuming this is for presentational purposes: you want that custom post type to displ...
Using custom field as custom post title
wordpress
I need to add ratings to a page for a few different fields (ex: color, quality, etc.) - not just per post or comment. I'm generating the page using a template, so I have access to the php file that generates the html. Is there any pre-existing rating plugin where I can add the rating feature anywhere on the page? (For ...
You should install the plugin and reference it inside of a function within your theme. Be sure to check to make sure the expected plugin/function actually exist. Then you can just use it's functionality as you see fit!
Dynamic Rating Plugin to Add Anywhere
wordpress
I have a series of categories on my website that are fixed, i.e. The client has specifically asked that I leave them. Now however, they would like me to add an events plugin so they are able to add events. Every plugin I've found insists that you create your own event specific categories, thus losing the permalinks str...
My plugin ( amr-events ) will work with existing categories (and you can choose standard posts or custom post types) There is also a way to convert any existing posts into 'event' posts in case there is alot of content already built into a post for an event. It is a paid plugin (the free version at test ) works with ic...
Events Plugin that works with existing categories?
wordpress