question
stringlengths
0
34.8k
answer
stringlengths
0
28.3k
title
stringlengths
7
150
forum_tag
stringclasses
12 values
I'm using the following code in my category.php file. I want it to show my custom post type 'Products' the thumbnail and an excerpt. At the moment it's showing the post title, the thumbnail for all the posts. However it's only showing the excerpt for the first post. <code> &lt;?php /* Template Name: Category */ ?&gt; &...
I suspect you're misusing <code> query_posts() </code> , which is always and only ever intended to modify the Primary Loop . <code> query_posts() </code> is meant for altering the main loop. Once you use <code> query_posts() </code> , your post-related global variables and template tags will be altered. Conditional tag...
Excerpt is only getting shown for first post
wordpress
I tried with this code: <code> function home_page_menu_args( $args ) { $args['show_home'] = true; return $args; } add_filter( 'wp_page_menu_args', 'home_page_menu_args' ); </code> but gives me this error: <code> Error 404 - Not Found </code> I would like that when I click on "Home Page" menu appears the recent posts. A...
To add a home link to menus that you create via the menus admin area: go to the Pages box, click the 'View All' tab 'Home' will appear, check the box and click 'add to menu'
How to show Home Page link in Wordpress Menu and how to add an icon to this?
wordpress
Is it possible to hook or filter the attachment creation process? More specifically is it possible to hook into the attachment creation so that I may parse the attachment’s filename, populate the attachment’s Meta data (title) with a filtered version of its filename? If not, are hooks and filters planned for the media ...
You can hook into the 'add_attachment' action from wp-includes/post.php Line:3738. It passes in the post_id and from there you can get the file name and then update the post meta with anything you need to.
Is it possible to Hook/Filters Attachment Creation?
wordpress
I'm working on creating a custom content type but I'm having a bit of a problem formatting the create and edit views. I want to disable the main editor and focus only on the title, excerpt, and custom fields. I have the following jQuery code that will add the WYSIWYG to my custom fields, and that works fine: <code> &lt...
I just had the exact same issue. You have to include the editor in the supports argument array to get custom mce boxes to show. I solved the issue by hiding it with CSS: <code> function move_posteditor( $hook ) { if ( $hook == 'post.php' OR $hook == 'post-new.php' ) { add_action( 'admin_print_footer_scripts', 'remove_e...
WYSIWYG on custom meta boxes while disabling main editor?
wordpress
I have been digging the code for days and no solution. :( I have a Custom Post Type and two different Taxonomies. It is possible to achieve the following permalink structure (with add_rewrite_rule, mod_rewrite or post_type_link post type filter) or not? <code> mysite.com/post-type-slug/post1 mysite.com/post-type-slug/t...
I'll look into the last two soon but for the top 3 you could do the following: mysite.com/post-type-slug/post1 : This defaults to the post type name you specify when registering it but can be altered by changing the <code> rewrite </code> argument in the <code> register_post_type() </code> call. <code> register_post_ty...
Custom permalink structure
wordpress
I've been tasked with configuring a LAMP stack on a dedicated server to run multiple WordPress sites. Each site is attached to it's own SSH account. I'm having trouble setting permissions that'll allow each user to easily perform updates, plugin installs and updates, and the like from within WordPress. Normally I'd con...
Yes have a look at SuPHP http://www.suphp.org/Home.html , this should be on serverfault, not really a WordPress question.
Configuring WordPress permissions for easy updates
wordpress
I have to remove some profile fields from the 'Profile' page according to the user roles. For removing the color picker I used <code> remove_action("admin_color_scheme_picker", "admin_color_scheme_picker") </code> . I want to remove these fields: Nickname Display name publicly as AIM, Yahoo, Google talk and About yours...
For the contact methods filter: <code> user_contactmethods </code> . <code> add_filter( 'user_contactmethods', 'update_contact_methods',10,1); function update_contact_methods( $contactmethods ) { unset($contactmethods['aim']); unset($contactmethods['jabber']); unset($contactmethods['yim']); return $contactmethods; } </...
How to remove these fields from the 'Profile' section?
wordpress
I have this wordpress site that I am making where a user has to login to see their specific gallery. My problem is that all our users are members and all the members can see all the other member pages. It's kind of hard to explain so I'll link you guys to what I have. Once this client is logged in and you hover over "M...
Big Question. So, first, to keep the galleries separate, it would be good to give them their own custom post type. We'll be checking for this later... <code> &lt;?php add_action( 'init', 'wpse32840_register_post_type' ); function wpse32840_register_post_type() { register_post_type( 'client_gallery', array( 'label' =&gt...
IF user is logged in only show certain page
wordpress
I want a script in my theme, ajax.php, which I want to load or access from other frontend pages using ajax. In ajax.php I want access to core WP functions such as get_posts(), do_shortcode() etc. I.e. I need WordPress loaded on the script. Traditionally I have setup a page in the admin and given it a custom template so...
It is really not best practice to do it this way at all. In fact you don't need to create an ajax.php file unless you're just going to include it in your functions.php file. You need to read up on AJAX in WordPress. You would just add an action on 'wp_ajax_name_of_action' and just specify the action within the javascri...
How to correctly load wordpress in a non WP script for AJAX request
wordpress
I have a custom post type, and I'm adding support for thumbnails (featured image) <code> register_post_type('cp_companies', array( 'labels' =&gt; array( 'name' =&gt; __('Companies'), 'singular_name' =&gt; __('Company') ), 'public' =&gt; true, 'has_archive' =&gt; true, 'supports' =&gt; array('thumbnail', 'title', 'edito...
From what I understand, you just want to have a thumb created at 120 x 120 when an image is uploaded using the new post type. Then use that image as the featured image on the custom post pages. Just add a new image size <code> add_image_size( 'companies_thumb', 120, 120, true); </code> Then in the post type template fo...
Set featured image size for a custom post type
wordpress
Hii i want that when i click on category link that show sub category if available instead of posts list If No Sub category available then show normal posts how to do this that if available sub categories only show just sub categories not any other posts Mean which extra code i add in my archive page that show sub categ...
use a conditional statement, for example: <code> $sub_cats = get_categories('parent='.get_query_var('cat')); if( $sub_cats ) : //show list of child categories, for instance with wp_list_categories() echo '&lt;ul&gt;; wp_list_categories('title_li=&amp;child_of='.get_query_var('cat')); echo '&lt;/ul&gt;'; //or possibly u...
show only sub categories if available?
wordpress
I'm looking for a to hide the text on the dashboard that says "You are using WordPress 3.2.1" in the Right Now widget. Not that we don't love WordPress, but for our use-case (where we'll be providing this WP install to dozens, if not hundreds of people), I'd like to get as much stuff out of there that's not needed (and...
There is a trick to get rid of this using the <code> gettext </code> filter for translations. This basically replaces it with nothing. <code> add_filter('gettext', 'remove_admin_stuff', 20, 3); function remove_admin_stuff( $translated_text, $untranslated_text, $domain ) { $custom_field_text = 'You are using &lt;span cl...
Remove "You are using Wordpress 3.2.1" from Right Now Dashboard Widget
wordpress
I'm trying to decide on how to organize a new site/theme. It has the standard sections: Home, About, Contact, Blog but also an (admin-only editable) Knowledgebase/Documentation area. My first thought was to create a custom post type to separate out the documentation area but it could more easily be done as parent/child...
There's the following: <code> http://www.wpbundle.com/demo/knowledgebase/questions/ </code> *) . To me it looks like only a clever combination of archive display. You'll have to copy/paste the link to your browser as I don't link to commercial themes from inside answers.
Knowledgebase / Docs: Custom Post Type, Pages or as a Post Category?
wordpress
I'm using the recently released WooCommerce plugin for my e-commerce site. In WooCommerce settings, the currency of my country is not listed. So I have to add it manually by coding in <code> woocommerce.php </code> and <code> admin-settings.php </code> file. The issue arises when there is an update. As soon as I update...
You have two options: Contact Woo You can ensure your changes will be permanent by contacting WooThemes (the authors of the plugin) directly and asking them to add your country's currency to the list. Use a filter Alternatively, remember that everything is filtered. Woo is using the <code> woocommerce_currency_symbol <...
Changing settings of WooCommerce
wordpress
My WordPress blog is hosted on a shared webserver on Hostgator. I've been having 500 Internal Server Errors the last couple of days. I haven't installed any new plugins since the errors started showing up. I contacted tech support a few times but never got a succesful answer. The webhost has a process limit of 25. At t...
You can't really debug server errors without having really good access to the server itself. This would entail looking at the internal working of this particular host which I'm certain they would not allow nor spend any actual time trying to fix. Move to a better host if they cannot give you more details as to what the...
Debug 500 Internal Server Error on WordPress blog
wordpress
EDIT 2 The following edit has some mis-information, see the selected answer and comments. EDIT I am a fool. The editor was in fact adding <code> &lt;p&gt; </code> tags as expected. I was using a combination of <code> get_the_content() </code> and <code> the_content() </code> . Apparently the former will strip out these...
Facilitating users to write content in an external editor, and then copy/paste it into the WordPress editor, is a fundamentally bad approach, and is fraught with issues. The WordPress editor is intended to be used to write content . You should train your users to use the post editor to write content , as opposed to usi...
How to force insertion in editor
wordpress
I'm trying to find a way to let my subscribers sign up to my site and enter details in their author pages to confirm their attendance at an event. In order to create the additional fields, I've been following this excellent tutorial by Justin Tadlock: http://justintadlock.com/archives/2009/09/10/adding-and-using-custom...
Free http://wordpress.org/extend/plugins/amr-users/ (also has details at http://wpusersplugin.com/ ) allows one to define the data in a user list and then export to csv that list.
Creating author profiles with extra fields and exporting that data?
wordpress
How-to show last 5 posts that are published after current post? Explained on image below: IMAGE FOR EXPLAINE
<code> global $wpdb, $post; // Uses current POST here $IDs = $wpdb-&gt;get_col("SELECT `ID` FROM {$wpdb-&gt;posts} WHERE `post_type`='{$post-&gt;post_type}' AND `post_status`='publish' AND `ID`&lt;{$post-&gt;ID} ORDER BY `ID` DESC LIMIT 5;"); </code> This function lists the 5 posts with IDs lower then <code> ID 176 </c...
How-to show last 5 posts
wordpress
I have a button within a post which a user can click. Once clicked, an AJAX call is made. My question is, within my PHP AJAX helper function (located in my theme's function.php) how can I retrieve, for instance, the ID of the post that the request was sent from. I can get the ID from the markup and pass it in the AJAX ...
Use <code> wp_localize_script() </code> to declare globals. Example: <code> wp_localize_script( 'my-ajax-request', 'MyAjax', array( 'ajaxurl' =&gt; admin_url( 'admin-ajax.php' ) ) ); </code> You could store your query results there and access them later.
Retrieve post info within AJAX helper function
wordpress
I'm currently developing a complex Theme (or framework, if it can be called that) for my own personal use. However, in the event that it becomes appreciated to the public - does it necessarily HAVE to be inheritable (the ability to have Child Themes derive from it)? Am I right in guessing that there is some publicly av...
However, in the event that it becomes appreciated to the public - does it necessarily HAVE to be inheritable (the ability to have Child Themes derive from it)? While you can certainly make life difficult on users who try to use your Theme as a template for a Child Theme, it is all but impossible to prevent your Theme f...
When developing a distributable Theme, does it HAVE to be "inheritable"?
wordpress
I currently have an ID of a page that I want to use its permalink as the front of a permastruct of a CPT I'm setting up. Now I can use get_permalink() but that returns the full URL: <code> http://www.example.com/imapage/subpage/subsubpage </code> but all I want to return is <code> imapage/subpage/subsubpage </code> Is ...
There's nothing built in to return the bit you want but it should be as easy as using the home_url() function and removing it's output from the full url eg: <code> function get_relative_permalink( $url ) { return str_replace( home_url(), "", $url ); } </code>
Get page permalink without wpurl
wordpress
Yeah, is there a way to add a search function that only searches through author profiles? For example, if someone is searching for authors called John Smith, is there a way to have a search form that ONLY searches in author.php?
You can use Relevanssi - Uncheck all boxes except for "Index and search your Authors" - see screenshot below.
Is it possible to search authors by profile field?
wordpress
I'm trying to specify a background image in a style in a plugin I'm making. I was just outputing tags from the php, but realized I should probably be using enqueue_style... But how do I put a line of code like this: <code> .star.half { background:url(&lt;?php echo plugins_url(); ?&gt;/my-plugin/images/star-half.png) no...
Just add a STYLE tag in <code> 'wp_head' </code> . <code> // Anonymous function, PHP 5.3+, extract function for 5.2 add_action('wp_head', function(){ echo '&lt;style type="text/css"&gt;'; // Add background style here echo '&lt;/style&gt;'; }); </code> Add this in your <code> functions.php </code> . Don't stuff too much...
How do I include background images in my stylesheets in a plugin?
wordpress
There is many a WordPress plugin out there that enhances WordPress search but I have yet to find a plugin that will add user search. Search Everything used to have the functionality but was removed when WP moved to version 2.8. I suspect this was due to the way WP changed how authors were stored. The reason why I'm aft...
You can't achieve this easily with WP's built-in search system. Even if you managed to build a complicated query that pulls data from the user table, it would be incredibly slow. Search Unleashed had this functionality, but I'm not sure about compatibility with WP 3.2. I used it in the past as inspiration to add better...
Extend WordPress search to include user search
wordpress
Is there any function/code snippet to retrieve the unix time stamp of the comment on a post? The WordPress default function <code> comment_time(); </code> returns the time of the post in 12hr format (not helpful).
Use: <code> global $comment; $timestamp = strtotime("{$comment-&gt;comment_date_gmt} GMT"); </code> Regards.
Unix timestamp for post comment
wordpress
Let me set the scene: I have a CPT that will work on a multi-site installation and some of the sites will be in a different language. For example my CPT is <code> Case Studies </code> I would use a URL structure like: <code> /case-studies/%post_id%/%postname%/ </code> but if the site language is different then <code> c...
I've gone with this the following approach: I already had a theme options page using the Settings API and because this CPT I have setup is part of the theme it only made sense to add this option to the theme options. Below is the code if anyone wants to use: <code> &lt;?php // Add settings to menu add_action( 'admin_me...
Possible to add another setting to 'Front page displays' setting for Custom Post Type
wordpress
I know that roles in WordPress are not hierarchical, but I'm wondering if there is any type of capability to "assign users to roles". All I can see if being able to add users or not. The real kicker here is, I've used Justin Tadlock's Members plugin to create a new role, called "Clients" which removes all the stuff the...
The UI select element On <code> user-edit.php </code> , you see the drop-down in the UI. The drop down <code> &lt;select&gt; </code> wrapper is hard coded. Then the admin interface does a nifty thing 1) according to the inline comment: <code> // Get the highest/primary role for this user </code> . In fact it is getting...
How to filter the role selector?
wordpress
I'm trying to use wp_nav_menu to only display a menu if one exists, otherwise, display nothing. If I delete the menu, it will output a list of the pages. My functions.php file contains: <code> if (function_exists('register_nav_menus')) { register_nav_menus ( array('main_nav' =&gt; 'Main Navigation Menu'));} </code> How...
Use <code> has_nav_menu() </code> , and test for <code> theme_location </code> , rather than <code> menu_id </code> : <code> &lt;?php if ( has_nav_menu( $theme_location ) ) { // User has assigned menu to this location; // output it wp_nav_menu( array( 'theme_location' =&gt; $theme_location, 'menu_class' =&gt; 'nav', 'c...
wp_nav_menu: show menu only if one exists, otherwise show nothing
wordpress
I have my Media settings set up so that my thumbnail size is 60x60 pixels and the "Crop thumbnail" box is checked. I can see in the /uploads folder that there are in fact perfect square 60x60 thumbnails being generated for all the images are being uploaded. However, when I use the gallery shortcode like this: [gallery ...
Is it thumb or full that is the problem? Firstly, here is the codex page about the [gallery] shortcode http://codex.wordpress.org/Gallery_Shortcode Notice that thumb is actually "thumbnail" So its [gallery size="thumbnail"] for the thumb image. If you are having issues with [gallery size="full"] then my initial thinkin...
Gallery Shortcode: using size="full" doesn't call the actual thumbnail image size
wordpress
I'd like to have the backend of Wordpress in English and use a different locale for the frontend so far I figure out perhaps I could do it by setting in the wpconfig the locale I want to use in the frontend, then add in functions.php something like this: <code> add_filter('locale', 'mytheme_backendlocale'); function my...
Install the plugin WP Native Dashboard . Then you can set one language for the front-end in your <code> wp-config.php </code> and each user can choose another one for the back-end. See stackexchange-url ("Change language of comments template") for details and a screenshot.
Localization: I want the backend: english and frontend in defined language
wordpress
Two days back a made a plugin that allows me to insert toggle box in to the post with the shortcode <code> [toggle Title="My title"]toggle test[/toggle] </code> I also posted my plugin on WordPress.org plugins http://wordpress.org/extend/plugins/toggle-box/ . The Problem I made the whole plugin on sand box that I have ...
You need to redo the way you include the Javascript and CSS, or at least just the javascript. WordPress has a way to register scripts and styles and declare their dependencies, in your case it probably isn't working because jQuery is not loaded. To include javascript do this within the <code> init </code> hook: <code> ...
Can someone please tell me what is wrong with my plugin?
wordpress
In WordPress settings you can set a page as the <code> Posts Page </code> . This can be found: <code> WP-Admin-&gt;Settings-&gt;Reading Settings-&gt;Front page displays </code> How do I retrieve the page ID that is set in this setting?
Use the <code> page_for_posts </code> option: <code> &lt;?php $page_for_posts = get_option( 'page_for_posts' ); ?&gt; </code> This will return the ID of the Page assigned to display the Blog Posts Index.
Get page ID of page that is set as the posts page
wordpress
... or does <code> wp_title() </code> already handle the various contexts in your blog? This could clarify for me how I can achieve a reusable <code> index.php </code> file without having all the conditional statements inside it to handle the different title formats in the given context (page, single, posts, search, ar...
The <code> wp_title() </code> template tag does some context-based output. From the Codex: The title text depends on the query: Single post or a Page the title of the post (or Page) Date-based archive the date (e.g., "2006", "2006 - January") Category the name of the category Author page the public name of the user If ...
When calling wp_title(), do you have to create some kind of "title.php" file?
wordpress
If I'm creating a page template, let's say for example one for a testimonials custom post type I've created, I think I have it figured out that if I do the following in page-testimonials.php: <code> &lt;?php get_template_part('loop', 'page'); ?&gt; &lt;?php get_template_part('loop', 'testimonials'); ?&gt; </code> Then ...
I'm having trouble doing the same for a page that is called from WP Settings as the "Posts Page". Let's say at the top of the "Blog" page (a WordPress page), I want some intro text to the blog that says, "Welcome to the blog. Please check out new posts below." Instead of hardcoding that into the template, how would tha...
Adding general page content to page templates
wordpress
I've set up a bunch of additional image sizes in my functions.php theme file, with the crop parameter set to true. However, the images are resized but not cropped. <code> if (function_exists('add_image_size')) { add_image_size('frontpage_a-la-une_thumb', 400, 215, true); add_image_size('single_thumb', 320, 9999, false)...
Currently, WordPress core image handling/thumbnail creation does not perform zoom-crop. If you need an intermediate image size to be created explicitly, you will need to ensure that you upload an image with equal or larger dimensions as the intermediate image size.
add_image_size() zoom-crop
wordpress
I'm trying to create a loop to read all the meta_value records from a given post_id. The idea is to gather all the meta_value's data from wp_postmeta table related to post_id number and print them as a list. But so far, I couldn't make this work. The issue is my 'custom_fields' variable. There I need to put my meta_key...
You're close, but not quite. Try it like this: <code> function jb_applicant() { $custom_fields = get_post_custom(2171); $op = ''; foreach ( $custom_fields as $key =&gt; $value ) { $op .= $key . " =&gt; " . $value . "&lt;br /&gt;"; } return $op; } add_shortcode('applicant', 'jb_applicant'); </code>
What is wrong here? Issue with post_id and meta_value
wordpress
I've started to develop my own theme in the past couple weeks (and extracting WP functionality here and there in the past year), and I'm finding the structure of the WP templates awful redundant. Although that yes, technically, the blog starts somewhere higher above to load the WP functionality, the main WP_Query objec...
Theme template files are organized in this way because of the WordPress Template Hierarchy . Since all primary template files eventually fallback to <code> index.php </code> , it is certainly possible to use only the <code> index.php </code> primary template file. There are advantages and disadvantages to using either ...
Why are theme templates organized as multiple point of entry PHP files instead of reusing your theme's index.php?
wordpress
i have made a new WordPress Theme and ive done .. but i have one problem. I can't get the pagination work. I use the "wp-paginate" plugin and i have put the folloing code on my index.php <code> &lt;?php if(function_exists('wp_paginate')) { wp_paginate(); } ?&gt; </code> But that doesn't work for my site. There is still...
If this is a new WordPress install, it is likely that you don't actually have enough posts to require pagination, and thus the pagination links aren't appearing. Quick test: ensure you have at least two posts, then go to <code> Dashboard -&gt; Settings -&gt; Reading </code> , and change the "Posts Per Page" setting to ...
The Pagination doesn't work
wordpress
How can i use my own (custom) session value in Wordpress? For example: <code> $_SESSION['myname']="4lvin" </code> I've already inserted <code> session_start() </code> at all page i need as following. <code> &lt;?php session_start(); $_SESSION['myname'] = "4lvin"; ?&gt; </code> But not working Global-wise. Just working ...
EDIT: "THE PLUGIN BELOW ISN'T AVAILABLE ANYMORE, SO PLEASE USE THAT PLUGIN INSTEAD: WordPress Session Plugin " There is a good WordPress Plugin adapted from CodeIgniter Session class: WP Sessions Plugin . When you activate the plugin, you can start to use <code> $session </code> object from anywhere in your theme ( <co...
How to use my own custom session value in Wordpress?
wordpress
I am altering the WordPress query, using the <code> posts_where </code> hook, when a (custom) query variable is set as follows: <code> add_filter('posts_where', 'my_posts_where' ); function my_posts_where( $where ){ global $wp_query; if( isset( $wp_query-&gt;query_vars['customvar'] )) { $custom_Var = $wp_query-&gt;quer...
Your last <code> prepare() </code> snippet should work just fine, check that you have <code> $wpdb </code> declared as global in your function. Also blank page seems extreme, enable <code> WP_DEBUG </code> if not yet and see if there are any specific errors that cause it.
Sanitatizing when using the posts_where hook
wordpress
Is there a way I can hide a certain categories content from just the homepage Posts section of my Wordpress Site? So, those posts are still posted and live; just not visible nor accessible from the homepage posts area. I'm calling the category twice on the homepage; once in the header within a plugin I'm using, and the...
Okay, it sounds like you'll want to modify the primary Loop using <code> query_posts() </code> , but only on the Site Front Page . I don't think TwentyTen includes a <code> front-page.php </code> template file, so we'll modify <code> index.php </code> directly. Add the following code to <code> index.php </code> , anywh...
Hiding a Categories content on just the Homepage 'Posts'?
wordpress
I have been tryin to make this plugin work but I failed badly. I have the code like below: The <code> portfolio-terms </code> is filtering buttons: <code> &lt;div id="portfolio-terms"&gt; &lt;ul&gt; &lt;li&gt;&lt;a href="#" class="all current"&gt;&lt;?php _e('All', 'framework'); ?&gt;&lt;/a&gt;&lt;span&gt;/&lt;/span&gt...
Not sure it is entirely your problem, but you have a syntax error here: <code> &lt;script src="&lt;?php bloginfo('template_directory'); ?&gt;js/jquery.easing.js"&gt;&lt;/script&gt; </code> ...you need to add the trailing slash to <code> bloginfo('template_directory') </code> , like so: <code> &lt;script src="&lt;?php b...
How I got jQuery Quicksand working with WordPress?
wordpress
I am using Custom post types in one of my themes I have one custom post type called "accommodation" with meta boxes to add details such as type of rooms (single, twin, double...); each room has a price according to different season (high season, low season, peak season - each could be ). However the room types could di...
I will answer myself after some research :) while there might be appropriate ways of coding this with some custom function, for me there's no need to reinvent the wheel when there's a neat plugin that does the job it's called "advanced custom fields" http://wordpress.org/extend/plugins/advanced-custom-fields/ it has a ...
Dynamically add / duplicate custom meta in custom post types
wordpress
In my blog, I sometimes post "how to" style tutorial posts. I would like to show a difficulty gauge next to the post title like 'assumed knowledge', 'time to complete', 'frustration level', 'cost' etc. They should show up in excerpts, the main page and in posts too. Unfortunately googling with keywords "wordpress tutor...
You don't need a plugin to do this. Why not just use the wordpress custom fields feature to add your custom meta data to the posts. http://codex.wordpress.org/Custom_Fields You can create a custom field for each that the person adding the tutorial fills in. Then take that value that is entered and add it as a class to ...
Need a wordpress plugin to show tutorial difficulty
wordpress
I am currently writing a plugin that allows all authors to be listed on a page. I've created an options page and wanted to create a function that allows administrators to exclude certain authors from the page. The options page is a list of checkboxes with the Author ID as a value. When the form is submitted, checkboxes...
Where are you calling <code> wp_applugin_options_process() </code> ? If you call it, and <code> $_POST["excludeid"] </code> isn't set, then you're effectively calling: <code> update_option("wp_applugin_excludeids", null ); </code> So if you're calling this function on every page load, or even just when your admin page ...
update_option creates an option, which empties on a blog reload
wordpress
I'm working on a project right now and I'm facing an issue that is about to freak me out. Basically I had to display information of some courses, in order to do so, I create a custom field called "CourseInfo", that array includes, date, place, and a link to sign in. So the user create that custom field as long as he ne...
Multiline is not an array (rant) You need to use standard dates for this to work DD/MM/YYYY (first row) Use the PHP function usort() to sort the fields Use strtotime() to convert that date to a timestamp and date_i18n() to output it If you need an actual example, change the date formats to what I've shown you above, up...
sort a custom field base on the date or anything
wordpress
I know it isn't good practice but I'm considering using same name slugs for some pages and categories on a site that I'm working on. It's a small site and it doesn't seem to affect anything in particular. I added one slug and page with the same name and they worked fine, but when creating a second WP forced me to renam...
I used to do the same thing - create a page with the same name as a category to use as a faux index page. I think I used this No Category Base plugin to remove the /category/ bit from the URL. (I think it was this plugin.) [...] this plugin will completely remove the mandatory 'Category Base' from your category permali...
Using same slug name for a page and category
wordpress
I am developing a functionality in WordPress so that once user updated any information admin can approve/reject the information only after which it should get published in the front users,in specific terms functionality is much similar to e,g Comment approval. i am new to PHP as well Word press, though i have developed...
You're looking for the WP_List_Table class. There is an example of how to use it in the .org plugin repository that you can use as a base for creating your own implementation: http://wordpress.org/extend/plugins/custom-list-table-example/
maintaing consistent layout wordpress dashboard
wordpress
I've got a custom post type called Products, which underneath i've got a related products section using a plugin called http://wordpress.org/extend/plugins/related-posts-thumbnails/ . I need to be able to create some more post types for example called Accessories and Supplies. I need to be able to relate some accessori...
2 possible solutions spring to mind, both fairly straightforward: Use a custom taxonomy to create groups then add the accessories and main product to the same group Add an interface that updates the post_parent field to mark items as accessories for a specific product With either of these approaches you get a fairly ea...
How can i manually relate pages?
wordpress
I have been advised how to add additional contact info fields to the User admin area here (stackexchange-url ("Click here")). However, I am not entirely sure how I can display the the field contents in a link within my template files. Here is the code in my functions.php: <code> add_filter( 'user_contactmethods', 'more...
This might help you out if you haven't found an answer yet. <code> /* BEGIN Custom User Contact Info */ function extra_contact_info($contactmethods) { unset($contactmethods['aim']); unset($contactmethods['yim']); unset($contactmethods['jabber']); $contactmethods['facebook'] = 'Facebook'; $contactmethods['twitter'] = 'T...
Displaying additional User Contact Information
wordpress
I am a beginner in Wordpress programming. I am basically looking out for video tutorials that teach Wordpress programming and specifically creation of plugins and such advanced things. Are there any good video tutorials which teach such sort of stuff? or any courses from training companies like pluralsight. I know plur...
Couple of sites I can refer: Start with wordpress codex http://codex.wordpress.org/ http://net.tutsplus.com you may find good starting point there. Search Youtube you can find some good ones there too. And if you feel like paying for it try some tutorial series from http://lynda.com Search google. I think its the best ...
Wordpress programming video tutorials
wordpress
I have a drawing canvas on some of my Wordpress' post pages, where users can draw on. Upon drawing, my JS code currently sends the user's drawing to a php file. This is where I store the array in JSON format in .txt files. Whenever the page is loaded by someone else, JS loads these JSON files on start, so you see other...
Yes! Yes you can! You can use this code to retrieve a stored option: <code> $value = get_post_meta($post-&gt;ID,'customfieldname',true); // where true means only return 1 custom field by this name </code> You can use this code to save a stored option: <code> update_post_meta($post-&gt;ID,'customfieldname',$valuetobesto...
Store JSON in a custom field
wordpress
Is it possible to automatically create a password for a new user? Ideally, I'm looking for a plugin that, if the password is not given on user creation, would generate one and optionally email it to the user if the checkbox for this is selected. If not, then maybe just show the password after the creation of the user. ...
I was looking for the same thing and I found this plugin: Simple User Password Generator (by Jake Goldman ) - Allows administrators to generate a secure password when adding new users.
Create password automatically for new users?
wordpress
I have a plugin adding a custom meta box to the comments editing page: <code> function on_admin_init() { add_meta_box( 'commentrating', __( 'Voto recensione', FB_DT_TEXTDOMAIN ), array( &amp;$this, 'meta_box_voto' ), 'comment', 'normal', 'high' ); } function meta_box_voto($data) { ... ?&gt; &lt;script&gt; jQuery(docume...
Put the JS in the <code> admin_footer </code> . If the Widgets are moved, your JS tag code can be duplicated hence called twice.
Custom Meta Box calling JS function twice
wordpress
I have custom post type <code> works </code> with custom taxonomy <code> work_category </code> I want to build such pagination while viewing <code> single.php </code> previous 2/25 next [ <code> link to previous post in custom tax </code> ] [ <code> current post number </code> ]/[ <code> all post number from custom tax...
I've solved it For previous/next use Ambrosite Next/Previous Post Link Plus To get current/all use following code inside the loop <code> $query = new WP_Query( array( 'post_type' =&gt; 'works', 'post_status' =&gt; 'publish', 'posts_per_page' =&gt; '-1', 'tax_query' =&gt; array( array( 'taxonomy' =&gt; 'work_category', ...
Custom post type pagination like "previous current/all next"
wordpress
I have some code in my category.php file to show either pages or categories. Depending if the category has sub categories or not. Is it possible to also show the category description as well? This is the code i'm using to show either the pages or a list of categories in my category.php file. <code> &lt;?php if (!catego...
i think that wp_list_categories show categories already formated with <code> &lt;li&gt; </code> tags and you should try using get_categories which leaves the display to you. eg show list of categories and the description <code> $all_categories=get_categories(); echo "&lt;ul&gt;"; foreach($all_categories as $categories_...
wp_list_categories to show list of categories and the description
wordpress
Is it possible to continually update an xml file on the server with data from a wordpress page? If so, how could I do it? I use this plugin http://plugins.elliotcondon.com/advanced-custom-fields/ to create the custom data. Would I be able to save this to an xml file? It's important that this xml file is updated every t...
The <code> save_post </code> hook gets called each time a post is created or updated. Just hook into that. There you can do something like <code> fputcsv('/tmp/' . $post_id, $post) </code> or output to XML/JSON. == EDIT == <code> add_action( 'save_post', 'wp239s5_post_to_xml', 10, 2 ); function wp239s5_post_to_xml( $po...
Save page data to an xml file
wordpress
I am working on a site and it is possible that the site will have a number of pages which feature links to the client's social networking sites (Twitter, Facebook, LinkedIn...). Now I know that the URLs to their profile shouldn't change too often, but they would like the option to update the URLs if they ever needed to...
The best way is on the user profile page using the contact methods extension: <code> add_filter( 'user_contactmethods', 'more_contactmethods' ); function more_contactmethods( $contactmethods ) { $contactmethods['twitter'] = 'Twitter username'; $contactmethods['facebook'] = 'Facebook URL'; return $contactmethods; } </co...
Best way to allow manageable social media URLS?
wordpress
I have a small problem with custom fields. This is what I am trying to do: Whenever a new post is added, I check what category is selected, grab the sub categories and create custom fields with a "0" value based on the sub categories. On each post I grab the sub categories, put them in a form and create checkboxes for ...
<code> 'name' </code> is what gets saved as key in the post meta data, so do a str_replace for the category name, before saving: <code> // Wrong: name="My Category" echo '&lt;input type="checkbox"' . $i . 'name='.'"'.$category-&gt;name.'"'.'value="" /&gt;'.$category-&gt;name; // Right: name="my_category" $name = str_re...
Custom fields won't update
wordpress
I want to use wordpress as a CMS and not as a blog. I am using the default twentyeleven theme and i would like to remove 'archive' (the blog ToC) and 'Meta' (login) and replace it with a sidebar seen on a traditional site. The part i am having trouble is how do i do it in a way were i can add pages to the sidebar from ...
An alternative method to what @Tanmoy gave above is to make an additional navigation menu (Appearance - Menus) and call it something like Sidebar-Pages. Then you can add the headers with a "link" like #. Add the sub-pages you want and save when you're done. Then go to widgets (Appearance - Widgets) and there you will s...
How do i replace the sidebar to use pages instead of blogs?
wordpress
I am trying to include user input includes using "get_template_part()" The includes are added in the theme options eg a user inputs. <code> get_template_part('content/block', 'branding'); get_template_part('content/block', 'footer'); </code> I need to execute this code as php and have a custom hook for add_before_conte...
I see what you're trying to do ... and I don't like it at all. You're including way too much in terms of options for the theme, particularly if you're allowing freeform PHP code on an options screen. Why this is a bad idea The mantra of the entire WordPress project is "decisions, not options." Fact is, the more options...
Is using eval() ok in this scenario
wordpress
Can anyone tell me how I can show a post count in this code snippet? <code> &lt;?php $tags = get_tags(); if ($tags) { foreach ($tags as $tag) { echo '&lt;li&gt;&lt;a href="' . get_tag_link( $tag-&gt;term_id ) . '" title="' . sprintf( __( "View all posts in %s" ), $tag-&gt;name ) . '" ' . '&gt;' . $tag-&gt;name.'&lt;/a&...
where exactly? example below is for the count getting shown in brackets after the tag name, outside the link: <code> &lt;?php $tags = get_tags(); if ($tags) { foreach ($tags as $tag) { echo '&lt;li&gt;&lt;a href="' . get_tag_link( $tag-&gt;term_id ) . '" title="' . sprintf( __( "View all posts in %s" ), $tag-&gt;name )...
How to include post count in this "get_tags" snippet
wordpress
How do I rewrite a category url that has a number at the end, to a url with no number using wordpress url rewriter? and... Why is there a number appended to all category url's? http://www.latestnewsexplorer.com/news/gaming/pc-gaming-2/
You cannot use the same term for a category, page, tag as they need to be unique. When you do, you'll get a number next to the slug To fix them you'll need to fix the tag or page slug otherwise edit the category slug last http://wordpresssites.net/links/how-to-edit-change-fix-duplicate-category-slugs-in-wordpress/
Rewrite a category
wordpress
In a WordPress blogsite, I'd like to add additional functionality but write it something other than PHP if possible, Python for example. For example, I'd like to create a self-scheduling page for a business so that clients can choose appointment times, and then write an admin side for the business to view and manage th...
You've got a couple of options here, but they're all pretty hacky ... iFrame The easiest way would be to script your external application in whatever language you want and embed it in a typical WordPress page using an iFrame. Applet Java, Flash, Air, and Silverlight are all objects embedded directly into HTML pages. If...
How can I integrate pages written in something other than PHP?
wordpress
I have 8 custom post types for a lottery website I am currently working, one custom post type for each game that is in the lottery, but I am now wondering if this is the best way to go about this, would I be better off do you think in creating 1 custom post type called draw results, and having all the games results in ...
One possible solution: Custom Post Type <code> draw-results </code> , where each post is a contest/game result Custom Taxonomy <code> contest </code> (or <code> game </code> ), where each term is a different contest/game When you create a <code> draw-results </code> post, taxonomize it using the appropriate <code> cont...
Advice on using Custom Post Types
wordpress
I have this code so far, which adds the classes first, second, and third to every first, second and third post in the loop. It also adds a class to the first 3 posts in the loop. But how can I make it so that it adds another class to the final 3 posts? <code> if (have_posts()) : while (have_posts()) : the_post(); $clas...
WP_Query seems to set two variables, $posts and $post_count when running(according to the source over at http://core.trac.wordpress.org/browser/tags/3.2.1/wp-includes/query.php ). You can access these two and work something out to figure out if you're in the last three posts. var_dump those two to see if there's a coun...
Add class to last 3 posts in loop
wordpress
The weight of opinion seems to favour using custom post types instead of custom post formats. I have several custom post types that I want to style in 4 different formats in a way that is not public ie not a category, tag or custom taxonomy. Custom post formats would seem to provide an ideal solution for this - they're...
You have several options here so I will clarify what you can do. Create a custom post type template page using something like <code> single-customposttype.php </code> and take advantage of the template hierarchy, http://codex.wordpress.org/Template_Hierarchy Use a conditional query for your styling in the loop ( or wha...
Custom Post Formats for Custom Post Types
wordpress
I am busy writing a plugin with a free version and a paid, Pro version. For our initial release of both versions, I want to keep things as simple as possible, so I would rather defer using a strategy of a very extensible free version, with hooks implemented in a Pro version; I will give this direction some attention fo...
You alluded to this in your comments, one way is to provide an API key for your plugin, that way your clients are actually paying for support and updates and not code, it's really one of the only decent ways to go about this. For example if their API key is not valid or expires they do not get access to your private fo...
How can I limit functionality in one version of a plugin?
wordpress
How can i prevent or blacklist a list of usernames that i don't want users to register with? And can I add a message if they try to register with one of those names that says 'this username has been reserved' Is this possible?
Yes there are plugins that do this, for example, http://wordpress.org/extend/plugins/restrict-usernames/
How to prevent certain usernames from being registered?
wordpress
I have edited my question, I'm now getting the error about checking my MySQL settings. I changed the $sql_dvalues variable to an array with the values instead of comma spaced values and now it is saying the following: WordPress database error: [You have an error in your SQL syntax; check the manual that corresponds to ...
You are aware that <code> $wpdb-&gt;insert </code> does exactly this? <code> $wpdb-&gt;insert( 'table', // Table name array( 'column' =&gt; 'foo', 'field' =&gt; 1337, ), // Columns array( '%s', '%d', ) // Explicit formatting ); </code> Right?
Wordpress database error: [Query was empty] - using $wpdb-> prepare()
wordpress
I'm trying to add some string replacements to the_title() - <code> function format_title($content) { $content = str_replace('&amp;','&amp;&lt;br&gt;', $content); $content = str_replace('!','!&lt;br&gt;', $content); return $content; } add_filter('the_title','format_title',11); </code> When I try and replace ampersands I...
<code> &amp;#38; </code> is essentially synonym of <code> &amp;amp; </code> . In <code> the_title </code> filter <code> wptexturize() </code> runs with priority <code> 1 </code> (important!) and makes this replacement. So by the time it gets to your <code> format_title() </code> at priority <code> 11 </code> - instead ...
Getting rid of the #038; when string replacing content
wordpress
iam working on my first wp theme and iam new to php and wordpress. i need to create a single category widget that displays at least five posts from specific category. inside this post loop i need a conditional function to make the first post different from the rest. to be clear iam using a plugin that gives me all the ...
To make the first post different you could add a post counter and change the output on the first loop. <code> $counter = 0 while ( $cat_posts-&gt;have_posts() ) { $cat_posts-&gt;the_post(); $counter++; if ( $counter == 0 ) { // Out put the different loop } //Normal loop output </code>
single category widget with conditional terms
wordpress
I would like to create one loop that lists the custom posts for each taxonomy term: Term A: Item Item Item Term B: Item Item Item I would like this to be totally dynamic so if I add a new term it automatically appears. I've seen examples where the taxonomy terms are explicity in the code but I am looking for something ...
Try: <code> $tt = get_terms('my_custom_taxonomy', array( // You can stick in orderby, order, exclude, child_of, etc. params here. )); foreach ($tt as $term) : // Output term name print $term-&gt;name. ": "; $q = new WP_Query(array( 'post_type' =&gt; 'custom_post_type_i_use', 'post_status' =&gt; 'publish', 'posts_per_pa...
Custom post type multiple loop by taxonomy term
wordpress
I'm looking for a MySQL Query that will look for all the posts with custom field "meta_key_I_want_to_find", then if the custom field is detected, add a category to that post. The category has already been created, so I just need to find all of the posts with that Meta_key and then add the category to them. I was thinki...
I can't tell here whether or not you have the WordPress API available to you. (Is this code that is being run from within an instance of WordPress, or is it being run by an external script on the WordPress database, without bootstrapping WordPress itself?) If you have the WordPress API, it is easy to get a list of all ...
MySQL Query that looks for post with Custom Field, then changes Category
wordpress
i want to add a datepicker on a custom page but i doesn not work. WP version is 3.2.1. Those are the init string i used on wp code: <code> wp_enqueue_script('jquery'); wp_enqueue_script('jquery-ui-core'); wp_enqueue_script('jquery-ui-datepicker', get_bloginfo('template_url') . '/js/jquery-ui-datepicker.min.js', array('...
I often type things wrong. So, I would start debugging you copying and pasting the links to the JS scripts in your browser and make sure they load. Then in Chrome go to the Wrench Menu -> Tools -> JavaScript Console. Here you will be able to type/execute your JavaScript directly. I would start off my typing <code> jQue...
jQuery UI Datepicker not working
wordpress
I'm trying to accomplish the following: I wan't to display all posts from a certain category on a page that has the same layout as the homepage of the actual blog. I found the following online to display posts for the category <code> &lt;?php $recent = new WP_Query("cat=797&amp;showposts=30"); while($recent-&gt;have_po...
This should help you, the second diagram... this one . Just copy the <code> index.php </code> code to the properly named <code> category-*.php </code> file and see if it works.
Duplicate homepage to show posts from 1 category
wordpress
I have started to use posts-to-posts plugin by scribu, and now I need to change vaues for connection fields. Particularly, I've created 'person' and 'piece', connection 'role' in between and defined possible values for role as 'composer', 'conductor' -- but now I think that I need rather 'author', not 'composer'. Pleas...
So, in my case this way hepled: 1) I've replaced <code> 'composer' </code> with <code> 'author' </code> in <code> functions.php </code> (in that part where connections are being registered) and 2) "edited" data in <code> ${wpdb}_p2pmeta </code> using phpmyadmin ( <code> UPDATE &lt;yourprefix&gt;_p2pmeta SET meta_value ...
Posts 2 Posts plugin: best way to change connection field value?
wordpress
how can i check if the current post belongs to the current author? this is my basic code; ` <code> if($curpost) { wpuf_edit_show_form($curpost); } else { $error = "there is no post."; } </code> ` also how can i add the same control to these action; ` <code> function wpuf_user_dashboard_post_list() { global $wpdb, $user...
A compacted version that does not load the globals yet calls upon them directly. <code> if( is_user_logged_in() and // Force user validation... STUFF !empty($GLOBALS['post']) and // Check if a $post exists in globals !empty($GLOBALS['current_user']) and // Check if current_user exists in globals ($GLOBALS['current_user...
current post with current author
wordpress
I have a page that currently loads posts of custom post type using regular WP_Query. The custom post type are for news articles. Newer news articles (posts) are constantly written, as such there is a need for loading newer posts without having the user to refresh the page. The effect I am desiring is similar to what on...
I was in the same situation as you recently. The way I did it is probably wrong, and prone to bugs but if you can live with that then this might help. Basically you create an empty array at the top of your loop file, say for example loop-index.php. $ignores = array(); Then inside your post loop you want to add these po...
Automatically pull newer posts and append to current page.
wordpress
I'm having problems with the WP uploader (hosting issue); WP is pooping out after uploading files that are relatively large (> 32MB). My idea was to upload the video file via SFTP to the server and then try to get WP to insert it into the Media Library. How do I do this? I know that it isn't as simple as just putting i...
Add From Server will do this for you
How do I insert an already uploaded video file into my Media Library?
wordpress
After running the WordPress stats plugin for many years, I've decided to upgrade to JetPack. The installation went smoothly, I connected and authorized my blog with Wordpress.com, and I'm seeing stats. Is it safe to deactivate and delete my old WordPress stats plugin now? Or do I need to keep it in order to preserve my...
Yes, you can safely deactivate the old wordpress.com stats Plugin. Once you verify that your historical data have been retained, you can safely delete the Plugin.
After installing JetPack, can I delete the WordPress stats plugin?
wordpress
I'm using WP Query &amp; want to only return 1 post in a category. Either the most recent sticky else the latest post. Is this possible? Thanks, George <code> &lt;?php $category1 = new WP_Query(); $category1-&gt;query( array('showposts' =&gt; 1, 'category_name' =&gt; 'hapless ' )); while ($category1-&gt;have_posts()) :...
Why don't you use a fat-free $wpdb-> get_var() for the task? <code> global $wpdb; $ID = $wpdb-&gt;get_var("SELECT `ID` FROM {$wpdb-&gt;posts} WHERE `post_type`='post' AND `post_status`='publish' ORDER BY `post_date_gmt` DESC LIMIT 1;"); $post = $ID ? get_post($ID) : null; // Now get the actual post </code> This is way ...
WP Query get only 1 post (sticky, not sticky etc)
wordpress
I have alot of custom meta boxes, and the user has to scroll to the top everytime he wants to save the meta info. Is there a way to put submit buttons at every meta box that does that same as the update button?
Don't know if i agree with EarnestoDev answer which is more of an opinion then an answer based on facts and not true in all cases, since you can use jQuery to trigger the submit event when a different element is clicked, so just add this js code once <code> &lt;script&gt; jQuery('.metabox_submit').click(function(e) { e...
Adding submit or update button to custom metabox?
wordpress
I'm trying to use widgetlogic to conditionally display menus on certain pages. Each menu uses a tag like <code> is_page(array("Page Name", "Page Name 2" ...)) </code> , and works perfectly until I try to change permalinks (whereupon all the menus disappear from their respective pages). Am I doing something wrong? Is th...
Changing permalinks should have absolutely no affect whatsoever on the parameters passed to <code> is_page() </code> . Are you perhaps changing the Page Titles instead? Regardless, try passing the Page ID instead of the Page Title to your <code> is_page() </code> array.
widgetlogic and permalinks
wordpress
Is there any plugin to translate navigation menu &amp; sidebar widget titles ?
Anyway, I found my answer. I used <code> qTranslate </code> to translate menu wordings as well as widget titles. Free &amp; useful.
Translate Navigation Menu & Sidebar Widget Titles
wordpress
In a category.php template, I built a function that lists "featured" posts before the main loop. The featured posts are selected using a custom field and get_posts(): <code> function list_featured_articles(){ $featured_posts = get_posts('meta_key=featured_article&amp;meta_value=on&amp;numberposts=10&amp;order=DESC&amp;...
This would be an appropriate use of <code> query_posts() </code> , with a post custom meta query . Since you're querying by <code> meta_key=featured_article&amp;meta_value=on </code> , you would then exclude on the same parameters. <code> &lt;?php // Setup the custom meta-query args $exclude_featured_args = array( 'met...
how to exclude "featured" posts from the main loop?
wordpress
hi wanted to know do i group my custom post types to appear together in a group in the wordpress back end menu bar like this below in the picture what code do i have to use in my functions.php so that i can give my custom post types a nice look and feel http://i39.tinypic.com/281u1og.jpg currently i am using a custom p...
The filter Inside /wp-admin/menu.php, you'll find this filter at the end of the "add css classes"-loop: <code> apply_filters( 'add_menu_classes', $menu ) </code> The function The following code attaches the right classes to the first and previous elements. It also adds the separator in between. If you need to add anoth...
how to group custom post types
wordpress
Let's say you need to generate javascript or CSS code that depends on the current context. For example you have a form on the homepage that fires an ajax request on submit, and a different form on the single page. Or in the case of CSS, you want to create a theme that allows its users to build their own layout, change ...
One additional option, depending on the kind of parameters you need to pass in. Let's call it (2a). You can also create PHP scripts which output dynamically-generated <code> text/css </code> or <code> text/javascript </code> rather than <code> text/html </code> , and provide them the data that they need using GET param...
Solutions for generating dynamic javascript / CSS
wordpress
I want to check for an appropriate template in the theme folder before falling back to the file in my plugin directory. Here’s my code: add_filter('template_include', 'sermon_template_include'); function sermon_template_include($template) { if(get_query_var('post_type') == 'wpfc_sermon') { if ( is_archive() || is_searc...
So, I'm not sure exactly what is causing the problem, but you might try the following: Plugin file path : replace <code> dirname(__FILE__) </code> with <code> plugin_dir_path( __FILE__ ) </code> Theme file path : replace <code> TEMPLATEDIR </code> with <code> get_stylesheet_directory() </code> It's possible that the pr...
Use template_include with custom post types
wordpress
I am writing a code snippet to display attachments to a post but for each user, he should only be able to see his own attachments and not those of other users <code> $current_user=wp_get_current_user(); //display all post attachments. see http://codex.wordpress.org/Template_Tags/get_posts#Show_attachments_for_the_curre...
Maybe you meant: <code> if($current_user-&gt;ID == $attachment-&gt;post_author) echo " Matched!! "; </code> PS : By unexpected results I think you are referring to the 'DISEASES OF THE PENIS' part... right?
my basic php code producing unexpected results
wordpress
I’m pretty sure this can be done with a filter or some kind of find and replace, but I’m not sure how. I have a page called “Home” like so: When the link is displayed in my template it says “Home”. I’d like it to say “About Us”. I want the user to know which page the homepage is in the Page Overview panel, but I’d like...
What I did was really simple...In the admin panel I left the name as home, then I used conditional statements to change the name. For the navigation I used: <code> &lt;ul&gt; &lt;li &lt;?php if ( is_home() ) { ?&gt;class="current_page_item"&lt;?php } ?&gt;&gt;&lt;a href="&lt;?php bloginfo('url') ?&gt;"&gt;About Us&lt;/...
Can I change the "Home" text in the menu?
wordpress
I'm busy writing my first plugin, using PHP 5.3.5. I come from a C# environment, and I must say I'm more than happy with the level of support for good, solid OOP techniques in PHP. However, I'm a little uncertain how to structure a plugin using classes. I have a plugin class that takes care of hook registration in its ...
I have one or two non-class scripts, mostly for forms, that I don't quite know how to neatly fit into classes. Split your project into multiple classes. Keep your worker classes as instantiable objects (typical OOP patterns) and put your non-class scripts into a class of their own as static scripts. I often use static ...
Applying OO patterns and principles to plugin development
wordpress
I have created a custom post type 'shows'. And I am using the capabilities argument to create my own custom capabilities. My aim is to have a user ( <code> show_manager </code> , say) who can only edit/create shows and nothing else. I have managed this, but the <code> show_manager </code> is unable to add their (show) ...
I have found the cause of this problem. The reason is due to the capabilities argument in the <code> category </code> taxonomy. i.e. <code> array( 'manage_terms' =&gt; 'manage_categories', 'edit_terms' =&gt; 'manage_categories', 'delete_terms' =&gt; 'manage_categories', 'assign_terms' =&gt; 'edit_posts', ); </code> So ...
How to add post of custom type to a category with custom type capabilities
wordpress
I am having private page.I want to show this page only when "subscriber" logged in."Editor" should not access this page.How can i set the privilege.
Without a plugin something like this should work <code> //functions.php function get_user_role() { global $current_user; $user_roles = $current_user-&gt;roles; $user_role = array_shift($user_roles); return $user_role; } //page template $role = get_user_role(); if($role == "subscriber"){ //cool you can see this } else {...
How to set privilege to wordpress subscriber for private page
wordpress
I just had to fix an AJAX failure in the admin area (the search/attach dialog box in the Media Library wasn't working) and tracked down a plugin that was the culprit. On activation, this plugin was generating 'unexpected output' (it had a space after the final php tag). Removing this solved the problem. Why was it caus...
The HTTP Protocol that runs both page loading, file downloading and AJAX functionality requires a headers (multiple lines) consisting of Name: Value and TWO ENTERS (separator) and then the actual data. Headers are very important as they control what the browser should do with the received data and state what the data i...
Why do plugins that cause 'unexpected output' create AJAX problems?
wordpress
This is probably a noob question BUT hear me out - isn't the point of using Nonce to protect from things like scrappers (phpcurl scrappers etc.)? But my Nonce prints out in the head of the document like so: <code> /* &lt;![CDATA[ */ var nc_ajax_getpost = { ...stuff... getpostNonce: "8a3318a44c" }; /* ]]&gt; */ </code> ...
Nonces are unique to each logged-in user. You can't scrape a logged-in user's nonces unless you have their cookies. But if you have a user's cookies, you've already stolen their identity and can do whatever you want. Nonces are meant to protect against users being tricked into doing something they didn't mean to do, by...
Are Nonces Useless?
wordpress
I have a wordpress blog i.e. bruno.wordpress.com I would like to use github:gist . I paste my code in gist and get a link like: https://gist.github.com/1323748 Is there a way to show this code in my blog? (rather than just a link to the code.)
No. As scribu mentions, you can do this on a self-hosted WordPress site with a plugin. In WordPress.com, though, you don't have access to these plugins and must depend on the oEmbed support WordPress.com extends you by default. Your best bet is to contact their support team directly and ask if/when they'll have support...
Is it possible to use github:gist with Wordpress?
wordpress
I am adding i18n to the widget on List Category Posts . I've correctly created the pot file, and po and mo files for Spanish and English. All of the Strings are being displayed with <code> _e() </code> on the form file. The directory structure is as follows: <code> / include/ ListCategoryPostsWidget.php lcp_widget_form...
Based on your comment: The html generated by the widget? That one just shows the Strings in the _e function for eg: _e("Category") displays "Category" I suspect that you've not configured your translation strings properly. You need to include the textdomain in every translation string function call, or else the strings...
Widget translation on my plugin
wordpress
What does the $GLOBALS['s'] variable contain? It looks like an empty array, but what would it normally hold? I've encountered it in a tutorial: The WordPress Theme: Single Post, Post Attachment, &amp; 404 Templates , it mentions a long string that gets passed to a <code> printf </code> function call. The string looks s...
It's not a global variable; in fact it's not a variable at all. It's just placeholder within the <code> sprintf() </code> function. Take a look at the <code> sprintf </code> PHP function documentation . In the example you cite, the author is using the 'argument swapping' placeholder syntax: %n$t where %n is the placeho...
What does the Global Variable $s represent?
wordpress
This is my category page code &lt;--Featured Post start--> <code> &lt;?php $count = 1; if (have_posts()) : while (have_posts()) : the_post(); if($count == 1) : ?&gt; &lt;a href="&lt;?php the_permalink() ?&gt;" rel="bookmark" title=""&gt;&lt;?php the_title(); ?&gt;&lt;/a&gt; &lt;--Featured Post start--&gt; &lt;?php else...
<code> if($count == 1 &amp;&amp; !is_paged() ) : </code> http://codex.wordpress.org/Function_Reference/is_paged
Hide featured post from second page
wordpress