question
stringlengths
0
34.8k
answer
stringlengths
0
28.3k
title
stringlengths
7
150
forum_tag
stringclasses
12 values
I want to develop a plugin that generates a page and embeds the page link in pages menu in the client part at the time of plugin activation. Please help me with this.
You can create the page using wp_insert_post() and make sure you send post type as 'page'. and if the user nav menu uses wp_list_pages the page will be added to the nav menu automatically and to run it on activation you can have you plugin check if it exists and save its id so it will only create it once. <code> $my_pa...
How can I develop a plugin that generates a page dynamically
wordpress
I set <code> add_filter( 'http_request_redirection_count', array($instance,'SetDirectionCount')); </code> to 0 I try to get 'http://boards.ign.com/The_Vestibule/b5296/' or 'http://www.informationweek.com/story/' but that gives me: <code> WP_Error Object ( [errors] =&gt; Array ( [http_request_failed] =&gt; Array ( [0] =...
Taking a look at the WordPress HTTP API, it seems there ain't no simple way to do this. In fact, it might even be a calling for a trac ticket. See, although it allows you to specify the maximum number of redirects, there's no abstract option to control if redirects should even be followed . So setting a max redirect co...
Wp Remote get with manual redirect
wordpress
I am reading the book Professional Wordpress, and have code like <code> $title = apply_filters('widget_title', $instance['title']); $name = apply_filters('widget_name', $instance['name']); ... </code> I wonder if there really are filters like <code> widget_xxx </code> ? What do they do?
For example, it makes them editable using the Front-end Editor plugin. All the cool widgets are doing it: http://core.trac.wordpress.org/browser/trunk/wp-includes/default-widgets.php
Is there a need to do apply_filter('widget_title', $instance['title']) or any other 'widget_xxx' filters?
wordpress
I read the following tutorial, which mentions moving your config file out of an HTTP-accessible folder. http://codex.wordpress.org/Hardening_WordPress#Securing_wp-config.php I did this, and it works fine. And when I visit http://mysite.com/wp-config.php , I see a blank page, as expected. However, when I visit http://my...
Hm, core WP files are usually die properly if opened directly. It probably slipped developers to include check in this one or something. The simple ways to fix this (and not really WP-specific) would be to: configure PHP on server to not display errors by default; restrict access to file with .htaccess or other means.
Securing wp-config leads to sensitive information leak on wp-settings
wordpress
I have a custom post type Holiday associated with a taxonomy Country. On my single-holiday.php, I use the taxonomy to display in the title. For example Holiday in Spain (Spain being the tax) Rarely, but it can happen, a holiday can be in 2 taxonomy terms. Creating a problem for my title display as I use get_the_terms. ...
you can change you code a bit : <code> $taxonomy = 'country'; $terms=get_the_terms($post-&gt;ID,$taxonomy); if($terms) { echo '&lt;h1&gt;Holiday '; $total_count = count($terms); $country_count = 1; foreach( $terms as $termcountry ) { if ($country_count = 1){ echo 'in '.$termcountry-&gt;name; }else{ if ($total_count = 2...
Get_the_terms restrict output
wordpress
Is there a list of the ID's and Classes I can give HTML elements in the admin panel in order to closely mimic the wordpress look and feel?
Onextrapixel's blog post How To Design And Style Your WordPress Plugin Admin Panel isn't an official reference, but it is a nicely detailed one.
Wordpress Plugin Look & Feel
wordpress
I've removed "Title" from a custom post type that I created. Which makes it that all new posts gets the name "Auto Draft". To get around this I want to be able to fetch a value/post name from a meta box and save that as the new title. Is this possible? This is what I'm using, and the value of this meta should be the ne...
Even though you've disabled <code> title </code> for your custom post type, if you use the post name <code> post_title </code> for your own title input, WordPress will still use it and update the post title accordingly.
Automatically set post title to same value as a meta box
wordpress
Is there a way to make Wordpress' "Remember Me" login checkbox work for a really long time, like a year? Currently I think it only works for a few days or a week max, usually I am not remembered.
I think I'll wait for such a plugin Save this code in a file named <code> set-cookie-expire.php </code> and upload it your plugins folder. The plugin will give you the ability to set a time (in days) that cookies expire within the WordPress Settings admin. <code> &lt;?php /** * Plugin Name: Set Cookie Expire * Version:...
Make my wordpress blog remember my login "forever"
wordpress
WordPress has a built in function to display a list of all of your site’s authors. But there is no option to display their avatars, so all you really get is a text list that links to the author’s page, if you have an author.php file in your theme, that is. thus turning the internet I found this nice tutorial bavotasan....
I have modified WP_LIST_AUTHORS to paginate. I don't know if its very sexy, and seems to require some sort of Caching plugin otherwise this particular page can start to load pretty slowly. The full code of my paginated function is in this thread: stackexchange-url ("Modifying WP_LIST_AUTHOR Functions to output all user...
Authors list Pagination?
wordpress
i'm using wordpress v3.1 and i'm requiring 2 extra fields for external url + youtube-link. is it possible? in case it's not - i was considering using own tags for the post-content and filter it out. btw. what's the easiest way to implement youtube videos (via link) directly into the post? thx
http://voodoopress.com/2011/03/adding-meta-boxes-to-your-post-screen/ Is a post I wrote the other day about adding meta boxes. I use it to put links in to change the link some of my post titles use. I'm not sure if this is what you are looking for exactly, as I'm not quite sure what you mean by 'extra fields'
extra post fields for url + youtube video / implementation
wordpress
I'm currently using the_post_thumbnail(); to display featured images in my pages. Is it possible to set a fallback placeholder image in the event a featured image hasn't been set?
You can use <code> has_post_thumbnail() </code> as condition and change output accordingly. Example from Codex: <code> if(has_post_thumbnail()) { the_post_thumbnail(); } else { echo '&lt;img src="'.get_bloginfo("template_url").'/images/img-default.png" /&gt;'; } </code>
Featured image/thumbnail fallback placeholder image
wordpress
<code> &lt;?php $post_type = get_post_type( $post-&gt;ID ); if $post_type == 'project' : echo 'Work'; ?&gt; </code> How can I make the above work? I want it so that if the post type is 'projects', then it echoes 'Work'. Also, I want to add another <code> if post type is 'movies' then it echoes 'Film' </code> on top of ...
Well, as far as I can tell you've got a syntax error there. Try this: <code> &lt;?php $post_type = get_post_type( $post-&gt;ID ); if ($post_type == 'project') echo 'Work'; ?&gt; </code> Also, make sure to check out what eileen.carpenter said in the comment to your question.
How do I echo the post type?
wordpress
I'm trying to optimize my header and I was wondering which plugin would call jquery. Is there a debugging tool to know which plugin is doing what in the header ? Thanks !
Plugins and themes tend to use <code> wp_enqueue_script() </code> to queue up scripts for the <code> &lt;head /&gt; </code> of your theme. I would rarely advise this, but since you only need to do it temporarily, you could modify WordPress core and run a debug backtrace for every call to this function. In <code> wp-inc...
Know which plugin is calling JS in wp_head()?
wordpress
My site is using a short vanity URL and https (for admin logins). This is working across all of the custom theme pages in every browser except Internet Explorer. Specifically in IE7, every page I visit in the site presents this warning message: Security Information This page contains both secure and non-secure items. D...
Yes, your page(s) are loading images, CSS, or JS files that are called in the HTML via non secure mode (http versus https). Install the Firebug extension on your Firefox browser and look at your URLs that are loading in network tab. Screenshot: https://skitch.com/noelsaw/rww31/fullscreen Or you could use Pingdom tools ...
Internet Explorer "Security Information" on every page in https site
wordpress
The following code should read: If the current custom post type (bbp_forum), is the one being displayed, assign the class 'current' to its respective <code> &lt;li&gt; </code> tag. But for some reason the class 'current' (to highlight the current <code> bbp_forum </code> link) is being displayed in all the <code> &lt;l...
The expression will always be true. Take a look at <code> get_the_ID() </code> ; <code> function get_the_ID() { global $post; return $post-&gt;ID; } </code> So your code is effectively running as; <code> if ( $post-&gt;ID == $post-&gt;ID ) // always true! </code> Instead, cache the ID of the main post in a variable, th...
Conditional if statement ($post-> ID == get_the_ID) not working
wordpress
I have 2 customs post type : "Artist" and "Concert", the "Concert" custom post type is the child of the "Artist" custom post type, the "Artist" custom post type has a "genre" taxonomy. What I'm trying to do (for instance): list all the concerts which belong to artists of the "pop" genre. Here is the query of my dream: ...
What I'm trying to do (for instance): list all the concerts which belong to artists of the "pop" genre. You can do it in two steps: <code> // 1. Get all the pop artist IDs $artist_ids = get_posts( array( 'fields' =&gt; 'ids', 'post_type' =&gt; 'artist', 'genre' =&gt; 'pop' ) ); // 2. Get all the concerts associated to ...
How to get the parent's taxonomy?
wordpress
Now that wordpress 3.1 is out, where is the documentation for grouping custom post types together in the wp backend?
If you are wondering how to group multiple post types under one menu, you can easily do this with the <code> show_in_menu </code> argument when setting up your menu. See below: <code> $args = array( 'public' =&gt; true, 'show_ui' =&gt; true, 'query_var' =&gt; true, 'rewrite' =&gt; true, 'capability_type' =&gt; 'post', ...
Now can I group custom post types together?
wordpress
OK, I can create the code to add custom widgets to the widgets manager. Check. My next challenge is to, in the same plugin, during activation, check for the existence of my theme, and if active, pre-populate the widget areas with the custom widgets I've just created. I hope this makes sense. If I can do this, it will s...
Sidebars are registered in the option <code> 'sidebars_widgets' </code> . To see what’s in and what not, try this: <code> add_action( 'wp_footer', 'show_my_sidebars' ); function show_my_sidebars() { $sw = get_option( 'sidebars_widgets' ); print '&lt;pre&gt;' . htmlspecialchars( print_r( $sw, TRUE ) ) . '&lt;/pre&gt;'; ...
My plugin creates custom widgets, How can I programatically add them to existing sidebar widget areas?
wordpress
I love markdown, and I have the Wordpress markdown-for-wordpress-and-bbpress parsing markdown in my posts and comments. However, I've noticed that Wordpress saves the comments rendered in html format. This makes it more difficult to go back and edit comments. How can I get wordpress to save comments in markdown format?...
This is a tricky one, but very doable. After looking at Mark's Markdown on Save plugin which does the exact thing you want but for posts content instead of comments i started thinking, that saving the comment content as Markdown would be bad because you would have to render the Markdown to HTML on-the-fly for each comm...
How can I get Wordpress to save comments in markdown format?
wordpress
I'd like to be able to automatically uninstall certain plugins if they're detected (specifically Akismet and Hello Dolly), either by writing another plugin to do so or via my theme's functions.php file. Is that possible?
Sure, just call the delete_plugins() function, found in <code> wp-admin/includes/plugin.php </code> - you have to manually require() it.
Is it possible to uninstall one plugin from within another plugin?
wordpress
I set up my blog so that some of my posts get linked to a page outside of Wordpress. For these posts that get linked outside of Wordpress, I'd like to still include my header and footer so the page looks like it's still a part of my site. What would be the best way to do this? I tried adding <code> &lt;?php include("/p...
You'll either need to load in WordPress , which can be considered computationally expensive if your 'other' pages are also powered by another webapp (not to mention the conflicts it may bring). If they're just regular PHP files, you should be OK. To load WordPress, include the file <code> /path/to/wordpress/wp-load.php...
making posts linked outside of Wordpress still use the same header and footer
wordpress
I am working on a Wordpress site that heavily uses image uploading and whatnot, I have defined the image sizes in my functions.php and I have hard crop mode turned on which ensures that my images are always cropped to the exact size that I want. The problem with hard cropping is that peoples faces in images and other a...
It depends on the source image, aspect ratio is not magic, it must be maintained in order to lessen the proportional distortion. You best option is to upload images that will maintain the same aspect ratio. You can tweak your CSS to get a more consistent image size but be aware that doing so will create distortion the ...
Need To Resize Images Exactly Without Losing Image Details
wordpress
I'm writing a plugin that modifies the default behavior when uploading a file for a post or to the media library. I'm setting $overrides in wp_handle_upload() with a custom $unique_filename_callback. Once I added that, it tripped the following check inside wp_handle_upload(), because $_POST['action'] wasn't set. (I'm n...
I wouldn't say security concern - since you're using this plugin within the admin (I presume after the user has been authenticated i.e. after <code> admin_init </code> ), then already you've got protection against any Jon Doe posting a form to your script. What it does provide, is an additional layer of authentication....
Is disabling test_form in wp_handle_upload a security concern?
wordpress
For some reason this custom field is not being shown in the page. This is the template file: <code> &lt;?php /** * Template Name: bbPress - Topics (Newest) * * @package bbPress * @subpackage Theme */ ?&gt; &lt;?php get_header(); ?&gt; &lt;div id="container"&gt; &lt;div id="content" role="main"&gt; &lt;?php do_action( '...
You're doing it outside of The Loop there, so $post is undefined at that point. Put it above the <code> endwhile </code> and it should work.
Value from custom field is not being displayed?
wordpress
I have a Wordpress site that relies on relationships quite heavily. It's a record label website where artists can be related to tours, reviews, album releases and store items throughout the site. I found the plugin Posts to Posts by Scribu which seems to do what I want, but I don't understand how to use it properly. Sc...
Ok, so the idea is that you have an outer loop, that displays the tours. And then you have an inner loop, that displays each artist. The way The Loop works is that it populates a lot of global variables, such as <code> $post </code> , so it looks like magic. Let's look at a more uniform approach: <code> $tours = get_po...
How Do I Use The Wordpress Plugin Posts 2 Posts by Scribu?
wordpress
This is a second navigation menu I'm using: <code> &lt;ul id="forums"&gt; &lt;?php $custom_posts = new WP_Query(); ?&gt; &lt;?php $custom_posts-&gt;query('post_type=bbp_forum'); ?&gt; &lt;?php while ($custom_posts-&gt;have_posts()) : $custom_posts-&gt;the_post(); ?&gt; &lt;li&gt;&lt;a href="&lt;?php the_permalink(); ?&...
So, if I understand correctly, when you're on a single post page, you want to have a navigation menu with all the posts of post_type bbp_forum. I had a similar case (without the post_type, but it's not a problem to add it), and I used code that I found that talked about posts of same category, on single post pages . Th...
Highlighting the current page in a navigation menu which links are generated with a custom loop?
wordpress
hey guys, The "mingle forum plugin" provides the following shortcode [mingleforum]. When I paste this into a page the forum is shown. My forum is using a specific page-template called forum.php. Is it possible to already include this shortcode in the page-template itself, so I don't have to paste it in the wordpress ba...
To use shortcode in a PHP file (outside the post editor) you have the handy little function do_shortcode(); so in your case you use: <code> &lt;?php do_shortcode('[mingleforum]'); ?&gt; </code> Update: following the first comment, I figured its publicly known for some reason, if you are expecting output from the shortc...
Adding a post shortcode to a page template?
wordpress
I'm a noob at this so please bear with me. I have the following code to return post title as links within categoryID 6, which is working fine: <code> &lt;?php global $post; $cat_posts = get_posts('numberposts=10&amp;category=6'); foreach($cat_posts as $post) : ?&gt; &lt;?php $postTitle = get_the_title(); if($title != $...
Have you tried the following code? <code> $cat_posts = get_posts('numberposts=10&amp;category='.$catID); </code>
With get_posts(), how can I put a category as a variable
wordpress
How do I have my plugin pop up with that <code> New version available. Upgrade Automatically </code> dialog to appear when my plugin has a new version? Specifically for plugins not hosted on the WP.org repository.
This library integrates auto-updates for privately hosted plugins. Looks great.
How to auto-upgrade my plugin?
wordpress
I'm using the twentyten theme with the bbpress plugin. I have the following in my header.php (twentyten): <code> &lt;div id="masthead"&gt; &lt;div id="branding" role="banner"&gt; &lt;h1&gt;&lt;a href="&lt;?php get_site_url(); ?&gt;"&gt;TaiwanTalk&lt;/a&gt;&lt;/h1&gt; &lt;/div&gt;&lt;!-- #branding --&gt; &lt;div id="acc...
The functions that start with "get_" return the value to what's calling it. So you would do <code> &lt;a href="&lt;?php echo get_site_url(); ?&gt;"&gt; </code> instead to print out the URL.
get_site_url is not returning anything?
wordpress
I have created some pages (not post) in wordpress related to my college notes. I would like to display a copyright message of the college on this pages, but I don't want do this manually every time. So is there any plug-in or tweak available to achieve this?
You could add a custom field to the pages you want to show the copyright on and have your page.php (or header.php or index.php or whatever) look for it. Example: Set a custom field of "show_copyright" to "1" in the page editor. In your page.php, right above <code> &lt;?php endwhile; endif; ?&gt; </code> , add this: <co...
Copyright messages for a particular set of pages
wordpress
I've created a custom post type with my own custom meta boxes. Now I want to move the title box to the side or simply remove it and place the same content in a custom meta box. How do I go about to do this? Thanks
When you register your post type, use the <code> supports </code> argument to explicitly set which core meta boxes to use. <code> register_post_type('my_type', array( 'supports' =&gt; array( 'editor' ) // if "title" isn't in this array, it won't appear on the edit post page // other arguments )); </code>
Move title "meta box" in post mode
wordpress
Hey! I have added a wp_loginout() to my header using a snippet in my functions.php: <code> add_filter('wp_nav_menu_items', 'add_login_logout_link', 10, 2); function add_login_logout_link($items, $args) { ob_start(); wp_loginout('index.php'); $loginoutlink = ob_get_contents(); ob_end_clean(); $items .= '&lt;li&gt;'. $lo...
See this stackexchange-url ("related question"). I guess in your case you'd wrap your code in <code> if( $args-&gt;theme_location == 'primary-menu' ) </code> .
Targeting specific menu with wp_nav_menu_items
wordpress
Been fiddling around, trying to remove the "path" info that's shown when you create/edit a post in wordpress. Been able to remove word count and the saving draft info, but not the path thingie This is what I'm talking about: http://dl.dropbox.com/u/3618143/Sk%C3%A4rmavbild%202011-03-13%20kl.%2001.08.11.png Also, the au...
Use the filter <code> tiny_mce_before_init </code> to customise the default configuration; <code> function __my_tiny_mce( $config ) { $config['theme_advanced_path'] = false; return $config; } add_filter('tiny_mce_before_init', '__my_tiny_mce'); </code> Check out all the options available on the Tiny MCE documentation .
Remove path from the create/edit a post view
wordpress
I have a 'media' category page that pumps in videos / image galleries. I'm looking to have a smaller size video display (vimeo / youtube) on the category page, and the full size video on the single page. How do I change the size of the video embed on the fly for the both scenarios? Here's the loop for selecting anythin...
The best solution here is to use the built-in filter for embed parameters: <code> &lt;?php function mytheme_embed_defaults( $defaults ) { return array( 'width' =&gt; 100, 'height' =&gt; 100 ); } add_filter( 'embed_defaults', 'mytheme_embed_defaults' ); ?&gt; </code> This code can be added to your theme's functions.php ...
Different size video display for category page (smaller) & detail page (larger)
wordpress
Is there a way to limit search to post titles? I know I can modify query.php core file but there must be a way to do it with hooks right? Thanks in advance!
Here's a filter that'll do the trick. Drop it into your theme's <code> functions.php </code> or a plugin. <code> /** * Search SQL filter for matching against post title only. */ function __search_by_title_only( $search, &amp;$wp_query ) { global $wpdb; if ( empty( $search ) ) return $search; // skip processing - no sea...
how to limit search to post titles?
wordpress
I have a Worpdress blog on a hosting company (it's remote and existing). I would like to load it to Netbeans. How do I do that? Thanks,
File > New Project Categories select 'PHP' Project select 'PHP Application from Remote Server' click 'Next' and give the project a name and specify where local/downloaded files will be stored. click next Enter Project URL, and upload path on remote server (this probably be just / if WP is installed at root of the domai...
Loading a remote WP website to Netbeans
wordpress
I'm having some problems getting the WP Subtitle plugin to work. After inserting the <code> &lt;?thesubtitle()?&gt; </code> or <code> &lt;?getthe_subtitle($id)?&gt; </code> into the index.php template I get a 'call to undefined function' error - inside or outside the loop doesn't seem to matter! Thanks in advance //Upd...
Try the correct syntax : <code> &lt;?php the_subtitle(); ?&gt; &lt;?php get_the_subtitle( $id ); ?&gt; </code>
WP Subtitle Plugin Problem
wordpress
I have a question about moving wordpress sites around. I've read most of the Support Docs about moving a wordpress site. My question is this, what would you guys recommend in regards to moving only certain posts from one site into a totally different domain. My current domain is a tech/blog installation. The past year ...
I would try the following: <code> site #1 == source site #2 == destination </code> On the Site #1: on all the post you want to move/migrate allocate them a category say 'moved' export them using 'Tools' > 'Export' (select 'Posts' and specify categories 'moved') On site #2: Import your exported file using 'Tools' > 'Imp...
Moving Some Articles to new site
wordpress
I'm trying to call multiple JQuery scripts using wp_enqueue_script. The call to JQuery works perfectly but the second call to cufon doesn't. I'm not a php or javascript expert - could anyone lend a hand, is there a best practice method for this? <code> function my_init_method() { if (!is_admin()) { wp_deregister_script...
I'm not good at this, but it could be because Cufon is not included in Wordpress? So, you are deregistrating a script that is not included.. http://codex.wordpress.org/Function_Reference/wp_enqueue_script#Default_scripts_included_with_WordPress
Calling multiple scripts using wp_enqueue_script
wordpress
One of my wordpress blog is protected by the wordpress password plugin. however, I would like provide rss features. I found how to configure wordpress plugin to make rss work. But, by default, it seems that all the content of a post is sent by the feed. I would like to limit the information available by rss. Ideally, I...
I have found two solutions : 1) First one, very easy, just select summary in the feed options of wordpress. Since this option is activated, neither pictures nor videos are displayed. 2)The second one is adding this piece of code in your theme's functions.php <code> add_filter('excerpt_length',create_function('$a','retu...
restricted rss feed
wordpress
How are you? I have a blog which have 20 authors. I want to write code to show the 5 author who have more posts. like this: Adam (10 Posts) Khal (8 Posts) Yous (5 Posts) Moha (3 Posts) Yousef (1 Post) but I don't know how can do it that
Are you using WordPress 3.1+? There's a nice <code> get_users() </code> function that'll do the trick! However, you will need a little magic to boot: <code> add_action( 'pre_user_query', 'wpse_11832_pre_user_query' ); /** * Adds "post_count" to the SELECT clause. Without this, the "post_count" * property for users will...
List top 5 authors with most posts
wordpress
i have a custom post type 'events'. Each event (post) can have multiple dates. The dates (date, time, location) are stored as array. I need a query that creates a chronological list of all events from the meta data (events can occur multiple times). The custom-meta-box looks like this: The resulting database entry in w...
Here's the code that finally worked for me: <code> &lt;?php global $events_meta_termine; $today = getdate(); $my_query = new WP_Query('post_type=events&amp;posts_per_page=-1&amp;monthnum='.$today["mon"]); $events=array(); while ($my_query-&gt;have_posts()) : $my_query-&gt;the_post(); $do_not_duplicate = $post-&gt;ID; $...
Custom Post Type 'Event': Chronological list of recurring events from meta_values in array
wordpress
Update: I'm now trying to find a way to echo the metadata of a custom taxonomy's value. I'm trying to create some PHP to use in a plaintext widget that'll display information in my sidebar. Because some of the information will be identical across some of the parts of the site instead of storing the information in custo...
First of all, what you're calling $current_tax would more appropriately be named $current_term. The taxonomy is 'game'. Secondly, what you're trying to do is basically adding term metadata. There already are several plugins that provide the custom table and functions for that. I recommend Simple Term Meta .
Returning info from MYSQL table via custom taxonomy
wordpress
I'm trying to apply this tutorial to my blog. I'm using Woothemes' Bueno Theme . I'm adding this code to my theme's functions.php file : <code> function ymc_add_meta_settings($comment_id) { add_comment_meta( $comment_id, 'mailchimp_subscribe', $_POST['mailchimp_subscribe'], true ); } add_action('comment_post', 'ymc_add...
The last two hooks should specify 2 accepted arguments, not 1; <code> add_action('comment_approved_','ymc_subscription_add', 10, 2); add_action('comment_post', 'ymc_subscription_add', 60, 2); </code>
Error While Sending Comment
wordpress
<code> &lt;div class="menu"&gt; &lt;ul&gt; &lt;?php wp_list_pages('exclude=&amp;title_li='); ?&gt; &lt;/ul&gt; &lt;/div&gt; </code> creates the following output... <code> &lt;div class="menu"&gt; &lt;ul&gt; &lt;li&gt;&lt;a href="#"&gt;Page 1&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="#"&gt;Page with Subpages&lt;/a&gt; ...
Phew! Bit more complex than I would've liked - if only the filter <code> page_css_class </code> passed back <code> $args </code> it would save a lot of effort (may submit this to trac). Since 3.3 it's as easy as this! <code> function add_parent_class( $css_class, $page, $depth, $args ) { if ( ! empty( $args['has_childr...
class="parent" for wp_list_pages?
wordpress
I have a custom taxonomy called 'game'; posts have a taxonomy value, i.e. Halo, which then has seven different fields; game_name, game_genre etc. I'm trying to echo the meta data for a given post's custom taxonomy albeit without much luck. The small piece of PHP that I tried to use to echo the metadata for the field ga...
I assume you're trying to use this when viewing a single post? For example, in <code> single.php </code> ? If so, you'll need to grab the terms first, then grab your meta. <code> global $post; if ( $terms = get_the_terms( $post-&gt;ID, 'game' ) ) { // $term = $terms[0]; // WRONG! $terms is indexed by term ID! $term = a...
Echo Custom Taxonomy Field Values Outside the Loop
wordpress
WP 3.1 has everyone excited, if somewhat confused, about post formats. Enabling new post formats The issue of enabling post formats has been covered at length. It's as simple as adding this line to functions.php: <code> add_theme_support( 'post-formats', array( 'aside', 'gallery' ) ); </code> Displaying Posts of a cert...
You have a lot of options for displaying using the "Post Formats" feature: for example in an index.php loop you can decide what to show based on the post format using has_post_format() function : <code> if ( has_post_format( 'aside' )) { echo the_content(); } elseif ( has_post_format( 'chat' )) { echo '&lt;h3&gt;'; ech...
Display/query post formats
wordpress
I'm having pretty heavy (lots of images) Wordpress website with around 20-30k unique users per day (1,000,000 monthly). German hosting that I use works fine in Europe, but many visitors from the USA, Asia and Australia complain about loading times. Do you know any good, affordable hosting companies that provide fast br...
Saw that you and a few others had their doubts about Media Temple. First off, if you have any questions feel free to ask. We have a good amount of customers with different experiences, be it bad or good. The shared service gets a lot more grief than our VPS , which many of our customers are very happy with. I see many ...
Best hosting for Wordpress blog(s)?
wordpress
I am designing a frontend for users, where they can submit an article/post from. But i am worrying if someone puts javascipt code, or SQL injection, or other malicious code. Is there a plugin or some sort of scripts which can help me to filter the post contents from security point of view. I'll appriate if someone can ...
If your really worried I would probably create custom write panels or custom meta boxes tied into custom post types. That way you can make the custom post types based on user role and control what shows up very easily. For instance you can make a custom post type called "tweens" with the user role of "contributor" so t...
Stop Authors from submitting spam post
wordpress
I'm trying to create a Thematic child theme that uses BuddyPress. First, I tried using BuddyMatic -- which currently doesn't work with WP3. Next, I tried the BuddyPress compatibility pack -- which totally works! Except for one thing: when I select "Activity Feed" as an option for the front page, I get a Not Found error...
I figured out how to make it work, but it's a bit hacky. Essentially, I coped the index.php from activity into the the main index.php of my Thematic child theme, adding the Thematic actions afterwards. Same error persists if I leave it on "Activity Stream" for the front page, but when I return it to the default "Most r...
Not Found when using activity stream as front page with BuddyPress
wordpress
I see a number of posts on various plugins for doing an Event Calendar that work with Wordpress, but the free hosted version does not allow me to use these. Are there any solutions that would work for hosting a calendar of events for an organization that I volunteer for? Even embedding a Live/Google calendar would work...
It may be time to give up WordPress.com. There is little day to day difference in managing a self-hosted version, but there is a world of opportunities that will open with a few well selected plugins. You mentioned you're volunteering for an organization. If the issue is paying for hosting, Dreamhost and HostGator offe...
Event Calendar on hosted wordpress?
wordpress
I am just creating a simple contact form, but I notice that it seems to post to an invalid page. The url in the browser is correct but the title of the page is "Page not found" on the top of the page <code> $emailed = false; if (isset($_POST['submit'])) { wp_mail('example@example.com', $_POST['subject'], $_POST['conten...
I could be wrong, but I vaguely remember that: name, email get hijacked by WordPress to do post comments, if you renamed the form elements to be contact-name and contact-email, do you get the same issue?
Why when I submit a form in wordpress it loads a 404 page though URL is correct
wordpress
I updated my plugin, Export to Text , to 1.3 and committed it to the WordPress SVN repository yesterday. The 1.3 download button was available pretty quickly, but a day later the read me text is not rendering on the plugin page and the download update reminder is not working in the WP UI for users with earlier versions...
A readme update may take a week or more. Sometimes it helps to update just the readme file again. The Last Updated field is … dead. One of my plugins still shows the date 2010-12-24, but I had three updates in the mean time, the last one a week ago. The whole system feels like an old windows. :)
How long should it take for a plugin to fully load into the WordPress.org plugin repository?
wordpress
First time experimenting with wordpress and looking for advice on the correct way to add a block of html to a sidebar. This doesn't seem like a custom widget to me as there is no functionality involved, other than displaying an image. I want to position it above a sidebar menu which exists there already - instead of ju...
You should simply add the html block to the built in text widget. And as for positioning it above the menu just use the drag n' drop functionality of the sidebar widgets.
Correct way to add a block element to sidebar layout
wordpress
Im trying to make different querys in my category like one with a offset of post and one that shows one post but while it continues to go through the loop, this is what i have but the loop keeps repeating itself i almost think im not doing it correctly. Anyone know whats wrong? <code> &lt;?php if (have_posts()) : $coun...
That's a really inefficient way to do it. Just use the $count variable you declared at the top, without any query_posts(): <code> $count = 0; while ( have_posts() ) : the_post(); if ( $count &lt; 1 ) { // first post } elseif ( $count &lt;= 4 ) { // next 4 posts } else { // rest of the posts } $count++; endwhile; </code...
Query the Loop without breaking it
wordpress
Just getting into wordpress and learning a lot! I know how to create a custom field and use it for basic purposes. I'm trying to do a little more now...I'm hoping someone can help me. Here is the scenario: I have businesses and events section on my website. Businesses use the default "posts" from wordpress, "events" ar...
here: What you need is to create a meta box so first you use the add_meta_box() <code> // Hook into WordPress add_meta_boxes action add_action( 'add_meta_boxes', 'add_Businesses_custom_metabox' ); /** * Add meta box function */ function add_Businesses_custom_metabox() { add_meta_box( 'custom-metabox', __( 'Businesses' ...
Populate a custom field dropdown with post titles by author
wordpress
How would you resend the login &amp; password to a user who has forgotten his password? In this case they don't want to go to the "password" forgotten page. Additional Q: Mass re-sending of passwords. I understand that it's nearly impossible to resend the password, so reset is also ok. but i need a way to click select ...
To reset the passwords for all users use the plugin Bulk Password Reset . It offers a nice interface with some useful options. For example: You can choose the users by their role or add a custom message to the reset email.
resend user login & password with custom button
wordpress
Not sure if the title makes sense sorry, but at the moment on my blog there is a long list of posts (with the thumbnail custom field) - the text next to the thumbnail is just the first characters from within the post. How exactly do I change that to something else? Thanks!
See this . You should be able to control that text by altering your Post's excerpts. You may need to click "Screen Options" at the top right of your Dashboard to have the Excerpt box be displayed when you create or edit posts. HTH.
On the post list, how do you show different text to the main content?
wordpress
I have a created a custom post type and have attached some custom fields to it. Now I would like for the search that authors can perform on the custom post list screen (in the admin backend) to also be performed on the meta fileds and not only look in the title and content as usual. Where can I hook in and what code I ...
I solved filtering the query by adding the join on the postmeta table and changing the where clause. tips on filtering the WHERE clause (often require regular expression search&amp;replace) are here on codex: <code> add_filter('posts_join', 'segnalazioni_search_join' ); function segnalazioni_search_join ($join){ global...
Extending the search context in the admin list post screen
wordpress
My site is using a short vanity URL. This is working across all of the custom theme pages. The only problem is when I logout in the admin it redirects to the long URL, which then 404s. My General Settings (which I can't change) are: WordPress address (URL): The long URL Site address (URL): The short URL Looks like the ...
The quickest way to do this is through an Apache rewrite via mod_rewrite . You'll also have to tell WordPress where to points its login links using the login_url and logout_url filters. <code> return apply_filters('login_url', $login_url, $redirect); return apply_filters('logout_url', $logout_url, $redirect); </code>
Change admin logout URL
wordpress
Recently getting into wordpress plugin development, I started to investigate how to make my code backward compatible to php 4+. I've focused only on php 5.1+ for the past 5 years, so this was an ordeal. Anyway, when looking at some plugins, one of them had this description: IMPORTANT: This plugin is not compatible with...
Yes, version 3.1 is the last version to support PHP 4. For WordPress 3.2, due in the first half of 2011, we will be raising the minimum required PHP version to 5.2. Why 5.2? Because that’s what the vast majority of WordPress users are using, and it offers substantial improvements over earlier PHP 5 releases. It is also...
Wordpress to end support for PHP 4?
wordpress
I have a div wrapper around my comments pagination. I have the comments set to paginate in the Wordpress admin at 10 comments per page. I want to hide the div wrapper if there are less than 10 comments (i.e. the pagination links aren't shown). I can't figure out how to do this. I know how to hide the div wrapper if pag...
Use the comments number function or the more native get_comments_number function and combine it with the page comments option <code> if ( get_option( page_comments ) == TRUE ) // do stuff </code>
If paginated comments don't span to a second page, how do I hide the div wrapper?
wordpress
I'm adding TinyMCE buttons to my plugin and they're working, but I only want these buttons to show up for a certain custom post type. I followed this tutorial if it helps: http://www.tutorialchip.com/wordpress/wordpress-shortcode-tinymce-button-tutorial-part-2/ How can I have that check if they are editing/posting a po...
If you followed that tutorial you linked then look at the function that registers the buttons: <code> function mylink_button() { if ( ! current_user_can('edit_posts') &amp;&amp; ! current_user_can('edit_pages'){ return; } if ( get_user_option('rich_editing') == 'true' ) { add_filter( 'mce_external_plugins', 'add_plugin...
Check if on Custom Post Type for TinyMCE buttons
wordpress
I am having problems looking for info on the codex on how to query for child pages. It seems to be missing the reference for the available parameters
Yeah they've moved the parameters to WP_Query . You're looking for the post_parent parameter.
query_posts for child pages
wordpress
I read the wordpress codex and professional wordpress. It seems both use something like <code> if($wpdb-&gt;get_var("SHOW TABLES LIKE '$table_name'") != $table_name) { </code> to determine if the table exists. Is there any reason why <code> CREATE TABLE IF NOT EXISTS ( ... ) </code> is not used? It will check and creat...
If you use "IF NOT EXISTS" then the dbdelta script will not upgrade your database with delta's appeared after the initial creation of the database. (assuming you want to re-use the same sql script) at least... that is what i think
Checking if Database Table exists
wordpress
I have 2 WordPress MultiSite installs (on different accounts, but under the same HostGator reseller a/c) and both seem to have been compromised. I say "compromised" because the user_logins have been modified (somehow) and "hidden users" are being shown via WP Admin. I attempted to login to the installs which are both u...
I would first of all change the password for phpMyAdmin because I think they moust be getting though the DB next thing is if that doesn't work , but the bullet and do a clean install but backup all the post and maybe the comments if you want ot.
Has anyone experience w/ WordPress (MultiSite) hidden users (possibly hacked)?
wordpress
I am trying to use jQuery to display the comment-section of my Wordpress-pages, but without requiring that jQuery be present on all pages that allows comments. Basically, I need the following: A generic javascript implementation of the 'in view' jQuery-plugin (http://remysharp.com/2009/01/26/element-in-view-event-plugi...
After a LOT of googling, trying to find a solution at the same time as keeping up with the earthquake-situation in Japan, I found a way: Two scripts for Wordpress Using wp_enqueue_script , I added a DeferJS ( https://github.com/BorisMoore/DeferJS ), which allows scripts to be loaded onEvent. Also, a I added a custom-sc...
How do I activate jQuery/script on demand?
wordpress
I have two custom post types: event and contact: http://acicafoc.josoroma.com/contactenos http://acicafoc.josoroma.com/eventos Both of them uses a custom taxonomy: country I just created a template named: taxonomy-country.php But I Need two separated templates, one for events who uses countries and another one for cont...
You use get_query_var('post_type') to set the post type in your args array <code> $args['post_type'] = get_query_var('post_type'); </code> and also include the right loop part based on that for example: <code> if (get_query_var('post_type') == "event"){ get_template_part( 'loop', 'event' ); }else{ get_template_part( 'l...
A shared custom taxonomy between two custom post types
wordpress
Is it possible to block user registration based on the referring URL? I have an open registration WP site (configured so users can post ads and events) and while I typically don't get a lot of spam registrations (there is a reCaptcha involved), I was listed on a site as an example of the capabilities of the theme I'm u...
You can use <code> "register_post" </code> hook that happens just before the user is saved to the database or you can use <code> "register_form" </code> hook and check the referring URL for a match and die();
Block registration by URL referrer?
wordpress
As far as I know, there's not a simple function that will return true if a post has an attachment. With that in mind, what's the best way to determine if a post has an attachment (or even better, has an image attachment)? I'm automatically inserting a shortcode on posts, but would like that to only happen if there is a...
I think this should work: <code> $attachments = get_children( array('post_parent' =&gt; get_the_ID(), 'post_type' =&gt; 'attachment', 'post_mime_type' =&gt; 'image') ); if ( $attachments ) { // do conditional stuff here } </code>
How can I determine if a post has an image attachment?
wordpress
I have a child theme based on Twenty Ten. I have split out the sidebar and secondary side bar so they can be used on different pages. sidebar.php file: <code> &lt;div id="primary" class="widget-area" role="complementary"&gt; &lt;ul class="xoxo"&gt; &lt;?php /* When we call the dynamic_sidebar() function, it'll spit out...
try this instead <code> &lt;?php get_sidebar(2); ?&gt; </code>
Twenty Ten child theme has post on an inner page. Cant get that page to use my desired template
wordpress
On the site I am developing I have a few custom post types set up (Press Releases, Articles, Podcasts). I also have the Tag Cloud widget enabled in my sidebar. I have tagged a post with 'Testtest', and I've also tagged a Press Release with 'Testtest'. The problem I have is when I click the 'Testtest' tag on my tag clou...
you can add them using pre_get_posts filter: <code> function myTagFilter($query) { $post_type = $_GET['type']; if (is_tag()){ if (!$post_type) { $post_type = 'any'; } $query-&gt;set('post_type', $post_type); } return $query; }; add_filter('pre_get_posts','myTagFilter'); </code>
Wordpress 3.1 - Tag page not showing posts from custom post type
wordpress
How do I identify that a page is a grandchild page?
use get_page twice like this handy little function <code> function get_grandpapa($page_id){ $current_page = get_page( $page_id ); if ($current_page-&gt;post_parent &gt; 0){ //has at least a parent $parent_page = get_page($current_page-&gt;post_parent); if ($parent_page-&gt;post_parent &gt; 0){ return $parent_page-&gt;p...
Identify that a page is a grandchild page
wordpress
It's an inconvenience to have to customize your theme just to use BuddyPress. It'd be much nicer if it simply used the wordpress page system for example, to inject content into standard WP pages. This way no theme editing is necessary, just activate BP and go. The idea would be that BuddyPress would just work in Twenty...
There is actually a plugin for that (bptemplate pack). It works pretty well! http://wordpress.org/extend/plugins/bp-template-pack/
Is there a plugin or something that allows you to use BuddyPress without having to create a BuddyPress-ready theme?
wordpress
I have a custom post-type "model", and I want to be able to export certain values (eg Name, Height, Shoe Size, etc) and a set number of images from the gallery, from each Model to a PDF. Ultimately, what I want to be able to do is: From the Admin backend, click an "options tab" or some such select a number of Models, e...
To answer your questions: Yes, it is possible. Depends on what you consider to be "too complex". No, you cannot do anything... For example, WordPress and PHP will not bring your deceased loved ones back.
Is it possible to create an "export to PDF" option?
wordpress
Is there a way to fetch the URLs of ALL images in the media gallery? I think this would be an easy way for a website to have a Pictures page that just pulls all of the images from the media gallery, granted it would only be necessary in certain scenarios. I don't need instructions on how to create a Pictures page, just...
<code> $query_images_args = array( 'post_type' =&gt; 'attachment', 'post_mime_type' =&gt;'image', 'post_status' =&gt; 'inherit', 'posts_per_page' =&gt; -1, ); $query_images = new WP_Query( $query_images_args ); $images = array(); foreach ( $query_images-&gt;posts as $image) { $images[]= wp_get_attachment_url( $image-&g...
Get All Images in Media Gallery?
wordpress
I'm just beginning to work the "Custom Menu" functionality that was introduced in 3.0 into my theme. I like everything about this new capability and API, with one exception: Why no posts? I can create menus containing pages, categories, even tags, but where is the posts selector? I know I could use the "Custom Links" t...
OK, I found the answer to this one and its surprisingly simple but maddeningly frustrating at the same time. All you have to do is click "Screen Options" while viewing the "Custom Menu" manager and place a check beside "Posts" to show the elusive hidden "Posts" widget. Now you can add "Posts" to your custom menus. Who ...
How to add posts to custom menus?
wordpress
We're setting up a site to showcase a series of archival recordings. We have the custom post types sorted out thanks to all the help from this site (many, many thanks): <code> add_action( 'init', 'create_radiotalks' ); function create_radiotalks() { register_post_type( 'radiotalks', array( 'labels' =&gt; array( 'name' ...
Add supports to your array like so <code> 'supports' =&gt; array('title','editor','author','thumbnail','excerpt','comments') </code> As for the additional data per each recording if you need to filter or search by it the create a custom taxonomy if not then a custom fields would be just fine.
custom post data - how to
wordpress
There was a news item today possibly of interest to those who self-host WordPress: Automattic unveiled the Jetpack plugin. I hadn't heard of it before, but going off the announcement and the site FAQ, it looks as if it's going to provide multiple bits of functionality in one package (WP.com Stats, Twitter widget, short...
Hi @Grant Palin: I think the decision is your own. As said Automattic is merging its plugins into JetPack and encouraging users with older versions to upgrade. If you want to continue using those plugins you likely will not have a choice but to upgrade to JetPack with the alternate being to switch to other plugins. I d...
When would it make sense to use Jetpack?
wordpress
Is it possible to control the length of the content or excerpt for a specific query/loop? I have come across the following code, but this changes the length for all excerpts, I want it focused on a specific custom query. <code> add_filter('excerpt_length', 'my_excerpt_length'); function my_excerpt_length($length) { ret...
Try this: http://pippinspages.com/tutorials/better-wordpress-post-excerpt-revamped/
Content/Excerpt length control for a specific loop?
wordpress
I've never really been comfortable with the on-board image editor in WordPress, and here's a good example of why: I'm just setting up a vanilla WP installation and am using the TwentyTen theme. I've uploaded an image, rotated it 90 degrees (using the Edit Image feature), saved it and have used it as my Featured Image. ...
AFAIK, the featured image ignores all on-site edits. It just takes your base image, and applies crop/resize based on your add_image_size defs.
Using the on-board image editor for featured images: edits are not being used
wordpress
Hi I run a site gaming review site www.co-opreviews.com . I'm trying to display info about the games in a sidebar on the right hand side of the page. (You can view a mockup of the sidebar here: http://i.stack.imgur.com/u3s5b.png ) I'm currently doing this through multiple sidebars (which my theme allows) and using a pl...
You don't need CPT's to display custom information. You could use custom fields (you may need to enable them in the screen options at the top of the post edit window). You'd just need to include the custom fields in your loop but position them so they appear over the sidebar. Their information would be related to the p...
Displaying info in a sidebar
wordpress
For starters I am using this GREAT answer to achieve custom post types as well as a custom way to insert those post types into other pages, you can view that answer here: stackexchange-url ("Custom field/meta populated by dropdown of existing posts?") I am running into a problem however when wordpress auto saves itself...
Well, as always I feel like a dummy, but after searching the internet for hours and seeing that it seems like lots of people are having this question and I cant seem to find an an answer anywhere, I guess im not THAT slow! the important code is something along these lines: <code> add_filter('wp_insert_post_data',array(...
post meta data clearing on autosave
wordpress
I'd really love to be able to conditionally apply a CSS class to link elements of images embedded into posts, but I can't seem to figure this one out. Basically what I'd like to achieve is to replace the default embedded image link that links the image to the full size version of itself to opening it in a colorbox. I k...
Thanks a LOT to user stackexchange-url ("t31os") for the tip on where to find my solution! Also thanks to user stackexchange-url ("orionrush") for pointing out a dumb mistake I had made! :) Here's how I got what I wanted: <code> function add_colorbox_class_to_image_links($html, $attachment_id, $attachment) { $linkptrn ...
Applying automatic link class to images embedded to posts
wordpress
I am having a unmanaged VPS, where my wordpress site is hosted, I am also using WP-ROBOT 3 plugin for auto posting, I want it to do auto post through cron jobs, According to the documentation of the plugin, I entered this code through SSH command <code> wget --post-data='mincamp=2&amp;maxcamp=3&amp;chance=50' -O /dev/n...
You can do this via wp_cron by using the following, <code> function more_reccurences() { return array( 'sixhourly' =&gt; array('interval' =&gt; 21600, 'display' =&gt; 'Every 6 hours'), ); } add_filter('cron_schedules', 'more_reccurences'); </code> then find the function that does the autopost and call it by <code> if (...
How to set intervals in cron jobs?
wordpress
My system emails on my linux server have been getting "message undelivered" emails which appear to be sent from the Contact Form 7 widget I have on my website. The odd thing is, there is no "to:" field in the widget - just "from" and "message". And yet the "undelivered messages" include random to:addresses. I have Akis...
It seems Contact Form 7 allows you to specify the recipient via a select dropdown . This means that the recipient e-mail address is stored in the form and sent to the server, which then just reads it. Unless the server then verifies the recipient address was one of the options you specified, this can be a "security hol...
Contact Form 7 being hijacked to send spam?
wordpress
The following is a tutorial to Sort Posts by Vote (for the Vote it Up plugin): I haven't found it anywhere so i put it here. This is a new function which add posibilities to sort post on index page by vote. Add this in votingfunctions.php : <code> function ShowPostByVotes() { global $wpdb, $voteiu_databasetable; mysql_...
I can't figure out how to setup this code. I've been dabbling with PHP for a while, but I'm only recently trying to go deeper into how all the WordPress stuff works. I don't understand what "Attention! Code above is something like:" means. Does that mean we put the previous code below it? Would you be able to do a quic...
How to fix/improve this 'bad coded' function that sort posts by votes (for the Vote it Up plugin)?
wordpress
I am using the Thesis theme with my WordPress multisite installation. I also changed the permalink settings from the Super Admin settings to remove /blog/ from the path. But now my menu links are broken. The permalink structure now is /%postname%/ and my pages have the links mydomain.com/about/, mydomain.com/contact/ e...
The solution posted here resolved the issue. The links work as expected now even when I use custom permalink structures!
WordPress multisite installation broke menu links
wordpress
I added a menu item to the Admin Bar that executes some Javascript to show debug information. The problem is that clicking this item also reloads the page. How can I prevent this? I was trying to speed up my debug &amp; dev stuff and wanted to add a class to my main wrapper div using jQuery. Step 1: Add styles to your ...
If you <code> return false </code> in that Javascript function the click will not be propagated and the page will also not reload. Even better, you can specify a <code> onclick </code> attribute for a menu item . So you definition would become this: <code> function my_admin_bar_class_switch( &amp;$wp_admin_bar ) { // $...
Admin Bar menu item that executes Javascript but does not reload the page?
wordpress
I have a custom post type of items set up. I also have a taxonomy set up with items called categories . functions.php code: <code> regsiter_post_type('items', array('labels' =&gt; array ( 'name' =&gt; 'Items', 'singular_name' =&gt; 'Item' ), 'public' =&gt; true, 'rewrite' =&gt; array ( 'slug' =&gt; 'items' ), 'supports...
Found the solution. The rewrites were getting added to the db after the system was reading them from the db. Moved the code and it worked!
Taxonomy Rewrite Rules Redirecting Instead of Masking
wordpress
I have another dumb question, but I can't get one thing :) I've found this very good article on creating custom post types: http://thinkvitamin.com/code/create-your-first-wordpress-custom-post-type/ I'm not sure how Step 4 works. This guys writes: <code> add_action("manage_posts_custom_column", "portfolio_custom_column...
The code from ThinkVitamin is right. I think the problem came from else where in your code. Actually, the hook <code> manage_edit-${post_type}_columns </code> takes an argument <code> $columns </code> which is an array of all registered columns. To add a new column, just add a new element to this array, like this: <cod...
How to add custom columns to Custom Post Type admin screen
wordpress
I know there is alot of discussion about the CPT and permlinks together with the 404. I did not found a solution though I am close. It would be great if someone could assist me to get it working. Ok what I did is: <code> function post_type_services() { register_post_type( 'services', array( 'label' =&gt; __('Services')...
You need to add the following to your <code> register_post_type() </code> array: <code> 'has_archive' =&gt; 'service' </code>
WP 3.1 custom post type permlinks
wordpress
This is the topic loop of the bbPress plugin . How can I make it stop when it reaches two posts? (Topics custom post types)? <code> &lt;?php /** * Topics Loop * * @package bbPress * @subpackage Theme */ ?&gt; &lt;?php if ( bbp_get_query_name() || bbp_has_topics() ) : ?&gt; &lt;?php get_template_part( 'pagination', 'bbp...
I think including a counter like this would do the trick. Does this help? <code> &lt;?php $showposts=2; $counter=0; while ( bbp_topics() ) : bbp_the_topic(); $counter++; if(counter&lt;=$showposts) { ?&gt; /*** Do stuff ***/ &lt;?php } else { break; } endwhile; ?&gt; </code>
How to make the following loop break/stop when it reaches 2 posts (custom post types called Topics)?
wordpress
I have added an image size with <code> add_image_size('gallery-thumb', 48, 48); </code> Why when I do <code> array_slice(wp_get_attachment_image_src($firstimg-&gt;ID, 'gallery-thumb')) </code> I get the link to the full sized image? UPDATE Somehow it appears that even when I do <code> wp_get_attachment_image_src($photo...
Does the 48x48 thumbnail file exist? If not, you can use a plugin like Regenerate Thumbnails.
Why is wp_get_attachment_image_src not working with my custom size (add_image_size)
wordpress
Essentially what I'd like to do is have the same effect as the wp_list_authors tag, but instead of just listing the name or their post count, I want to be able to do a loop with the IDs. Ultimately I'd like have to a page with every author, with their name, description, avatar and link. I can figure out the specifics, ...
Looks like you'll want to use get_users and you might want to take a look at the source code behind wp_list_authors to info on how to use it.
Custom Author Loop
wordpress
I'm looking for something, but don't exactly know what. I have a shortcode, let's call it [shortcode]. Users will input HTML tags inside, mostly images, but also links, images in links, etc., for example: <code> [shortcode] &lt;img src="http://www.site.com/myimage.jpg" /&gt; &lt;a href="http://www.blabla.com"&gt;&lt;im...
you can use regex to find your the src and use that to append your "files/myimagescript?" to it: <code> function append_myimagescript($attr, $content){ $pattern = '/src="([^"]*)"/i'; $replacement = 'files/myimagescript?${1}'; return preg_replace($pattern, $replacement, $content); } </code>
Shortcode content filter?
wordpress
I've taken this line from header.php of TwentyTen where its loading the custom menus... <code> &lt;?php /* Our navigation menu. If one isn't filled out, wp_nav_menu falls back to wp_page_menu. The menu assiged to the primary position is the one used. If none is assigned, the menu with the lowest ID is used. */ ?&gt; &l...
From looking at the Codex , you should be able to just pass the fallback_cb parameter as false to have wp_nav_menu return nothing. So something like: <code> &lt;?php wp_nav_menu( array( 'container_class' =&gt; 'menu-header', 'theme_location' =&gt; 'primary', 'fallback_cb' =&gt; FALSE ) ); ?&gt; </code>
if (has_custom_menu())?
wordpress
I need some help with restyling my alternate widget areas. I've created some new widget areas, and placed one into the main content of my index.php . This works just fine, however i want to style it differently. WordPress: 3.0.4 Theme: Twenty Ten Child (twentyten-child) Server: Local/MAMP I've tried creating new style ...
you can either use the !important property or ensure that your style definition has precedence by making it more specific. http://www.google.com/search?q=css+specificity
Customized widget area - how to override or filter class xoxo?
wordpress
I am trying to upload java files to my word press blog but it does not let me upload any files with .java extension. It says ".java” has failed to upload due to an error *File type does not meet security guidelines. Try another.* So how do I add .java extension so that it allows me to upload java source code. I am usin...
Use filter ' upload_mimes '. <code> &lt;?php add_filter('upload_mimes','add_java_files'); function add_java_files($mimes) { // Add file extension 'extension' with mime type 'mime/type' $mimes['java'] = 'text/x-java-source'; return $mimes; } </code>
Adding file types in wordpress
wordpress