question
stringlengths
0
34.8k
answer
stringlengths
0
28.3k
title
stringlengths
7
150
forum_tag
stringclasses
12 values
I can control the custom template to be used on custom post type pages but the template file would still need to have the markup of the theme. I was wondering if I could make it theme independent? Example: I have a plugin that registers my custom post type. I have the post meta info that I want to show in a custom temp...
I have got it working by the following code: <code> add_action( 'template_redirect', 'ft_job_cpt_template' ); function ft_job_cpt_template() { global $wp, $wp_query; if ( isset( $wp-&gt;query_vars['post_type'] ) &amp;&amp; $wp-&gt;query_vars['post_type'] == 'job' ) { if ( have_posts() ) { add_filter( 'the_content', 'ft...
Control Custom Post Type template from a plugin
wordpress
I have a function that performs some custom queries to get specific information regarding a post (children count, dates, etc). I am wondering if it is possible to send this custom query info (set as a variable) to a custom field automatically when I update the page.
Sure. Hook into the <code> save_post </code> action, then perform your custom queries upon save, and store them as custom fields of the post. <code> add_action('save_post', 'my_extra_meta_saver'); function my_extra_meta_saver($post_id) { global $post; // Prepare whatever extra information you want here // Save each pie...
Setting variables as custom field values
wordpress
Is there a similar way to select / perform DOM manipulation on the server-side (PHP) like the way jQuery works? For example, if I wanted to modify content of each <code> &lt;pre class="raw"&gt;...&lt;/pre&gt; </code> elements inside of a post content, in jQuery you can easily capture them all with: <code> //In jQuery, ...
You may also take a look at phpQuery .
How to make modifications only to certain elements of an HTML string on the server-side?
wordpress
I am using this code: <code> add_menu_page($page_title, $menu_title, $this-&gt;capability, $menu_slug, $function); </code> Which is adding top level admin page. When I add: <code> add_submenu_page( $menu_slug, 'sub menu 1', 'sub menu 1', $this-&gt;capability, $menu_slug . '_sub_menu_page_1', $function ); </code> I get ...
Unless I misunderstand the question, this should do the trick: <code> add_action('admin_menu', 'add_menu_pages'); function add_menu_pages() { add_menu_page('Menu Title', 'Menu Title', 10, 'main_menu', 'submenu_1_callback'); add_submenu_page('main_menu', 'Sub Menu Title 1', 'Sub Menu Title 1', 10, 'main_menu' , 'submenu...
How to prevent parent admin page from appearring as a child admin page
wordpress
My installation is of Multisite setup . when I upload an image and try to view it, getting a message 'go home baby!!' instead of image Actually the specific sub-site is also mapped with a custom domain. I thought that it is breaking the link. So removed the mapped domain and still having the same issue Tried uploading ...
The only reference I can find is this: http://wordpress.org/support/topic/how-to-block-even-direct-link-to-img-on-running-a-private-site-in-network Check your ms-files.php is the one bundled with WordPress and hasn't been modified
Suspicious mesage appears instead of images
wordpress
I tried a few echo commands, and they return properly. Breaking Statement <code> &lt;?php $gallery_ids = $wpdb-&gt;get_results( "SELECT gid FROM ".$wpdb-&gt;prefix."ngg_gallery ORDER BY gid ASC", ARRAY_A); ?&gt; </code> This causes anything after this statement not to show up, consequentially breaking the page. If I do...
Make sure you reference the global <code> $wpdb </code> variable first, otherwise PHP doesn't know what <code> $wpdb </code> is or whether or not it has a <code> get_results() </code> method or a <code> prefix </code> property. So just add <code> global $wpdb; </code> to fix it: <code> &lt;?php global $wpdb; $gallery_i...
Pasting this PHP breaks my page. Why?
wordpress
I created a page called "Projects" through the wordpress admin I created a template called "Projects" Set the "Projects" page to use the Projects template. How come when I navigate to the Projects page it shows the archive page and not the Projects template. Also, if I set the "posts page" in settings-> reading to "Pro...
This conflict normally happens when a custom post type archive and a normal wordpress page has the same slug. The custom post type archive has the higher priority here. If you have a custom post type by the name 'Projects' and 'has_archive' is set to true for the custom post type then the conflict will arise. Set 'has_...
Page is defaulting to archive page and not designated template
wordpress
My main projects page is bringing in some data that I have entered in for custom post types. There are basically a few categories like "photo", "video", etc. When you click on one of these it will go to a subpage like /projects/photo/1. How to I go about specifying a template to use for those subpages? I am using the U...
Have a look at the template hierarchy that WordPress follows. Since the sub page is a single custom post type. You could put the code you require to output for the sub pages in single-[post-type].php
Specifying a template for custom post type pages
wordpress
I need to display the online status (online/offline) for each author page (custom author page template). is_user_logged_in() only applies to the current user and I can't find a relevant approach targeting the current author e.g. is_author_logged_in() Any ideas? Answer One Trick Pony was kind enough to prepare the codin...
I would use transients to do this: create a user-online-update function that you hook on <code> init </code> ; it would look something like this: <code> // get the user activity the list $logged_in_users = get_transient('online_status'); // get current user ID $user = wp_get_current_user(); // check if the current user...
How to check if a user (not current user) is logged in?
wordpress
What I need to do is have a meta box that you can select an Image (via the built in media uploader), and then add a caption to it using a text box with the TinyMCE bar - and once this is done, another one can then be added below if needed. I found a similar question, with an answer, here: stackexchange-url ("Create mor...
I've accomplished this using the WPAlchemy library. Might not meet completely your "do it myself" requirement, but the functionality is there and you can tweak it to accomplish a lot without having to code everything from scratch.
How do I create a Meta box that can be repeated? (with an image section and text area)
wordpress
I try to get thumbnail URL correctly... In my functions.php, I have theses lines: <code> &lt;?php add_theme_support( 'post-thumbnails' ); set_post_thumbnail_size( 'emphasis', 132, 82, true ); ?&gt; &lt;?php function w_thumbnail_src() { if (has_post_thumbnail()) { $thumb = wp_get_attachment_image_src(get_post_thumbnail_...
You are not using <code> set_post_thumbnail_size </code> properly. Try with: <code> add_image_size( 'emphasis', 132, 82, true ); </code>
Get thumbnail URL :)
wordpress
Does anyone know of a nice map plugin for Wordpress. I have a diary website in Wordpress where each diary entry has the latitiude and longitude of where each post was written. I thought it would be cool for each post I could have a google map showing where each entry was written. Maybe even show the path that was taken...
There is one and two really interesting ones at the general plugin database. Slightly different with their layout options, but they both take data input (coordinates and what-have-you) in plenty of formats. hope that helps, J
Wordpress Google Maps
wordpress
I'd like to get a list (array) of all the post types I registered. Precisely I would like to retrieve their slugs. Could someone help me? thanks!
@EAMann's answer is correct, but there's already a build in WordPress function for fetching all registered post types: <code> get_post_types </code> <code> &lt;?php // hook into init late, so everything is registered // you can also use get_post_types where ever. Any time after init is usually fine. add_action( 'init',...
Get list of all registered post types slugs
wordpress
Currently this code http://pastebin.com/As0exwZy is displaying 10 posts because I set it in the Reading settings. Now what I want is to display a advertisement(widgetize) every 3 posts... how can I do that?
<code> $i = 0; while (have_posts()) { $i++; the_post(); // Output the post the_title(); the_content(); // Output an ad after each third post if ($i % 3 === 0) { echo 'ad'; } } </code> The <code> % </code> is called the modulus operator .
Archieve page, Advertisement Every 3 Posts
wordpress
This code works fine and returns two StdClass Objects for each of my two posts: <code> $children = get_pages($args); foreach ($children as $cake=&gt;$element) { $args = array( 'post_id' =&gt; $ID ); $Comments = get_comments( $args ); }; </code> This is great. I get each comment's properties but I am only interested in ...
The problem with your use of <code> foreach </code> (in both cases) is that you are erasing any previous value <code> $Comments </code> or <code> $CommentDates </code> had before the current iteration. Rather than setting the value to the variable itself, perhaps you should be appending new values onto the variable as ...
Obtaining values from objects
wordpress
Maybe I did not understand the role of comment_form(). After pasting this in my wordpress single.php I get just the form for submitting comments but NOT THE ACTUAL COMMENTS. Is this a bug, or the comment_form() does not handle listing the comments? Ty!
to list comments use wp_list_comments() functions' names tell for themselves, your CO
Wordpress comment_form() does not display actual comments
wordpress
There are many tutorials out there, but all of them give you the same code snippet. I put it into my htaccess file, but the feeds are not being redirected. I don't want to use a plugin. I'm sure the code works. I need to figure out why it doesn't work for me. Here's part of my code: <code> # BEGIN WordPress &lt;IfModul...
The rules for Feedburner should come before the WordPress rules. And activate the rewrite engine just once. That’s enough. :) <code> &lt;IfModule mod_rewrite.c&gt; RewriteEngine On RewriteBase / RewriteCond %{HTTP_USER_AGENT} !FeedBurner [NC] RewriteCond %{HTTP_USER_AGENT} !FeedValidator [NC] RewriteRule ^feed/?([_0-9a...
How to redirect RSS feeds to Feedburner and keep pretty permalinks?
wordpress
Is there a function that will let me display a category title and the last 5 post titles from that category just below it? Is there a loop which can do this and list post titles of that category in an un ordered list with the category title just above outside the loop?
you haven't stated where the category id will come from, nor how you want to style the category title, and if the post titles are supposed to be linked to the single post; therefore just the basic structure: <code> &lt;?php $cat_id = 137; echo '&lt;div class="category-title"&gt;'.get_category($cat_id)-&gt;name.'&lt;/di...
Show category name, and last 5 post titles below category name?
wordpress
I've built a basic meta box and have this in my functions.php. The current code: <code> add_action( 'admin_print_styles-post-new.php', 'portfolio_admin_style', 11 ); add_action( 'admin_print_styles-post.php', 'portfolio_admin_style', 11 ); function portfolio_admin_style() { global $post_type; if( 'portfolio' == $post_t...
Remove the wp_enqueue_style line from the above code and replace it with this: <code> add_action( 'admin_print_styles-post-new.php', 'portfolio_admin_style', 11 ); add_action( 'admin_print_styles-post.php', 'portfolio_admin_style', 11 ); function portfolio_admin_style() { global $post_type; if( 'portfolio' == $post_typ...
Styling Custom Meta Boxes?
wordpress
Is it possible to convert a standard WordPress gallery that I have created in a page to a NextGen Gallery? And if so, how do I do this?
Maybe someone will correct me, but I believe your answer is no. The reason I say no is because NextGen creates additional folders that contain your gallery images. It might be possible to tweak the settings to force it to use the current images location, but that would cause issues down the road if you have your Media ...
Can I create a NextGen gallery from a WordPress gallery
wordpress
I'm attempting to list posts from a category (a random selection). However, I only want to display one post per author. Thoughts? Appreciate the help.
Can this help you? -- http://wordpress.org/support/topic/query-post-to-show-one-post-per-author ps. I should add this as a comment, but I can't, sorry.
Query posts in a category and include only one post per author?
wordpress
I just came across this page with almost similar requirements as mine stackexchange-url ("Multiple endpoints to same page") i have to achieve same functionality but i also want to pass some parameters to the page where all these URL will be map. say example <code> http://mysite.com/test/link1 http://mysite.com/test/lin...
You can use the same answer as the question you referred to (I have answered it). Here's how you would change to pass the arguments: <code> &lt;?php add_action('init', 'add_my_rule'); function add_my_rule() { global $wp; $wp-&gt;add_query_var('args'); add_rewrite_rule('test\/finaldestination\/(.*)','index.php?pagename=...
Mapping multiple URLs to same page
wordpress
A plugin I want to use has a filter like so: add_action('comment_form_after','yoast_track_comment_form'); The theme I'm using doesn't use the comment_form() call and I believe that this means the filter isn't being called. The yoast_track_comment_form just adds some jquery tracking, so what is the best way to trigger i...
You can simply place the hook yourself in your theme (or better: Child theme) template: <code> do_action( 'comment_form_after' ); </code>
How to Trigger comment_form_after action if comment_form() not used
wordpress
I'm looking for a function, NOT A PLUGIN, that allow me to remove the Inactive Widgets... there was a topic before stackexchange-url ("Script to remove all inactive widgets?") with an answer, however it's not working for me. Any other solutions? Regards.!
<code> function andrew_unregister_widgets() { unregister_widget( 'WP_Widget_Archives' ); unregister_widget( 'WP_Widget_Calendar' ); unregister_widget( 'WP_Widget_Categories' ); unregister_widget( 'WP_Widget_Links' ); unregister_widget( 'WP_Widget_Meta' ); unregister_widget( 'WP_Widget_Pages' ); unregister_widget( 'WP_W...
Remove the Inactive Widgets
wordpress
I'm new to WP and am not sure how to re-size a picture. I want to scale down the pic of the guy on this page: http://www.millermusiclessons.com/ If you view the page source and find the source of the picture, it already has height and width attributes assigned to it. When I edit these attributes in Notepad++ and re-upl...
<code> #sidebar_img img { width: 250px !important; height: auto; } #sidebar_img { text-align: center; } </code> use this css.. change 250px with whatever you want.
Resizing Picture
wordpress
I want to add some more profile fields to Wordpress. It works fine with normal text box: <code> &lt;input type="text" name="gender" id="gender" value="&lt;?php echo esc_attr( get_the_author_meta( 'gender', $user-&gt;ID ) ); ?&gt;" class="regular-text" /&gt;&lt;br /&gt; </code> But of cause I don't want my users to ente...
Place the following code in your functions.php <code> &lt;?php add_action( 'show_user_profile', 'show_extra_profile_fields' ); add_action( 'edit_user_profile', 'show_extra_profile_fields' ); function show_extra_profile_fields( $user ) { ?&gt; &lt;h3&gt;Extra profile information&lt;/h3&gt; &lt;table class="form-table"&g...
Extra profile field as select box?
wordpress
Ok, so I'm confused as to what's going on here... I've been trying for hours now to get a relatively accurate page load timer setup on my WordPress site, but nothing is working like it's supposed to. I've added this code to my theme's header.php file as the very first block of code: <code> &lt;?php $exectime = microtim...
<code> $starttime </code> is undefined in your footer, so you're subtracting nothing from endtime. declare <code> global $starttime </code> first and it'll work. that said, it won't be a very accurate indicator of rendering time, since most of the work WordPress does happens before you ever reach the template and start...
Page load timer?
wordpress
I want to prefix my blog posts with <code> /news/ </code> and changing my Permalinks to <code> /news/%postname% </code> seems to do the trick. However, I also have a few custom post types and for some reason those URL's are now also prefixed with <code> /news/ </code> . Of course this is not what I want. How can I make...
Assuming that you are not using a plugin to handle your post types but are registering them manually: Add the <code> rewrite </code> argument to your <code> register_post_type() </code> function calls. <code> $rewrite = array( 'slug' =&gt; $slug, 'with_front' =&gt; false ); $args = array( // your other arguments 'rewri...
How to properly prefix blog post URL's
wordpress
I'm using the following code in my function.php to display the top commenters in my theme: function top_comment_authors($amount = 5){ <code> global $wpdb; $results = $wpdb-&gt;get_results(' SELECT COUNT(comment_author_email) AS comments_count, comment_author_email, comment_author, comment_author_url FROM '.$wpdb-&gt;co...
Extend the WHERE clause: <code> WHERE comment_author_email != "" AND comment_author_email != "YOUR_MAIL_ADDRESS" AND comment_type = "" AND comment_approved = 1 </code>
Top Commenters: exclude admin
wordpress
I'm having issues with my @font-face code in my style.css file for a theme. I've already tested the theme as an HTML site, and the paths are the same. The style.css file uses a relative path to a fonts folder like so: `@font-face{ <code> font-family:'Fertigo_PRO-webfont'; src:url('./fonts/Fertigo_PRO-webfont.eot'); src...
It was a permissions issue with XAMPP that was complicating things. For whatever reason, Gnome's GUI permissions interface wasn't actually changing permissions even though I thought I had changed them. I fixed it in BASH instantly. For those interested, and to add an answer for some people who may have a similar proble...
@font-face Paths Don't Seem to be working properly
wordpress
I have installed WordPress on my linode vps and it was running without a problem till today. Today I realized I dont have admin rights to post a page in wp-admin. It doesn't show me submit button, it shows me "submit for review" button instead. It is very odd because I am logged in with admin account and for example I ...
Weird.. Have you checked the database on your own? Are you in the administrator group? Get your user id from the <code> {tableprefix}_users </code> table and search for the coresponding meta key <code> {tableprefix}_user_level </code> for your user id inside the <code> {tableprefix}_usermeta </code> table. The value sh...
submit for review issue
wordpress
I want to modify the Default Registration Page of Wordpress. Want to add a few new fields and remove some. How should i go about it. I am an absolute begineer
Both modifying the fields and the styling of the user registration (as well as login, lost password, etc. pp.) page can be done programmatically as well as using plugins. The latter obviously being the much simpler way of achieving quick results. While I'm all for control and doing things on our own, in this case there...
Modifying the Default Registeration Page?
wordpress
I'm not sure if I've asked the question properly, apologies for that! What I'm trying to do is, output a <code> &lt;!--nextpage--&gt; </code> tag via a shortcode. But it doesn't work, I guess because shortcodes are applied when the content is rendered, whereas <code> &lt;!--nextpage--&gt; </code> is resolved into links...
I don't know in what exact order filters are applied to <code> the_content(); </code> and whether that's early enough, but if it doesn't work for you, I believe it is safe to assume that you're right in thinking that the shortcode is applied to late. From <code> /wp-includes/shortcodes.php </code> (line 296, wp 3.2.1) ...
Are shortcode functions applied while rendering the content, or are they executed and stored with the post content?
wordpress
I'm running a Wordpress self hosted blog with registration and I would like to know if there is a safe way to know if users hasn't login yet or if account is unused by a long time. What I would like to achieve is to be able to automatically delete accounts that aren't unused by 6 months or more or not used at all. Any ...
There's several plugins in the directory that will track the last login time of your users, each with various options: http://wordpress.org/extend/plugins/search.php?q=last+login You could use one of those to track login times, and then delete unused accounts based on the information one of those plugins provides.
How to discover and delete unused accounts?
wordpress
I have installed Job Manager and managed to filter the search to only display jobs (i.e. post_type = jobman_job) and it works ok however, when displaying the search results, it only shows the title - it does not pull the short description (the "excerpt") like the normal search does. Can anyone give me some direction on...
used post_type to differentiate the specific Job Manager posts and search those
Wordpress search results
wordpress
Here is my case, I'm making some experiments with post types, basically I created a post type called Slider where the featured image is will display in the slide. Now, when user type something like domain.com/slider/slide1, or try to reach the slider post, I want to display a not found page instead of the single page, ...
I have a script that wil; display a good 404 page for certain pages. Now I do not yet know what custom post types are, as I am just starting, but I think you can edit the script to fit your needs. <code> add_action('template_redirect', 'my_template_redirect'); function my_template_redirect() { global $wp_query, $post; ...
Display not found page 404 on specific Post Type
wordpress
Is there an easy way to highlight search results based on post_type? I am using Job Manager plugin and when a site search is performed, I want to simply add a note e.g. (Job) next to the Job Results.
i think you can PHP it using an if statement.. like so: Say this is the loop.. (simple one i know): <code> &lt;?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?&gt; &lt;?php $post_type = get_post_type_object( get_post_type($post) ); $post_type_name = $post_type-&gt;labels-&gt;singular_name if ($post_typ...
Modifying search results based on post_type
wordpress
Is there an elegant way (without hacking the plugin's code ) to integrate a Contact Form 7 contact form to Mailchimp, so I can have a checkbox that when selected would register the email to a Mailchimp list? Thank you
This is what finally worked for me . The code needs to be updated tho. I don't have time now to get back to the refactored code but if someone requests it I will do it in due time.
Integrate Mailchimp to a Contact Form 7 contact form
wordpress
Should "snippets" (short code or functions) be added to: the theme's functions.php? OR make site-specific plugins? Which is better from technical, security, performance, etc., standpoint? Besides the reason that during an upgrade the theme's functions.php may get overwritten, what would be the other reasons to make cre...
From performance point of view, I don't think there is any difference between functions.php and plugins : it's just different places for the code to be. I would be practical : if the function is part of the theme's core (say, a scrollable slider in the header without which the theme is worthless) : it's a function of t...
Snippets: is it better to add them in functions.php or make site-specific plugins?
wordpress
Cross posting my trac question here in the slim hopes that someone here has run into the same issue and has already come up with some proof of concept code I can try: In building a custom 'theme plugin' for bbpress I was just made aware that it is impossible for a plugin to 'transparently' add/append template files to ...
There isn't an easy way to do this at this time. Check out stackexchange-url ("this question's answers") for some potential work arounds.
add/apend templates 'transparently' via plugin to currently active theme or child theme?
wordpress
I have made my Front Page as a Static Page. The Page is having a Introduction Content. I am showing this content as an introduction to the site. But it displays "Leave a Reply" Box below it. I do not want the users to give comments on this content. Can somebody suggest How to suppress this for my Static Home Page for a...
Follow these steps: Go to 'Pages'. Look for the page you've set as your homepage in the list. Hover your cursor over the title and click on 'Quick Edit'. Uncheck 'Allow Comments' and then 'Update'. Edit: For disabling Trackbacks and Pingbacks (and Comments too!): Open the page you've set as your homepage for editing. L...
How not to show leave a Reply to Home Page?
wordpress
I am pre-writing some posts that will be published next year. My permalink structure is <code> /%year%/%postname%/ </code> After setting the post title, the permalink says it will be <code> http://www.amazeaweek.net/2011/spiral-out/ </code> which reflects the year I'm writing it. But I'd like it to be <code> http://www...
After clicking [publish] once or twice, the permalink fixes itself automagically; I didn't see it before because I didn't want to save with the "wrong" permalink.
permalink %year% of pre-written posts to be published next year, in the mysterious future (*)
wordpress
I am completly new to WordPress. I have a requirment where I need to develop a site where people will form communities and will blog around. They will make friends and send friend request. So its much a combination of social Networking Stuff combined with Blogging Stuff. Can somebody suggest that if I should go for Wor...
Take a look at the http://buddypress.org/ plugin
Can I develop a social networking Site using WordPress and its Plugins?
wordpress
i am creating a related post article feature for my wordpress enabled site.being new to php and wordpress facing some issue. though i can user wordpress build in feature to show related post of author but since site is hosting articles of authors who don't have any profile with us and there are many such authors so whe...
I think you need to tell that the query is paged. Did you tried : <code> $args = array( 'meta_key' =&gt; 'author_email', 'meta_value' =&gt; 'XYZ@XYZ.com', 'paged' =&gt; $paged); </code> ?
getPost() method and Pagination
wordpress
I'm trying to make a nav to access all the different galleries on a single page. Instead of hard-coding all their names out. I was curious if it was possible to make this dynamic and just call all the ID's of all the galleries, with maybe an exclusionary on the two that are slideshows. Anyone got any fresh ideas?
All your Galleries are stored a table called <code> wp_ngg_gallery </code> in your wordpress database. (For the sake of completeness: nextGen Gallery creates 2 more tables for albums and pictures, respectively) <code> $gallery_ids = $wpdb-&gt;get_results( "SELECT gid FROM ".$wpdb-&gt;prefix."ngg_gallery ORDER BY gid AS...
Using nextGen Gallery.. how can I call a list of all Gallery Names?
wordpress
Im trying to figure out howto structure general content that should be easy to import in a page template. Lets say for example i have some contact details and i want to include this content on multiple pages. One way i tried was to create a custom post type and just add posts for Email Phone Address I would then simply...
Using custom post types for this seems like a bad approach. Instead, create a simple option page in the admin using <code> add_options_page </code> , displayed in the menu under "Settings", for example. Lay out some input fields for each piece of data you want to save. You can use the options API to read and write each...
Wordpress general content best pratices
wordpress
I want to make a simple website where users can register to my site. they can have their profile page. when they login they should be redirected to their profile page. Subscribers should not be allowed to view their profile in admin side. suggest me plugins or way to do it. Thanking for answer.
you don't need any plugin.just add this code to your function.php file which you will find in your theme folder. <code> add_action( 'init', 'blockusers_init' ); function blockusers_init() { if ( is_admin() &amp;&amp; current_user_can( 'subscriber' ) ) { wp_redirect( home_url() ); exit; } } </code>
restrict subscribers to admin area. They have their own profile on fron-end
wordpress
I've tried a couple of methods but I cannot seem to filter custom post_types from my search results and was hoping someone could help. I have installed "Job Manager" and created 4 jobs which have a custom <code> post_type = 'jobman_job' </code> I tried to create a manual search form and set a hidden value of <code> pos...
NOT TESTED! <code> function mySearchFilter($query) { $post_type = $_GET['type']; if (!$post_type) { $post_type = 'jobman_job'; } if ($query-&gt;is_search) { $query-&gt;set('post_type', $post_type); }; return $query; }; add_filter('pre_get_posts','mySearchFilter'); </code>
WordPress Custom Search by post_type
wordpress
I'm trying to access the page ID of the child so that I can recursively call the get_children function on that child (to get grandchildren). <code> if ($CurrentPage) { $args = array( 'child_of' =&gt; $CurrentPage ); $children = get_pages( $args ); foreach ($children as $key =&gt; $value) { echo $key.'=&gt;'.$value.'&lt...
The return set of $children is an associative array. So you can get the IDs with: <code> $children = get_children( $args ); foreach ($children as $k =&gt; $v) { echo $k; // do stuff with $v } </code>
Accessing array elements (get_pages)
wordpress
I am creating a set of plugins that all use AJAX. Now localizing the admin.php in all the plugins seems to be a bit of an overkill. Is there a way to localize the script only once.\ Now I do not know which plugin would be initialized at first, so I have to place the localize function in all the plugins. The way I do it...
Good question, and one I've dealt with, but never quite satisfactorily. It would be very nice to figure out a core function that handles this. In the meantime, though, I would just bypass the whole <code> localize_script </code> function and add an action to <code> wp_head </code> that just defines a global javascript ...
How to localize admin.php only once
wordpress
I'm using this code to call some custom post meta named port_excerpt: <code> &lt;?php global $wp_query; $postid = $wp_query-&gt;post-&gt;ID; echo get_post_meta($postid, 'port_excerpt', true); ?&gt; </code> This works like a dream when used on the template it is intended for: http://themeforward.com/demo2/portfolio/new-...
You need to put this inside the loop running on the portfolio page. <code> echo get_post_meta( get_the_ID(), 'port_excerpt', true ); </code>
Custom Post Meta on a Different Page?
wordpress
I building a site in WordPress (my own theme) that includes a very simple "sign up" email form. Person enters name and email address and hits submit button. Client currently using a script through Bluehost so I want to recreate vs. using a form plugin. The form is fine. After hitting "submit" person is redirected to a ...
There's a great function called wp_redirect() , unfortunately not supporting "last page" argument yet, but I hope it will soon. I believe the easiest (but not the most elegant way) way to achieve what you need is by using JavaScript, in jQuery it will look like: <code> &lt;script type="text/javascript"&gt; jQuery(docum...
How code a redirect back to page from form thanks
wordpress
Hi all, I'm a newb here, but hoping someone might have the answer to my question. Within my functions.php file, I have this code: <code> //Contractor Page meta box details $contractorpage_meta_box=array(); $contractorpage_meta_box[]=array( 'id'=&gt;'contractor-page-meta-box', 'title'=&gt;'Contractor Page Details', 'pag...
<code> function youtube($atts) { global $post; $value = get_post_meta($post-&gt;ID, 'video_link', true); extract(shortcode_atts(array( //Make sure not to include the 'value' as part of this array. "width" =&gt; '475', "height" =&gt; '350', "name"=&gt; 'movie', "allowFullScreen" =&gt; 'true', "allowScriptAccess"=&gt;'al...
How to call a specific value within the functions.php file?
wordpress
I'm working with the BuddyPress extended profile component and would like to add image fields to the WordPress user profile. Is there code that I can add to my theme's functions.php so it inserts the "Image" option into the plugin? I have searched the BuddyPress and WordPress Codex forums and haven't come across code f...
I figured out a way to go about adding the image type field without editing core BuddyPress files. The solution involves adding code to the theme's functions.php that intercepts the plugin's loading, display and saving. It also updates the WordPress upload location in order to direct the profile images to a subdirector...
How can I add an image field to BuddyPress Extended Profile Fields?
wordpress
Here's my code: <code> $args = array( 'child_of' =&gt; $CurrentPage ); $children = get_pages( $args ); foreach ($children as $child) { foreach ($child as $key =&gt; $value) { echo $key['post_title']; } }; </code> And output: <code> IpppppppcppptpppppgmppcfIpppppppcppptpppppgmppcf </code> The output appears to be the fi...
You're doing one to many loops. What you want to be doing is this: <code> $args = array( 'child_of' =&gt; $CurrentPage ); $children = get_pages( $args ); foreach ($children as $key =&gt; $value) { echo $key['post_title']; }; </code> Or you could also: <code> $args = array( 'child_of' =&gt; $CurrentPage ); $children = g...
Accessing value from associative array
wordpress
I'm having problems finding a "plugin" that will help me display some of my images in a nice way such as prettyPhoto, Lightbox etc. As I'm already using the jQuery library, I'd prefer a plugin that works with jQuery rather than Scriptaculous. I tried to implement the newest version of prettyPhoto as well the the jQuery...
Here is my code for using thickbox in my themes. It works on all the ones I build. I've tried several ways suggested on other sites, but none worked for me. Try the script out, if it doesn't work, you probably have a plugin or another script in your theme that's doing it wrong. Here's the code: <code> &lt;?php function...
Any good lightbox-like option that works in WP 3.2.1?
wordpress
I'm modifying the layout and content of the wordpress admin panel using a custom plugin. For most sections I have been able to change the page heading (i.e. the title wrapped in h2 tags at the top of each page), however I've been unable to do so for sections to relating post types, specifically adding and editing posts...
In <code> wp-admin/edit.php </code> at line 189 you can see that the title text is grabbed from the labels of the post type: <code> &lt;h2&gt;&lt;?php echo esc_html( $post_type_object-&gt;labels-&gt;name ); ?&gt; ... &lt;/h2&gt; </code> When you register a new post type ( <code> register_post_type </code> ) you can als...
How can I modify page content in the admin panel?
wordpress
Hello I tried to find the solution but couldn't get what I am looking for..I am getting error exactly as bellow.. Notice: Undefined index: page in C:\xampp\htdocs\site\wp-content\themes\mytheme\admin\admin-panel.php on line 745 and code on line 745 is <code> function mytheme_add_init() { $file_dir=get_bloginfo('templat...
Looking at your actual source, the relevant portion (with line numbers) is this: <code> 745 if ( $_GET['page'] == basename(__FILE__) ) { 746 747 if ( 'save' == $_REQUEST['action'] ) { 748 749 foreach ($options as $value) { 750 update_option( $value['id'], $_REQUEST[ $value['id'] ] ); } 751 752 foreach ($options as $val...
Undefined index: debuging error for theme option template snippet
wordpress
I've installed a plugin that puts google analytics code to the page of each post. But it did not install google analytics code to home page and because only a small portion of users click on the post's page I can not track the users. How can I install google analytics manually to the home page and if I do so I could no...
This depends on your theme. Most themes have a call the <code> wp_footer </code> hook at the bottom of every page - which means it's at the bottom of every single post, every single page, and the home page. Rather than editing all of your theme files to include your tracking code, use a plugin that ties in to <code> wp...
Installing Google analytics to home page
wordpress
I've recently created several custom post types in a wordpress site, with the code below, they are generating links in the correct form e.g. root/category/id/postname but each link to the full post, pagination or category 404's. I've tried a number of popular solutions, appending /%category%/%post_id%/ to the url struc...
Flush your permalinks whenever you add/remove/modify a taxonomy or post type. You can do this in the backend by simply going to the permalinks page and resaving
Wordpress custom post type post and category links 404
wordpress
I want to develop a site like http://www.webpresent.biz/ Should I develop in wordpress? How much effort is required? Plugins available? Help would be appreciated.
The amount of effort depends on the level of preparation and thought you put into the start of the site. You should have a clear end goal, and as many details as possible. With that in place you just kneed to know enough about the available WordPress functions so you can choose which is right for your set of options. T...
how to implement a site like this in wordpress?
wordpress
I'm not using the full settings api, just this code: <code> register_setting( 'my_options', 'my_options', 'my_options_validate' ); </code> Then my validation: <code> $options = get_option('my_options'); if(error_found){ add_settings_error( 'my_options', 'settings_updated', 'error_message_here', 'error'); } return $opti...
No, you need to add a call to settings_errors <code> /** * Displays all messages registered to 'your-settings-error-slug' */ function your_admin_notices_action() { settings_errors( 'your-settings-error-slug' ); } add_action( 'admin_notices', 'your_admin_notices_action' ); </code> Else the errors you added will not be d...
Displaying errors with settings api
wordpress
So I've been working with WordPress for a while now and I usually develop locally and then upload everything to my Prod server... however, I've experienced a lot of differing results, especially when using plugins. I usually export the database, but things like the location of the domain don't always seem to get change...
Any difference between dev and prod is bad. Here is what I do: Have a different ip for dev server (Whether internal, external, or on local computer is unimportant) -- but dev server must be the exact same setup (see bottom paragraph) Change the hosts file (see here) (on yours or a testing computer or a virtual machine)...
Most Flawless Way To Transfer from Dev to Prod
wordpress
I recently updated the WP of a friend's site that I'm working on. Now his navigation bar is messed up and I'm new to WP so I'm not sure where to go to fix it. Here's the site: http://www.millermusiclessons.com/ Here's what the nav should look like: http://www.millermusicllc.com/ Thanks
It's not WordPress that messed it up, it's something with your theme. On the working site, your navigation bar looks like this: <code> &lt;ul class="sf-menu sf-js-enabled sf-shadow"&gt; &lt;li class="page_item page-item-4 current_page_item"&gt;&lt;a href="http://www.millermusicllc.com/" title="Home"&gt;Home&lt;/a&gt;&l...
Updated WordPress, now Navigation is Messed Up
wordpress
is there any Way to Catch Last widget box or div from same widget area?? i mean i have 4 widgets in footer widget area but due to design issue my 3rd widget box style+width is different.so i want to add extra class to 3rd box container using php.is there any way to do that? please reply. Thanks in advance. :)
Add the following code in your functions.php file of the theme directory. Replace widget name "Home Widget Area" with your widget's name <code> /*=============WIDGETs CSS CLASS CONTROLLER==============*/ $GLOBALS['my_widget_num']=1; function edei_widget_class_adder($params){ if( $params[0]['name']=='Home Widget Area' )...
How to Catch Last Widget box From Same Widget Area?
wordpress
I have a few different custom content types and would like to give my users the ability to favorite or 'like' (like Facebook, but not for Facebook) pieces of content so that they can later view a list of their favorited content. I've searched everywhere but haven't come up with a clean solution. I'm pretty comfortable ...
You might have already thought of this, but have you thought about a plugin. I was sure that the WPMU Dev guys did one that did a like (that wasn't FB related) but I can't find it (if you want to look it must be somewhere here but I've gone through it all and I can't find it now http://premium.wpmudev.org/wordpress-plu...
User ability to favorite or 'like' content
wordpress
I don't have the feeling that my blog is particularly slow, but that's because I haven't really started out yet. I'm very worried that it will get slow soon, especially because I will have blog posts with (optimized/compressed) 40-50 photos. This can't be changed, but other things can. I already read a lot about it, we...
I was in a similar situation recently and started using W3 Total Cache too. I'm not sure what settings you have at the moment, but it's worth experimenting a bit if you can to see that you're really using W3 Total Cache to the max For example, I originally only had Page Cache and Browser Cache checked on the main scree...
Speed up Wordpress
wordpress
I creating shopping cart, based on custom post types . And for this cart I have two related custom taxonomies. I need to create shop.mysite.com instead of mysyte.com/shop only for this one custom post type. I dont need multisite solution. All posts of current post types will be opened as shop.mysite.com/some-post/. Rel...
While multisite would give you exactly what you wanted via domain mapping, you've opted to throw away this option in favour of the much more time consuming and harder method of manual htaccess rewrites etc. The challenges you face include: Telling wordpress to rewrite the permalink URLs it outputs to shop.mysite.com bu...
How to create subdomain for custom post type and associated custom taxonomies
wordpress
Is it possible to localize a script more than once? I want to send two separate arrays of params. Or is it only possible to localize a script once, in which case, I'll have to combine the arrays? I'd like to do something like this: <code> wp_localize_script('my-handle', 'my_object1', $data1 ); wp_localize_script('my-ha...
This will be possible in WP 3.3: http://core.trac.wordpress.org/changeset/18480
Multiple wp_localize_script
wordpress
I find inline links offputting to read so want to use wikipedia style foot-of-article references with incremental numeric linking to the external link reference. I can just stick the HTML in but on the off chance is there any plugins on WP for semi-automating the process?
I think Netblog plugin seems to be what you're looking for. Connect posts and external resources (websites, pdf, doc, zip, exe). Use Captions, Footnotes, Bibliography. Netblog is highly customizable.
Plugin for wikipedia style references in WP?
wordpress
Take a look at: http://www.themeforward.com/demo2 . When I hover over a menu item with a sub-menu, like 'Templates', and mouse over sub-menu items the background color stays the same as it should... but the hover color of the text does not. How do I make the font color remain the same while scrolling through the sub-me...
Try changing the style of: <code> .sf-menu a, .sf-menu a:visited { /* visited pseudo selector so IE6 applies text colour*/ padding: 5px 10px; color: #FFF; text-decoration:none } </code> The white text colour appears to be coming from there.
Superfish and WordPress: Active Color Problem
wordpress
Basically what I want is to create an EVENT post type. So people can put in a date and time of the event. (I've got this far... this is fine). The bit that I can't seem to figure is now I want to be able to make pages as SUB PAGES of that meeting. I'm not really bothered how I do this to be honest, although I figured t...
Unfortunately at the moment that isn't really possible. You can set up the posts manually or via a custom UI to have the right parentage, but the permalinks will not work, defeating the point. What's more even if it did work, after the first event, you'd have clashing permalinks, and wordpress would rename your second ...
Creating a website with EVENT post type and PAGES as subpages of those EVENTs
wordpress
I'm using a few plugins and UpThemes framework on my new website and if I turn on Wp Debug I can see that there are a few errors related to Deprecated functions (but website is working). What I would like to know is if there is a plugin, a software or a pray (lol) that I can use to know exactly where the deprecated cod...
What you're looking for is the Log Deprecated Notices plugin . (Don't run it on a production site, as it is a direct-to-database log.) What it'll do is convert those cryptic messages that are likely to reference has_cap() or some line in functions.php, to what's actually going on. The Debug Bar plugin is also nice. It ...
How to debug WordPress correctly?
wordpress
I have a settings page for a plugin which I created using this function: <code> function vsp_create_menu() { add_menu_page( 'Visitors Statistics', 'Visitors Statistics', 'manage_options', 'vsp_settings_page', 'vsp_settings_page_function', plugins_url( '/images/icon.png', __FILE__ ) ); } </code> That created a plugin se...
The fourth parameter of <code> add_menu_page </code> is the menu slug. Hence the form action should start with: <code> admin.php?page=vsp_settings_page </code> , if you want to stay on said page. If your form is correctly written, it should populate the query string in the URL. You should have probably posted all your ...
How to add a custom form to a plugin's setting page
wordpress
I have a wordpress install that I have been working on and now I want develop the install on my local server. I have downloaded all of the site files and added it to my local server directory. I also exported the live database and import into the local install's database. The only credentials that I changed for the dat...
Remove WP_HOME and WP_SITEURL from your wp-config.php, and then check in the wp_options table for the values "siteurl" and "home" and change them to http://localhost/sitefolder . It must be an absolute URL. The WP Codex has more information about changing the site URL.
Moving Wordpress from live to local server
wordpress
I am trying to change some of the titles of my posts and their respective permalinks. After I edit the title and permalink and click 'ok', the permalink appears to have changed temporarily. However, when I click 'update', the permalink changes back to what it was originally. Is there anything that may be preventing the...
Have you somehow hidden/removed the slug metabox? (is something like this located in your functions.php?) <code> function remove_post_meta_box() { remove_meta_box('slugdiv', 'post', 'normal'); } add_action('admin_menu', 'remove_post_meta_box'); </code> If that's the case, it's causing the error. There is a Trac ticket ...
Can't change permalink url after hitting 'ok' and 'update'
wordpress
Over the last few months I've seen stories popping up in my timeline from various newspapers and websites where people have read certain articles, for example somebody has read a story on yahoo or guardian etc... ( examples here ) Is there a WP plugin to achieve this or is this a standalone FB app that would have to be...
People have been calling these 'gestures'. They are a facebook action which the developer defines in the new open graph. It is the equivalent of a 'like' action, but can be changed depending on the user action -> https://developers.facebook.com/docs/beta/opengraph It basically means dev's can add verbs in to describe h...
WP / Facebook integration - recently read articles
wordpress
I am using custom taxonomies. I have multiple categories and each category has multiple children. I would like to display the categories in two columns on my homepage similar to linkcentre.com. I tried using wp_list_categories but could not split its output into two columns. I tried this solution but it only works when...
You don't need any code changes to your PHP or html! Assuming the following code was used: <code> &lt;ul class="mypagelist"&gt; &lt;?php wp_list_pages('sort_column=menu_order&amp;title_li='); ?&gt; &lt;/ul&gt; </code> Resulting in: <code> &lt;ul class="mypagelist"&gt; &lt;li&gt;Page 1&lt;/li&gt; &lt;li&gt;Page 2&lt;/li...
How to divide and display categories into two columns
wordpress
I have a test site here (with WordPress 3.2.1) Since I activate the multisite support, the add featured image disappear. I try to deactivate all the plugin and activate the default theme (twenty eleven with has add_theme_support ('post-thumbnail') by default) but nothing change. The post thumbnail show up normaly on th...
I find the solution. The problem start when I activate the multi site on the test site. In the network setting, in Upload Settings Everything works now.
add featured image dialog box disappear
wordpress
How do I escape a right bracket in a short code? I'm working on a Google Map plugin that has encoded points. Sometimes the polygons have the ] in it, which makes WP think that it's the end of the shortcode. For example: <code> [my_shortcode latitude='36.93' longitude='-72.98' encoded_points='ortlF~g]tM?cZEH`z]}|@DQfi]'...
I don't know of an official escape syntax for shortcodes and there likely isn't one. When wordpress parses for shortcodes it looks for [ and ] . If you want to use square brackets within a shortcode, using the respective html ASCII entities escapes them. I.e. replacing [ by <code> &amp;#91; </code> and ] by <code> &amp...
How do I escape a ']' in a short code?
wordpress
Google Webmaster Tools shows a bad URL of /?p=xxxx This page id does not exist. I don't use this form of permalink at all. If I try using a 301 redirect or RewriteRule in .htaccess nothing happens. All my other redirects work fine, but none of them include the format /?p=xxxx Is there a method to redirect this specific...
You might not use that form of permalink, but it still exists. By default, unless you are using a tool like JetPack, WordPress uses the default permalink as the post's "shortlink." So if your regular post title is <code> http://mysite.com/2011/11/my-really-cool-long-post-title </code> and the post's ID is 32, the same ...
Redirect deleted page URL ?p=xxxx
wordpress
Case: I <code> register_post_type() </code> 3 different CPTs 1) Example: 3 post types named party, event, location . The other needed arguments in the array are left out. <code> register_post_type( 'party' ,array( 'show_in_menu' // true (for main) or "edit.php?post_type=party (for subentries) ) ); </code> Then I set th...
Customizing the menu this way is as for as I can tell, not very friendly. What I had to do recently was custom built the submenu item using <code> remove_submenu_page </code> for all the sub menu items and then add them in the order I wanted using <code> add_submenu_page </code> . A simple example <code> //this was fir...
register multiple post types on one menu entry
wordpress
Easy question: I'm trying to understand wp_localize_script. Does wp_localize_script call a javascript function or does it simply pass PHP parameters to javascript? I want to pass php parameters to a javascript function and call the js function.
<code> wp_localize_script </code> takes an array of data (in PHP) spits out a javascript. It's a way for you to add dynamic data for a specific script to the front end without having to hook into wp_head or wp_footer and echo it out yourself. More over, <code> wp_localize_script </code> outputs your data right above th...
Does wp_localize_script Call a Javascript Function or Simply Pass PHP Parameters to It
wordpress
Let's say I have a query stored in a array. I want to parse this array, find the first posts inside this array that match a certain value from a certain key, and so extract the whole post. Is there a elegant way to do it ? Or, is it possible to run a query_posts() inside this array ? Thanks ! Edit: Sorry, just learning...
<code> // store the IDs of the posts we've already displayed to prevent duplicates $used_ids = array(); $highlights_posts = request_highlights($slides_id); foreach( $highlights_posts as $post ) { setup_postdata($post); // check if we've already done this post if(in_array($post-&gt;ID,$used_ids)){ // skip to the next on...
Querying a query
wordpress
I want to create a custom widget so the user can select 2 images from the media library via a dropdown box and display them in a sidebar. So I need the widget to display 2 drop downs, which each show the TITLE of the images in the media library. I then need to save the url of these two images to use in the front-end (l...
Try this code. <code> class Image_Picker extends WP_Widget { function Image_Picker() { $widget_ops = array('classname' =&gt; 'Image_Picker', 'description' =&gt; 'Pick 2 images from media library'); $this-&gt;WP_Widget('Image_Picker', 'Image Picker', $widget_ops); } function form($instance) { //WIDGET BACK-END SETTINGS ...
Image picker widget
wordpress
is it possible to change the readme.txt of a plugin that is hosted at <code> http://wordpress.org/extend/plugins/plugin-name </code> without tagging a new version? I would like wordpress.org to show the new readme.txt. I have added a link to the plugin documentation but I do not want to force the users of updating thei...
Yes, just change the readme in the tagged directory that is marked as stable.
Change Wordpress.org hosted plugin readme.txt
wordpress
Alright, I've made a bunch of themes over the years, and I've written a lot of queries. And I just realized that I apparently have no clue how to get multiple queries to behave. So, here is the loops from my index.php: <code> &lt;?php do_action( 'voodoo_pre_loop' ); ?&gt; &lt;?php if( is_home() ) : ?&gt; &lt;?php $args...
The first query should be reset with <code> wp_reset_postdata() </code> after its loop has finished to avoid conflicts with the main query. Glancing over your code, that's the most important flaw I see. Also, I'd use <code> $my_query_2 = new WP_Query( $more_args ); </code> for the second one - I don't see why it'd be b...
2 loops, is_home won't work, count is off
wordpress
I know this question has been asked in different forms. But as far as I can tell from searching Google and SE/WP it's never been satisfactorily answered. Let's say I have a taxonomy clubs and a custom post type person . On each <code> taxonomy-club.php </code> page I display all the people who are members of that club ...
I would go for custom nav menu walker... <code> //define the custom post type and custom taxonomy define("MENU_CPT", "people"); define("MENU_CT", "club"); //custom function for selecting posts based on a term function get_posts_by_term($term_id, $post_type=MENU_CPT, $taxonomy=MENU_CT) { $args = array( 'posts_per_page' ...
How do I dynamically populate wp_nav_menu from a custom taxonomy?
wordpress
I have some code that basically looks like this (it's more complicated, but even this example shows what I'm running into): <code> echo '&lt;a href="#"&gt;TEST&lt;/a&gt;'; </code> However, what gets sent to the browser is not <code> &lt;a href="#"&gt;TEST&lt;/a&gt; </code> , but instead <code> &lt;a href="http://exampl...
Just ran that exact code snippet on WP 3.3 to test. In practice, <code> &lt;a href="#"&gt;test&lt;/a&gt; </code> is rendered in the markup correctly, but the browser will attempt to navigate to <code> http://example.com/current-page/# </code> when you hover over the link or click on it. This is the expected behavior of...
Are href attributes of a elements filtered on output to add the current path?
wordpress
I created a code for querying child pages when we're on a parent page and also display brother pages if we are on a child page, and works amazing... now my problem is, I cannot find a parameter like post_per_page that allow me to limit the number of page displaying, so far I need to display 5, but if a 6 is added the s...
Maybe array_slice($subpages, 0,5) to cut the array after 5 entries?
Limit the number of child page displaying
wordpress
Every media item that is uploaded to Wordpress can be viewed in a page. This can be seen if you browse to the Media section, hover on any item and click view. Are there any benefits to this because I am not seeing any at the moment. Can this feature be edited (or removed)?
It is desirable because you can modify that page, to introduce extra functionality. e.g.: Comments Meta data custom fields titles descriptions Image EXIF showing geolocation data video/audio players thumbnails of other images attached to the post, e.g. the other pictures in the gallery If it troubles you, you can 'remo...
Why does WP allow to view and media item as a page
wordpress
Maybe someone can help me with a small problem I'm having. I'm trying to use this: http://jquery.malsup.com/form/ to create a submit form for Wordpress. I've tested it on a regular site(not WP) and it works. I can't figure out why it won't work in wp. This is my form. I've created two page templates, one has the form, ...
Leave the action value as blank. Give the <code> submit </code> button a name as <code> name='form_sub' </code> . Then add the following code to your <code> functions.php </code> file. Check the codex for <code> init </code> hook. You can create a 'Thank You' page, or a confirmation page where the user should go after ...
Front end submit form with jquery form plugin
wordpress
How do you display the archives of a Custom Post Type by Year &amp; Month?
Yes, you can. All you need is make a filter for <code> wp_get_archives(); </code> so it accepts <code> post_type </code> parameter: <code> function my_custom_post_type_archive_where($where,$args){ $post_type = isset($args['post_type']) ? $args['post_type'] : 'post'; $where = "WHERE post_type = '$post_type' AND post_sta...
Custom Post Type Archives by Year & Month?
wordpress
I managed to get the #content field html with this jquery call: <code> jQuery("#content").html() </code> This seems to be failing though on "Add New Post" pages. Any tips on how to get the contents of the #content div? Cheers
The div <code> #editorcontainer </code> contains a regular textarea <code> #content </code> and an iframe <code> #content_ifr </code> . The <code> #content </code> is filled with the saved contents of the post when the page loads. This means that any live edits of the content won't be returned when calling <code> jQuer...
jquery: getting contents of #content field on post page
wordpress
Inside a WordPress site I load a external xml file parse it and show some links. The link looks like this: <code> domain.com/prof/vac/item?guid=1234&amp;title=foo </code> This works, but now i would like the url to look like this: <code> domain.com/prof/vac/item/1234-bar </code> when I create a link to that url and cli...
You can use the details here in this answer to solve your problem : stackexchange-url ("Pretty URL with add_query_var") Something along the lines of <code> add_rewrite_endpoint('item', array(EP_PAGES)); </code> resulting in a rewrite rule that would let you use /prof/vac/item/1234 which you would then check in the vac ...
custom data in url
wordpress
I have created user meta options using this tutorial. Now I want to know how to allow users to edit (update) certain custom user meta options that I created. Users already have a template account page where they have access to some user meta options. I added the a function to the users' page to update the meta field up...
"edit_user_profile_update" is not an action... check: http://codex.wordpress.org/Plugin_API/Action_Reference update_usermeta() is deprecated in wp 3 and above, use update_user_meta() your form is lacking some standard hidden fields like: <code> &lt;input type="hidden" name="user_id" id="user_id" value="&lt;?php echo es...
Front end user meta options for users
wordpress
Is it possible to cancel comment submission if certain creteria are met? I want to limit the number of characters in a comment. Where do I test the length and cancel the comment if it's over a given length? Would the pre_comment_approved filter do this? And does anyone have some sample code for how to use pre_comment_a...
You are certainly on the right track. You can create a plugin (create a directory in "wp-content/plugins" and create a php file with the same name as the folder) with the following code: <code> function wpse_33944_filter_handler( $approved , $commentdata ){ if(strlen($commentdata[comment_content]) &gt; 5) { return fals...
Cancel comment filter?
wordpress
As said in the title, I am creating a blog on my companies new website using Wordpress but I have sidebar issues. The website is only in production phase at the moment. The Link is so you can see is: http://madhousecreative.co.uk/completegroup/Blog/ Heres an image of what it is currently. Whenever I try to move the sid...
You need to do three things: firstly, your markup is incorrect, take the container_24 div the main content sits in and make it grid_17 so it doesn't take up the entire width of the container div. The sidebar needs to go in the container div along with the content, else it will be pushed downwards by the container div B...
Creating a blog on my companies new website using Wordpress but I have sidebar issues
wordpress
I'd like to have a custom registration confirmation page live within a WordPress site. I can provide a URL for this page to an external site. When the registration is successful the URL has several parameters, one of which is 'name' (which of course is a reserved word in WordPress) and a 404/page not found results. The...
In case it's useful for someone else in this situation, I ended up creating a page outside WordPress which renames the 'name' parameter (to 'username') and then redirects to the page I originally wanted to hit. My code for this external page is: <code> &lt;?php $data = array('UID' =&gt; $_GET['UID'], 'username' =&gt; $...
How to deal with a GET variable of 'name'?
wordpress
I have this code for display posts between two particular dates: <code> $s = '2011-10-23'; $e = '2011-11-17'; function filter_where($where = '') { $where .= ' AND post_date &gt;= $s AND post_date &lt;= $e'; return $where; } add_filter('posts_where', 'filter_where'); query_posts($query_string); </code> But that's not wo...
I think its because the SQL statement needs the dates inside the quotation marks. Try <code> $where .= " AND post_date &gt;= '$s' AND post_date &lt;= '$e'"; </code> That should work, otherwise, try <code> $where .= " AND post_date &gt;= '".$s."' AND post_date &lt;= '".$e."'"; </code>
Display posts between two particular dates
wordpress