question
stringlengths
0
34.8k
answer
stringlengths
0
28.3k
title
stringlengths
7
150
forum_tag
stringclasses
12 values
I want to add the categories ID to admin page. I call it for my <code> functions.php </code> : <code> require_once('includes/categories_custom_id.php'); </code> The part of code: <code> function categoriesColumnsHeader($columns) { $columns['catID'] = __('ID'); return $columns; } add_filter( 'manage_categories_columns',...
The hooks for taxonomies are: <code> "manage_edit-${taxonomy}_columns" </code> for the header <code> "manage_edit-${taxonomy}_sortable_columns" </code> to make columns sortable <code> "manage_${taxonomy}_custom_column" </code> for the cell content To catch all taxonomies write: <code> foreach ( get_taxonomies() as $tax...
How to add the category ID to admin page
wordpress
As per title and following screenshot
Your user are not inside the user-list of each blog in network active; maybe you are Super-Admin. Go to 'Sites (All Sites)' --> Edit a blog in Sites --> Tab 'Users' --> Add your user to the list of users and see the dropdown.
Cannot see dropdown shortcut to site dashboard in WordPress network why?
wordpress
I have the following shortcode in my content <code> [src]&lt;a href="#"&gt;Some Link&lt;/a&gt;, &lt;a href="#"&gt;Some Other Link&lt;/a&gt;[/src] </code> My post structure looks like this: <code> &lt;?php echo $content; ?&gt; &lt;?php wp_link_pages();?&gt; </code> If that shortcode is being used in the content, I'd lik...
Do something like this. <code> // your shortcode callback function your_sc_callback($atts,$content) { $content = wp_list_pages(array('echo'=&gt;false)).$content; define('YOUR_SC_RAN',true); return $content; } </code> Now, in your theme template after the content prints <code> if (!defined('YOUR_SC_RAN')) { wp_list_page...
How can I display wp_link_pages before a shortcode, if it is used, or display after content?
wordpress
I know this has been a long debated issue with WP, but I was hoping that since the 3.5 upgrade, there has been some progress in categorizing images in the Media Library. Really, what I am hoping to accomplish is creating a set of categories for the images in the Media Library, and then assigning the current images, or ...
See the question / answer on this stackexchange-url ("link"). The answer have 2 different solutions, easy with default categories and taxonomies and also a solution with custom taxonomies only for media.
Taxonomies for Wordpress Media Library
wordpress
Using this code from codex: <code> function my_enqueue($hook) { if( 'edit.php' != $hook ) return; wp_enqueue_script( 'my_custom_script', plugins_url('/myscript.js', __FILE__) ); } add_action( 'admin_enqueue_scripts', 'my_enqueue' ); </code> this will add a custom stylesheet into wp-admin on the edit page, how can we ch...
Don't confuse menu structure with page/URL structure. Each one of your pages may have a different hook. Do this: <code> function my_enqueue($hook) { echo $hook; } add_action( 'admin_enqueue_scripts', 'my_enqueue' ); </code> Load your pages and write down the hook names. There may be other ways to do this too, like the ...
How to include stylesheet in custom admin using parent_slug
wordpress
I've used Wordpress for years. Whenever I would add an image to an article, I manually would write out all of the HTML for every image. I also used an image lightbox plugin called Highslide for people to enlarge my thumbnails. An example thumbnail that links to a larger image looks like this in my manual HTML: <code> &...
This filter checks if an anchor is in the html image send to the editor and if so adds rel and class to the anchor. <code> function add_highslide_attr( $html ) { preg_match_all('/(&lt;a[^&gt;]*&gt;)(.*)/i', $html, $result); if( !isset($result) || !isset($result[1][0]) || ! $result[1][0] ) return $html; $anchor = $resul...
Modifying the HTML Output of Inserted Images
wordpress
Im currently working on a Theme for a WordPress website. The theme affectively splits the website up into three sections. <code> http://url.com/section1 http://url.com/section2 http://url.com/section3 </code> I need to be able to split up Pages in the backend into these sections. So in the menu it appears: <code> - Pag...
I need this to be done with PHP so that the user cannot set the Parent. I asked this over on WP.SE and got a promising answer: stackexchange-url ("stackexchange-url I haven't got around to testing it yet, though, as the project is on hold. And I need to know how to divide up the pages into the relevant sections. I'm no...
WordPress Pages into Sections edit.php PHP hack
wordpress
Is there a way to add a source link at the end of an article like TechnoBuffalo (scroll down to end of post) with a plugin? If someone could find a plugin or quickly make one for me that would be great.
Thats what meta_boxes are for. First you need to register the metabox within the page or post with the function add_meta_box . Then you want to get that value with get_post_meta on the page where you want the "Source". This goes into your functions.php file: <code> /* Define the custom box */ add_action( 'add_meta_boxe...
Article source link for posts
wordpress
I inherited a wordpress e-commerce website from a developer that only half finished the project. I do not know alot about css or php, but I have been able to play around with the coding enough to almost finish the products page. I am having trouble formatting the products page however, the products listing is too wide ...
So there are a few things you'll want to take a look at... And let me clarify the behavior you're seeing too... First, are you saying that when you actually make code changes to the wpsc-default.css file and save them, when you inspect the code after you refresh the page, your changes are not there? If that's the case,...
E-Commerce Products Page Sidebar Formatting
wordpress
I have a custom post type which supports editor. (WordPress ver. 3.5) I want to customize the editor for it. Make it readonly Hide "Add Media" button Hide HTML editor Remove status bar showing word count I am using the following code: <code> add_filter( 'tiny_mce_before_init', function( $args ) { $args['readonly'] = 1;...
It should be <code> 'media_buttons' =&gt; FALSE </code> . <code> array ( 'textarea_rows' =&gt; 5, 'media_buttons' =&gt; FALSE, 'teeny' =&gt; TRUE, 'tinymce' =&gt; TRUE ) </code> … creates this editor:
Hide "Add media", html editor from tinymce
wordpress
I want to get the ID of the currently logged in user. I've found the function: <code> get_current_user_id </code> which seems to be working, however I'm not sure what 'current' means in this context. Meaning if the user views the profile of another user, then will the current user change to become the other user? In sh...
<code> get_current_user_id() </code> effectively does what @Giri had described in the first snippet. The internal Wordpress function-call chain eventually calls <code> get_currentuserinfo() </code> which already checks if there is a WP_User object, meaning a user is logged in. Thus, from what I can see in the linked co...
How to get the ID of the currently logged in user?
wordpress
I am trying to creating some custom options for a template I am developing but I am getting an error when the checkbox (Line 130) is unchecked: Warning: Illegal string offset 'show_admin_dev' in E:\composite-cms\WordPress-Settings-Sandbox-master\lib\admin\pages\dev-page.php on line 11 This is the line that seems to be ...
Your problem is that you haven't included a sanitization function as the third parameter to register_settings on line 111. When no sanitization provided WordPress deletes the value of the option and creates a new one based only on what is passed in <code> $_POST </code> . Since unchecked checkboxes are not sent by the ...
WordPress settings API error when checkbox unchecked
wordpress
I've been studying roles and capabilities and have worked with and worked up a bunch of awesome code for creating unique capabilities and roles. I have created a "Master Editor" role to maintain users with almost every capability... However, edit_users &amp; delete_users obviously allows for an editor to CUD users, inc...
Your question seems to boil down to this I can't figure out how to check that the $userids in question are an administrators user ID. Try <code> user_can($id,'administrator') </code> http://codex.wordpress.org/Function_Reference/user_can The Codex has a warning about using role names with the <code> current_user_can </...
Remove Ability for Administrators to Delete Administrators
wordpress
I'm trying to find how to edit format of <code> bbp_forum_freshness_link() </code> function in bbpress plugin. E.g. currently it displays how many days ago there was last activity and I would like to display date. So if someone would like to share some thoughts or code snippets, that would be great.
I cannot test it right now, but it should work like this: <code> add_filter( 'bbp_get_forum_freshness_link', 'wpse_77441_change_time_format', 10, 2 ); function wpse_77441_change_time_format( $anchor, $forum_id ) { $last_active = get_post_meta( $forum_id, '_bbp_last_active_time', true ); if ( empty( $last_active ) ) { $...
how to edit bbp_forum_freshness_link() format
wordpress
Here's what I have so far as my notification, but I can't find any information around how to input the user's name, role and site name within those sections. You can see where they are supposed to go. Any help would be much appreciated as I've been stumped for a few days now... <code> function my_network_notice(){ glob...
You can use the <code> bloginfo( 'name' ) </code> function to display the site name. Information about the current logged in user can be retrieved using the <code> get_currentuserinfo() </code> function. Here is the fixed code: <code> function my_network_notice(){ global $pagenow, $currentuser; get_currentuserinfo(); i...
How do I display user name, role and site name using HTML tags inside a dashboard notification?
wordpress
How to display parent post title on individual image attachment page heading of the post gallery? Currently, it shows image name as page heading on image attachment page. Any help appreciated. Thanks
Use … <code> echo get_the_title( $post-&gt;post_parent ); </code> … where <code> $post </code> is the currently viewed attachment.
Display post title on individual image attachment page
wordpress
On the WordPress codex Add Role page it says how to add a role, but I can not figure out how to do it, or that is inherits. Specially the comment <code> //Use false to explicitly deny </code> . What does that mean? Does that mean if i do not say false to all the capability they can still do is if they guess the rigth U...
You must set to true for them to take affect. If you do not specify true they all default to NULL which in turn basically makes them false. So to create a roll that allows pages only: <code> add_role('page_editor', 'Page Editor', array( 'read' =&gt; true, 'edit_others_pages' =&gt; true, 'edit_pages' =&gt; true, 'edit_p...
Add Role inherits?
wordpress
Is there a way to get comments with more than one <code> status </code> using <code> get_comments </code> function? Let's say I would like to get both <code> trash </code> and <code> hold </code> comments. It is possible to do the same with posts: <code> get_posts(array('post_status' =&gt; 'draft,private,trash')); get_...
As of the Wordpress codex there is no such option. But you could just combine two or more comment arrays using plain PHP: <code> array_merge( get_comments( array( 'status' =&gt; 'hold' ) ), get_comments( array( 'status' =&gt; 'trash' ) ) ); </code> http://codex.wordpress.org/Function_Reference/get_comments http://php.n...
How to get comments with mixed status using get_comments?
wordpress
Let's say I have several custom post types that all have support for post tags. Since these custom post types will all be tagged with mostly the same keywords, I'd like to know if there is a way to share the commonly used tags between the custom post types. So if I were to browse a post edit screen for Custom Post Type...
When you register_taxonomy you can simply add an array of post_types to <code> $object_type </code> parameter. From WordPress-codex: (array/string) (required) Name of the object type for the taxonomy object. Object-types can be built-in objects (see below) or any custom post type that may be registered. So you can just...
Share Tags Between Custom Posts in Admin
wordpress
I need to know how can I get the child/grandchild terms of the current taxonomy being viewed, and put it into a drop down so that I can add values to the options. I am currently using this code to display exactly what I want, but I am unable to modify the options in the drop down - <code> &lt;?php //first get the curre...
Ok well without any help from here....... I was able to figure out how to change the option and select values of wp_dropdown_categories to display the child terms of the current taxonomy being viewed- First I placed this code into my functions file, which creates a walker class - <code> class SH_Walker_TaxonomyDropdown...
How to create drop down for child categories of current taxonomy being viewed?
wordpress
Why does WP pagination break when used on the homepage? If you take the code below and use it in a page template it works perfectly (make sure you have 3 or more posts). However, as soon as you use the same code on home.php, front-page.php, index.php or even as a page template but set as a static homepage, it breaks. T...
The solution is to not alter the main query in the template. The default query happens before the template is loaded, so querying in the template overwrites that original query, which is a waste of resources. See the example in codex under <code> pre_get_posts </code> for the correct way to alter the default query with...
Why does pagination always break when used on any form of a home page?
wordpress
My MySQL databases are limited to 1024MB per 1 database but WPMU websites need to exceed that... Is there any way to make WPMU go and use <code> database_2 </code> when <code> database_1 </code> is already close to 1024MB? I can have: <code> database_1 </code> 1024MB <code> database_2 </code> 1024MB <code> database_3 <...
There is no code I know of to automatically partition databases like that based on their size, but if you want to use something to manually split your system across multiple databases, then HyperDB is one way to do that. http://wordpress.org/extend/plugins/hyperdb/
WPMU on MySQL limited to 1GB of space?
wordpress
I am making multi-language site powered by WordPress. WPML is not free and it makes too many extra sql queries to database so it is not good solution for my site. qTranslate saves all languages in one database row and it is very complicated to move to another multi-language plugin later. <code> &lt;?php _e( '&lt;!--:en...
I would rather use multisite than WPML. WPML slows down website a lot. With multisite you dont have connected posts with translation, but gives you much faster loading.
multi-language WordPress site
wordpress
I am using this function to display categories specified to a post having gallery on the image attachment page. <code> &lt;p&gt;CATEGORY: &lt;?php the_category(', '); ?&gt;&lt;/p&gt; </code> The problem is that this function doesn't return anything. I have also used this way to display categories but no success: <code>...
If you have WordPress 3.5 this will work. http://make.wordpress.org/core/2012/12/12/attachment-editing-now-with-full-post-edit-ui/ First you need to enable this in your theme, Put this in your functions.php file in your theme root. <code> add_action('init', 'wpse_77390_enable_media_categories' , 1); function wpse_77390...
categories on attachment page
wordpress
So I have this website that I am building and I am using get_the_author_meta to display various information about the user / author including user image. I added a function in my functions.php which allows to add more options to the author profile such as: facebook profile, twitter, image etc etc.. this is the basic fu...
it was my mistake to comment this code, in my real code it is not. anyway I found a solution myself finally. changing the variable $user-> ID to $author fixed the problem that's the working code: <code> &lt;img src="&lt;?php echo esc_attr( get_the_author_meta( 'author_pic_sidebar', $author ) ); ?&gt;" alt="" class="aut...
get_the_author_meta not working
wordpress
I'm researching the structure of WordPress database and there is something that really get me confuesd. Could someone please explain, what is the exact job of <code> meta_key </code> and <code> meta_value </code> fields in <code> wp_commentmeta </code> , <code> wp_postmeta </code> , <code> wp_usermeta </code> tables? W...
Think of them as array key/value pairs (kinda). These tables are used to store additional data about particular posts, comments, or users. The <code> meta_key </code> is the name by which the <code> meta_value </code> is retrieved, plus you have associations with particular posts, comments, or users by means of IDs. As...
Job of meta_key meta_value fields in database tables
wordpress
Happy holidays everyone. Hope someone can help me in thinking about a problem I've run into. I have a plugin Im building that allows the user to pull address data from the maps API - ie it validates an address and if it is a business, pulls the marker icon, address details, web link etc. and builds a shortcode to rende...
You have quite a bit of markup for that shortcode. Trying to pass all of that as a shortcode is going to be trouble. I pulled it apart to look at it. id="map" z="11" w="100%" h="300" scrollwheel="false" maptype="ROADMAP" address="Southampton, United Kingdom" marker="true" markerimage=" <code> http://anachronistic.local...
passing markup thought a shortcode attribute
wordpress
I stumbled upon one problem regarding too complicated(at least in my point of view) data structures stored in option field. Right now I have an array of collections and within each other there is another sub-collection (as depicted below). In my opinion it looks too complicated, especially when one wants to store some ...
This is a typical situation for using a class to manage a data structure. You got a complex data structure and you need some functions to retrieve and modify the data structure. This is easy made with a class. The class get the data structure from the database and have some methods to get parts of the data structure or...
Ways of dealing with nested arrays within option
wordpress
I'm trying out the Options Framework , and I've started hacking options.php. I have reduced the amount of options, and one of the options left is an image upload. I have gone into Theme Options, and uploaded an image (for the logo), but I cannot find mention of this anywhere in the database. If I search phpmyadmin for ...
Selecting the theme master as the current theme outputs instructions to the front page of the website. Amongst the instructions is the necessity to use the code: <code> of_get_option($id,$default) </code> So, I needed to use: <code> of_get_option('logo_uploader') </code>
Options Framework not saving options correctly
wordpress
I'm using Woocommerce for products. All products are imported automatically by a plugin. Currently when i want to attach an image to a product (a post type) i have to use "Featured image" to display the image on the website. This is all manual work. Once i save the image, the image is saved to the database in table wp_...
I got it now using the following code: <code> //featured image from postmeta function postmeta_img_update() { global $post; // If Custom Post Meta Field for a Image/Thumnail Exists if( get_post_meta($post-&gt;ID, "_image", true): // Get Image Location and File Extention $img = get_post_meta($post-&gt;ID, "_image", true...
How to add image attachment to post from a single meta key (Woocommerce)
wordpress
I wish to edit the text in the dashboard's help tab. I can add help to other pages, but I want to change the text in the grey box with links on the right-hand side of the help tab. It is on the 'For more information:' section. I want to add links to my support page and not the WordPress support forum. <code> function m...
The documentation in the Codex seems outdated. Use the following code (see comments): <code> // Priority 5 allows the removal of default tabs and insertion of other plugin's tabs add_filter( 'contextual_help', 'wpse_77308_products_help', 5, 3 ); function wpse_77308_products_help( $old_help, $screen_id, $screen ) { // N...
Edit dashboard's help tab
wordpress
I really would like a nice frontside wysiwyg-editor for the P2 theme. Preferable a light one with only the most basic controls. Tried front-end-editor but not to fond of it´s looks and UX. Plain and simple are key.
This question is quite old but the plugin which answers this question is quite new (in fact not finished yet). http://wordpress.org/plugins/wp-front-end-editor/
Wysiwyg editor for P2 theme
wordpress
I try to get posts that either do not have a custom field set or if set have a value not like a given parameter. Here is my code: <code> $args_included = array( 'numberposts' =&gt; 1, 'post_type' =&gt; 'post', 'post_status' =&gt; 'published', 'meta_query' =&gt; array( 'relation' =&gt; 'OR', array( 'key' =&gt; 'requeste...
You don't need to add the % signs to the value. WordPress does that for you automatically on a LIKE or NOT LIKE comparison. You also don't need to "sanitize" the parameter, it will be automatically escaped for SQL. See wp-includes/meta.php, around line 806 or so.
Why posts array is empty?
wordpress
I've got a plugin that puts post statuses into post type admin menus. I'm in the middle of internationalizing it, and I'm wondering how to handle this situation. The plugin uses some unique strings that will get a textdomain like this: <code> __( 'Select the post statuses to &lt;strong&gt;exclude&lt;/strong&gt; from po...
Never rely on core strings for translation, they may change or get a <code> context </code> parameter any time. Once that happens your users get a partially translated interface, and your translators have no way to fix that. Also keep in mind the same string is not necessary translated everywhere with the same word. Ev...
Can I leave off plugin textdomain for terms used in core?
wordpress
I have a problem with my page. I'm trying to make a "Contact Us" page. It's working perfectly fine design-wise. But when I try to send the form to the same page as origin. It returns 404 error. It only happens when I'm sending the form. I've tried both with GET and POST requests. Nothing seems to work. I've even commen...
Prefix everything, especially your variables. The names you are using are used by WordPress internally (see the comment form), so WordPress might try to do something with your form values. If that fails you get an error. While <code> $_GET </code> problems are usually rather easy to debug, <code> $_POST </code> and <co...
Page returns 404 with POST variables, but not without
wordpress
I would like to add a new section in the custom menu panel that would allow predetermined URLs to be added to a custom menu. For example, I would like a custom post type archive page. I know that they can be added manually by specifying the URL in the custom link section, but then if the site URL changes then the custo...
I have made a custom menu for the nav menu page to add post type archives just like posts/pages etc. I don't think it's possible to make it change the url on siteurl change. You could add the url as <code> /slug/ </code> instead of <code> http://url.com/slug/ </code> , but that won't work with WordPress in a folder. <c...
Add section to custom menu panel
wordpress
Is it possible to add a class or ID to next/prev image links in <code> attachment.php </code> ? I tried like this but it didn't work: <code> &lt;?php next_image_link( false, 'Next', array('class' =&gt; 'next')); ?&gt; </code>
There two hooks to filter these links: <code> previous_image_link </code> and <code> next_image_link </code> . So we can add these classes per filter: <code> add_filter( 'previous_image_link', 'wpse_77296_img_link_class' ); add_filter( 'next_image_link', 'wpse_77296_img_link_class' ); /** * Add CSS class to image navig...
Adding class to next/prev image link in attachment.php
wordpress
I went through a lot of threads, codex page and tried messing with a lot of things but my code doesn't seem to be creating the tables. And I am not able to figure out where I am going wrong. I checked booking_db_version in the database, it gets updated when I update it in the file. Here's the code <code> global $bookin...
From WordPress-codex about dbDelta: The dbDelta function examines the current table structure, compares it to the desired table structure, and either adds or modifies the table as necessary, so it can be very handy for updates (see wp-admin/upgrade-schema.php for more examples of how to use dbDelta). Note that the dbDe...
dbDelta not creating tables
wordpress
I have a multisite that was setup on WordPress 3.4. That means that uploads for sub-sites are stored in <code> wp-content/blogs.dir/{blog_id}/files </code> and are served through ms-files.php. In WordPress 3.5, ms-files.php was disbanded completely for new installs and uploads are stored and accessed at <code> wp-conte...
In theory: Move images from blogs.dir/SITENUM/files/ to /uploads/SITENUM/ (or make an alias) Edit all sites so they don't look in /files/ but in /uploads/SITENUM/ .htaccess, remove the ms-files.php line Search/replace each posts table for each site, changing /files/ to /uploads/SITENUM/ A walk-through can be found here...
Turn off ms-files.php after network setup
wordpress
Ok that's something normal, files are being downloaded again and the code changes. What should I do if I don't want some changes to take place? For example a gallery plugin I use recently updated and a border I didn't want to appear in the gallery now exists again. Updates should always take place for security reasons ...
If it's just a CSS change, load your own CSS stylesheet to override their CSS. If it's the HTML of the plugin, then you will need to look at filter hooks to see what you can change. Some plugins are developer friendly and supply some filter hooks allowing you to change various things the plugin does; for others, you wi...
custom changes removed after plugin update
wordpress
I'm using the Options Framework Theme to put together an options page. The user(s) I'm building this for would like to be able to edit a few settings directly from this page, including of which - the Site Title and Tagline . Concept: Options.php: <code> $options[] = array( 'name' =&gt; __('Site Title', 'options_framewo...
The framework offers a filter for validating input values inside the <code> optionsframework_validate </code> function. Just for reference, here's the relevant part from the file <code> wp-content/themes/your-theme/inc/options-framework.php </code> : <code> /** * Validate Options. * * This runs after the submit/reset b...
Site Title and Tagline in Theme Options Page
wordpress
I'm looking for a way to link to author pages within one WordPress install simply by putting the @ symbol in front of a person's username in a post.... just like on twitter. Example: If the username is "Bill256" and I write "@Bill256" it will be linked to his author page.
This is a little tricky because <code> sanitize_user </code> allows spaces in usernames, meaning it difficult to avoid grabbing the whole phrase '@johndoe said that ... ' as opposed to just the actual username '@johndoe' and you have no separator at the end that would help. To avoid that I imposed a requirement that sp...
WordPress Internal @ Mentions
wordpress
I have a custom post type 'Participant' with many custom fields. I also have a form with corresponding input fields for the user to fill out. When he submits the form, I want a new post to be generated with each custom fields containing the value chosen by the user. Is it possible to do and if so, how?
Use wp_insert_post() and add_post_meta(), like this: <code> // insert the post and set the category $post_id = wp_insert_post(array ( 'post_type' =&gt; 'your_post_type', 'post_title' =&gt; $your_title, 'post_content' =&gt; $your_content, 'post_status' =&gt; 'publish', 'comment_status' =&gt; 'closed', // if you prefer '...
Programmatically publish a post (custom post type) with custom fields
wordpress
I want to add the font awesome iconfont to my menu list items, so I need to make a custom Walker. Because the font per menu item will be different I was hoping to use the css class in the WP backend to add the name of the icon and then output that css class within the output of the walker. Example how it should become:...
ok, I figured it out myself. instead of using the CSS class (as I cannot figure out how to filter it), I decided to use the description instead. under the lines with <code> $attributes </code> I have added this line: <code> $description = ! empty( $item-&gt;description ) ? esc_attr( $item-&gt;description ) : ''; </code...
custom walker to add iconfont to wp_nav_menu
wordpress
I was wondering if there were any cut and dry rules to placing meta boxes? I have a meta box for a custom post type for a TV series that holds extra information for said series: when it began airing, genre, etc and I'm debating whether to place it under the editor or on the side. Are there any unofficial rules to what ...
It is hard to declare best practices here. The placement depends on the content of the metabox: an editor field would be too narrow usually in the side column; two small checkboxes on the other hand will look lost in the main column. To understand where which box will be placed, let’s use a small demo plugin: <code> ad...
Best practices for meta box placement?
wordpress
I have never used WordPress before, but have done a lot of programming. But what is the normal way of making customs forms? I need to create a form where a user fill some input fields and on submit will the data be stored in the database. No need for any email. I also need to query the data and get the output in a HTML...
It give different ways. For store data, like options is the options table, the options API , the right place with a entry and a array as store element. But for store data to use it like posts and each request from the form is it better to save also like post. But also here different possibilities. You can save for diff...
Custom form that store input in database
wordpress
my client in his template is using <code> &lt;?php comment_author_IP(); ?&gt; </code> to display IP's of comment authors. Recently he came to me with idea of limiting whole number to several characters. Final result should be something simillar to: 192.168... How can i achieve it? I've tried with jquery but without suc...
You can filter <code> 'get_comment_author_IP' </code> : <code> add_filter( 'get_comment_author_IP', 'wpse_77254_trim_comment_ip' ); function wpse_77254_trim_comment_ip( $ip ) { return implode( '.', array_slice(explode( '.', $ip ), 2) ) . '…'; } </code> Note this will fail with IPv6 addresses .
IP address character limit
wordpress
I guess I would like to be able to include HTML tags within the title so that when the title is listed certain words are bolded. Is this possible? When I try to put HTML into the title, the tag itself is output (escaped) in the final page list.
Yes, you can use HTML elements in post titles by default. If your output is escaped a plugin or theme might have touched that. Disable all plugins and switch to TwentyEleven. This will help you to identify the source. Note that markup is stripped in some places where it is not allowed: <code> title </code> attributes a...
Is it possible to bold certain words in a post title?
wordpress
can I make a Blog Provider like Wordpress.com? Which features and Plugin exist in wordperss.com but we cant have them in our clone site of WordPress free source?
Install WordPress as a multisite installation. Check Codex ! for how to start. You can google for more tutorials on how to setup a multisite installation.
How can I install WordPress as blog provider , stable?
wordpress
How would I put the following code, for a certain shopping cart, just before the closing body tag in my WordPress site? In the footer? It seems to me that I would only want to call startcart() for product pages. Thanks very much. <code> &lt;script language="javascript" type="text/javascript"&gt; startcart() &lt;/script...
If you're just using a small script or other markup, you can hook a function to the <code> wp_footer </code> filter, which is included in all modern themes: <code> function wpse_77196_script_in_footer() { &lt;script language="javascript" type="text/javascript"&gt; startcart() &lt;/script&gt; } add_filter( 'wp_footer', ...
How to add code to just before closing body tag
wordpress
I tried to avoid ask this question, because I think that must be simple, but after long hours trying to get an answer I cant achieve it. I am trying to get a permalink structure like this: <code> http://domain.com/u/USERNAME http://domain.com/p/POSTID </code> To get that structure I set a "Custom structure" in the perm...
I would just change the <code> author_base </code> on the global <code> $wp_rewrite </code> object. Also add a field to the Permalink options page, so you can change it at will. To start: a class to wrap everything up. <code> &lt;?php class Custom_Author_Base { const SETTING = 'author_base'; private static $ins = null;...
Different permalink for posts and authors
wordpress
Enqueuing Google Web Fonts the usual way, i.e., using the <code> wp_enqueue_style </code> function like so... <code> function wpse_google_webfonts() { wp_enqueue_style( 'google-webfonts', 'http://fonts.googleapis.com/css?family=Ubuntu+Condensed|Open+Sans:400italic,700italic,400,700' ); } add_action( 'wp_enqueue_scripts...
WordPress knows what it is doing here. Honest. When rendering an ampersand in HTML, you should always use <code> &amp;amp; </code> or <code> &amp;#038; </code> . The browser then converts it to <code> &amp; </code> before actually firing the HTTP request. See for yourself by inspecting the network calls in a web inspec...
Enqueue Google Web Fonts Without Messing Up Symbols In URL
wordpress
I've read that nonces are meant to be for one time use only, and after an ajax request, you should issue a new nonce so with the next ajax request, a new nonce would be sent to the server. However, I just tested repeated ajax requests using the same nonce token, and for each request <code> wp_verify_nonce </code> retur...
In WordPress, nonces are specific to the user, the action being performed, and the time. With regards to time, a nonce is valid for 24 hours, and changes every 12 hours. This is considered an acceptable trade-off, since using a real number-used-once would involve adding a tracking system and having storage of the used ...
Nonces can be reused multiple times? Bug / Security issue?
wordpress
I want to change primary menu according to the language of the user. I have reviewed multi language plugins such as WPML and qTranslate. They have lots of features but what I want is much simpler than what they provide. There will be three links such as English, Arabic, and Turkish in the upper right corner. When the u...
This can be done via cookies. We set it with Javascript, reload the page and display different menus in PHP using its value. First, print the script at the site footer (see comments). Note: would be better to enqueue this together with your theme scripts. <code> add_action( 'wp_footer', 'wpse_77220_language_cookie' ); ...
How to change menu according to the language?
wordpress
I want a simple post editor for WordPress, it should be something like tumblr editor or the stackoverflow editor. My questions: Is there any plugin I can use? (I just can't find it) If no plugin, how can I implement it? Is there any example? (I saw one site has such editor using WordPress, but they have reworked their ...
You can use the Stackexchange Editor with the WP-Markdown Plugin, created by Steve Harris in this stackexchange-url ("Question").
How can I implement a simple post editor?
wordpress
What are the advantages and disadvantages of using <code> add_theme_support('automatic-feed-links') </code> in my <code> functions.php </code> file?
A long time ago WordPress did not put feed links into the <code> head </code> element automatically. Theme or plugin authors had to do that. In 2009 <code> automatic_feed_links() </code> was introduced , a function that should be used in themes or plugins to let WordPress do the hard work. One year later it was added t...
Advantages and disadvantages of using automatic-feed-links
wordpress
I am trying to find a way to add <code> rel="nofollow" </code> to my comments pagination links. Can anyone provide me with a hook or way to do so?
There are two special filters for that: <code> add_filter( 'previous_comments_link_attributes', 'wpse_77217_comment_nofollow' ); add_filter( 'next_comments_link_attributes', 'wpse_77217_comment_nofollow' ); function wpse_77217_comment_nofollow() { return ' rel="nofollow"'; } </code>
How to no follow the paginated comments
wordpress
I have post views enabled and I'm attempting to make an options panel option to allow users to choose if they would like to display post views in each post . If they choose 'Yes," then they will be shown post views. If they choose 'No,' then they will not. I'm hoping somebody can help me create the correct get_option t...
So this goes in your themes functions.php file. This adds a metabox on the right side of your editscreen within posts called "Enable Post Views on this Post": <code> // Hook into WordPress add_action( 'admin_init', 'add_custom_metabox' ); add_action( 'save_post', 'wpse_16722_save_post_views_value' ); /** * Add meta box...
Choose To Display Post Views With An Options Panel
wordpress
Below is my pagination code. It can be seen in action at this link . When I start on page one it displays the first 3 pages and page 9 (the last page). When I go to the second it displays the first 4 and page 9. I find this to be odd behavior and expect the numbers to be added in a traditional behavior, like that code ...
What you are seeing, I believe, is a result of <code> paginate_links </code> using three blocks of numbering-- first, middle, and last. If you had enough pages you'd get, for example, when browsing page 50 ... 1 2 3 ... 49 50 51 ... 98 99 100 If you imagine the "middle" numbers overlapping the "first" numbers you'd get...
Pagination Adding Numbers in Strange Fashion
wordpress
For some reason, when viewing a category, the posts are repeated - basically the whole loop repeats as many times as there are posts for that category. E.G.: If <code> category_a </code> has 3 posts, the page will display: post1 - Featured post2 post3 post1 - Featured post2 post3 post1 - Featured post2 post3 If <code> ...
Ahhhh, thanks to Ralf912's help troubleshooting, I was able to figure out the solution. I needed to remove the "parent" loop - so replacing <code> &lt;?php while (have_posts()) : the_post(); ?&gt; </code> with <code> &lt;?php if (have_posts()) : ?&gt; </code> and replacing the closing <code> &lt;?php endwhile; ?&gt; </...
How do I stop the loop from repeating in my category template?
wordpress
On my website, registered users (subscriber role) can send drafts and, if admins validate them, they are published. I'm trying to add a tag box to frontend editor used to send new posts. To implement the autocomplete feature I'm making an AJAX call to this URL: <code> http://example.com/wp-admin/admin-ajax.php?action=a...
All the WordPress AJAX calls should be handled by the <code> admin-ajax.php </code> , wether they happen on the frontend or in the backend. To grant the access you have to register the callbackfuntion for the AJAX call add those lines to your file: <code> add_action( 'wp_ajax_prefix_update_post', 'prefix_update_post' )...
Allow AJAX call to other roles than admin
wordpress
I took this code from this question (which shows how to let users choose which posts to display by choosing categories and tags): stackexchange-url ("Filter index page plugin") function.php <code> add_action( 'pre_get_posts', 'do_user_post_selection' ); function do_user_post_selection( $query ) { if( !is_home() || !is_...
I suppose you need to make it global. It might look like: <code> add_action( 'pre_get_posts', 'do_user_post_selection' ); function do_user_post_selection( $query ) { if( !is_home() || !is_user_logged_in() ) return; if( isset( $query-&gt;query_vars['post_type'] ) &amp;&amp; ( 'nav_menu_item' == $query-&gt;query_vars['po...
How to use this $tax_selection variable in this custom loop?
wordpress
I'm a Wordpress Theme Designer. I want to have functions to make my footer links remain intact. Like some themes that use this method to protect their footer link from the theme downloaders to remove it. If they alter, change, or deltete parts or all, they will get an error! Any step by step guide or source would reall...
If you are releasing a GPL'd theme (which WP requires, but not looking to start the whole GPL debate here) then you can't prevent someone from removing your footer link. You can ask they they don't do it. But anyone who's looking to do so will get around whatever method you employ. a side note: having these links in th...
How to Keep footer link remain intact?
wordpress
I'm building a custom theme. My sidebar is not being generated at all. In functions.php, I have: <code> if ( function_exists('register_sidebar') ) { register_sidebar(array( 'name' =&gt; 'Standard Sidebar', 'id' =&gt; 'sidebar-1', 'description' =&gt; 'Appears as the sidebar on standard pages', 'before_widget' =&gt; '&lt...
Your get_sidebar call: <code> &lt;?php get_sidebar; ?&gt; </code> is missing the parentheses: <code> &lt;?php get_sidebar(); ?&gt; </code>
How to troubleshoot Sidebar not being generated
wordpress
I'm trying to build a slider exactly like this in wordpress. I have managed to make the slider work except the next/prev button. I need to get the next image title and the previous image title for the next/prev button. my code is like this: <code> &lt;script type="text/javascript" charset="UTF-8"&gt; var clist_autoplay...
You are using an associative array of <code> $attach_id =&gt; $attach_obj </code> and loop through it. While there are methods to get the next and previous elements in this array, I would prefer to rely on continuous index array to get these objects. First convert the array: <code> $images = array_values($images); </co...
How to get the next and previous image title from attachment or gallery?
wordpress
For those with experience of the Contact Form 7 plugin - When I installed it, the form worked fine, and upon pressing the submit button, there was no page load, all done via Ajax, however now the page loads upon pressing submit. I have not made any changes to the form. I have tried deactivating then activating but the ...
Have you installed any other plugins? Also check in <code> header.php </code> that there is <code> wp_head(); </code> function in <code> &lt;head&gt;wp_head(); &lt;/head&gt; </code> tag and <code> wp_footer(); </code> before <code> &lt;/body&gt; </code> tags ends
Contact Form 7 plugin refreshing page on submit
wordpress
I currently use a Wordpress network in order to run a number of sites, which all use the same template, plugins and images. As posts appear on a multiple sites, it makes sense to only upload images to one location (and have one copy of an image), rather than multiple ones. Could I perhaps achieve this by creating a cus...
You can pretty simple add some actions to archive this. <code> function wpse_16722_main_uploads() { switch_to_blog(1); } add_action('load-media-new.php', 'wpse_16722_main_uploads'); add_action('load-media-upload.php', 'wpse_16722_main_uploads'); add_action('load-media.php', 'wpse_16722_main_uploads'); add_action('load-...
Using same directory for storing all uploaded images on a Wordpress network
wordpress
I'm creating a WordPress theme for my portfolio and I would like to my single.php file to act just like the index.php. I need the single.php to show the entire loop but if I access single post's page it only shows the specific post not the full list of posts. I'm using a one page design and I have to use i.e <code> &lt...
you could create a secondary loop using <code> WP_Query() </code> to get all posts; the links should have enough examples to get you started.
I would like single.php to act just like index.php
wordpress
Hi all I am newbie to wordpress I am using the wp_list_categories in the sidebar to display the categories . How can i display thus categories sort by id any one much appreciated... <code> &lt;?php wp_list_categories('exclude=73');?&gt; </code>
<code> wp_list_categories </code> takes an <code> orderby </code> parameter which accepts : ID - Default name slug count term_group So the default behavior of wp-list-categories is to order by ID but you can specify that like so: <code> &lt;?php wp_list_categories(array('exclude'=&gt; 73,'orderby' =&gt; 'ID'));?&gt; </...
How can i sort the categories by ID
wordpress
The problem is whenever I display a post containing gallery, it shows them all on front page same as within post. I want a function for posts on front page to display only the clickable featured image with read more below for posts have predefined featured image. And if the post has some specific category eg. video, it...
I am not sure that a filter on <code> the_content </code> is the way to go here. If I understand you, I think that all you need is something like the following your theme-- cribbed from the two Codex pages listed below and altered slightly. <code> if ( has_post_thumbnail() ) { // check if the post has a Post Thumbnail ...
function to show only featured image of the posts
wordpress
Environment: WP 3.5, Twenty Twelve child theme. I created a custom template. Now, I'd like to display the built-in sidebar-2 in this custom template page (instead of the default sidebar-1). sidebar-2 is already registered by twenty twelve functions.php. I read a bit about get_sidebar and how to activate other sidebars,...
<code> &lt;?php get_sidebar( 'customtemplate' ); ?&gt; </code> did the thing :)
Showing sidebar-2 on custom template page
wordpress
<code> $width = 560; $height = 315; $code = "I8M_uCnxhwY"; $homepage = "/"; $currentpage = $_SERVER['REQUEST_URI']; if($homepage!=$currentpage) { echo '&lt;iframe width=".$width." height=".$height." src="http://www.youtube.com/embed/'.$code.'" frameborder="0" allowfullscreen&gt;&lt;/iframe&gt;'; } </code> So, that's my...
I would say that's a quirk with the plugin. In this case, it's better to make a shortcode . Add this code to your functions.php file: <code> function wpse_77036_embed_video( $atts ) { extract( shortcode_atts( array( 'homepage' =&gt; '/', 'currentpage' =&gt; $_SERVER['REQUEST_URI'], 'width' =&gt; 560, 'height' =&gt; 315...
iframe not showing in post (with "allow php in posts" plugin activated)
wordpress
I've uploaded images directly to my WordPress server through FTP. I want to add these images to a post, so right now I'm using the Add from Server plugin that allows me to browse images on the server and add them to the media library. The only thing I don't like about this is that adding an image to the media library g...
I think that the best option here would be to disable the generation of additional image sizes on adding an image to the media library. Doing so is fairly straight-forward: Visit the Settings > Media page of your WordPress dashboard. Under the Image Sizes section, change all of the values to 0. Save the changes. This w...
Is it possible to insert images directly from the server?
wordpress
For a particular custom post type I'm setting, I simply want to change the default icon to the wordpress pages icon (menu-icon-page). I know I could upload my own pages icon and point to it, but can I just tell wordpress to use the default pages icon? Here's what I'm using <code> register_post_type( 'intranet-pages', /...
<code> add_action( 'admin_head', 'custom_post_type_icon' ); function custom_post_type_icon() { ?&gt; &lt;style type="text/css" media="screen"&gt; #menu-posts-intranet-pages .wp-menu-image { background: url("PATH TO SMALL ICON") no-repeat 6px 6px !important; } #menu-posts-intranet-pages:hover .wp-menu-image, #menu-posts...
How can I use a different default admin menu icon for custom post type?
wordpress
I've created a plugin that uses a custom shortcode to allow the user to easily split their post into columns. The problem is, when writing about how to use the shortcode in the plugin documentation on my website, WordPress interprets the shortcode and starts applying to to my content. I don't want this, rather I want t...
The secret is called escaping . You need to place an extra set of square brackets around your shortcode <code> [[gallery]] </code> and it will display as <code> [gallery] </code> . Also, double escaping works too: <code> [[[gallery]]] </code> outputs <code> [[gallery]] </code> . There is also a Trac ticket on this topi...
Escaping a shortcode so it displays as-is
wordpress
I have 5 author levels in my WordPress site. Levels are calculated using points <code> - level 1 - level 2 - level 3 - level 4 - level 5 </code> Authors getting impressions based on author levels like this. <code> - Level l =&gt; 50% - Level 2 =&gt; 55% - Level 3 =&gt; 60% - Level 4 =&gt; 65% - Level 5 =&gt; 70% </code...
<code> function get_current_number($author_id) { $current_number = (int) get_user_meta( $author_id, 'revshare_current_number', true ); if( in_array( $current_number, range( 1, 99 ) ) ) { $current_number++; } else { $current_number = 1; } update_user_meta($author_id, 'revshare_current_number', $current_number); return $...
How to build a fool proof AdSense revenue sharing model?
wordpress
I added the code below to the plugin that I'm working on to display the values of the custom fields but it shows up but blank. <code> function mySEO() { require('wp-site-gps-transport.php'); } // Add hook for admin &lt;head&gt; add_action('admin_head', 'mySEO'); // Add hook for front-end &lt;head&gt; add_action('wp_hea...
aside from a few syntax errors in there with your <code> printf </code> s, the crux of the problem is things like this: <code> $title = get_post_meta( $post-&gt;ID, 'title', true ); </code> won't work in your included file because there is no <code> $post </code> in this scope, You have to globalize <code> $post </code...
Outputting custom field query from a plugin to the website header
wordpress
I am wondering if it is possible to return a list of all the "tags" that are associated with ALL returned posts. In theory, I would then use this list of terms to build appropriate "filter by" links for refining the search. For instance: A user searches for "Foo" and there are 100 results. Would it be possible to get a...
The global <code> $wp_query </code> object is available before you call <code> have_posts() </code> . All you have to do is running through this object’s <code> posts </code> member with <code> get_the_terms() </code> . Sample function: <code> function get_query_terms( $taxonomy = 'post_tag' ) { $list = array (); forea...
Return all Tags from search results
wordpress
I've got a password protected post and <code> comments_popup_link('No Comments', '1 Comment', '% Comments'); </code> function displays "ENTER YOUR PASSWORD TO VIEW COMMENTS." message. The question is, is it possible to change this message without touching core files, maybe apply filter or something like that. Thanks.
The only hook to change that is <code> gettext </code> : <code> add_action( 'loop_start', 'wpse_77028_switch_filter' ); add_action( 'loop_end', 'wpse_77028_switch_filter' ); /** * Turn comment text filter on or off depending on global $post object. * * @wp-hook loop_start * @wp-hook loop_end * @return void */ function ...
Comments number message in password protected post
wordpress
Since the new version of Wordpress (3.5), it seems to be an incompatibility between the image manager and the custom image sizes. Previously I used in my functions.php : <code> add_action( 'after_setup_theme', 'addemo_setup' ); function addemo_setup() { add_theme_support( 'post-thumbnails' ); add_image_size( 'featured-...
Instead of using the functions.php to add my custom image size, I installed the plugin Simple Image Size . This plugin does perfectly the job.
Wordpress 3.5 - Add custom image size
wordpress
I have some actions like this <code> function simple_notification() { echo '&lt;div&gt;This is a notification&lt;/div&gt;'; } add_action( 'site_notices', 'simple_notification' ); function simple_notification2() { echo '&lt;div&gt;This is a notification&lt;/div&gt;'; } add_action( 'site_notices', 'simple_notification2' ...
Don't ask me way but i actually have a function to count hooked functions to a tag <code> /** * count_hooked_functions * @author Ohad Raz * @param string $tag hook name as string * @return int the number of hooked functions to a specific hook */ function count_hooked_functions($tag = false){ global $wp_filter; if ($tag...
How to count number of functions attached to an action hook?
wordpress
I am working on twenty twelve theme. Whenever I post an image gallery, it shows all of images including featured image on front page same as it looks inside. I wanted it to just show featured image on home page instead of showing all. I tried but no success. Any help appreciated!! Thanks
You need to porvide more info, such as what you have tried so far. have you used <code> the_post_thumbnail </code> function? http://codex.wordpress.org/Function_Reference/the_post_thumbnail
Making featured image to show on home page
wordpress
Been working for several hours on getting my WordPress site to run on a secondary VPS with Nginx. Home is loaded and W3T Cache is working OK, but the permalinks are still broken and each one of them leads to a 404: <code> 404 Not Found nginx/0.8.53 </code> In the error.log I found <code> 2012/12/22 01:06:16 [error] 168...
Correct rewrite rules for wordpress.conf are: <code> location / { try_files $uri $uri/ /index.php?q=$uri&amp;$args; } </code> but the main issue was location. I misread at Dreamhost's wiki where I had to put this wordpress.conf. An awesome lady at Dreamhost explained it to me. I am very grateful for her telling me this...
Nginx Rewrite Rule:: index.html added to every permalink
wordpress
I would like to show a widget in only one page of my site, as i can see it is not possible right? Should i add that for all my site pages or not?
It depends on where you want to show the widget. Let’s start with the widget area (sidebar) registration: <code> add_action( 'wp_loaded', 'wpse_76959_register_widget_area' ); function wpse_76959_register_widget_area() { register_sidebar( array ( 'name' =&gt; __( 'Widgets on page Sample Page', 'theme_textdomain' ), 'des...
How to add a specific widget to only 1 page?
wordpress
I am using <code> wordpress 3.4.1 </code> . I need to display the featured image of a page. How can i get the <code> featured image url </code> by particular <code> page id </code> . Any help?
Did you try anything? Its always helpful to share what you have tried. <code> $url = wp_get_attachment_url( get_post_thumbnail_id($post_id) ); </code> Or if you want to get the image by image size. <code> $src = wp_get_attachment_image_src( get_post_thumbnail_id($post_id), 'thumbnail_size' ); $url = $src[0]; </code> ht...
get featured image url by page id
wordpress
In a WordPress.com hosted blog, you have the posibility to create picture galleries with a different style than usual: tiles, squared tiles or circles. What plugin are they using to achieve this? I haven't found that feature in a stand-alone WordPress installation.
Tiled galleries have been proprietary feature of wordpress.com, but later also released as Jetpack feature since version 2.1 of it.
How to have Tiled Galleries like in WordPress.com?
wordpress
Since wordpress does not have a menu icon (aka "user friendly) way to add the command to a post or page, I'm trying to create a shortcode to do it. However, as logic would have it, its not that easy. Doing this with a shortcode merely inserts into the markup, which is post process, not pre-process as wordpress does it ...
Best solution for what you want to accomplish which is essentially to make the next page feature more user friendly for your authors is to add a TinyMCE button that will do this for you. This may be a bit complicated so hold your hat. To avoid this answer being the length of a thesis, I have added comments in all codes...
Shortcode to insert
wordpress
I'm trying to add a new footer widget area to my theme. I was able to add the new footer widget area and it works correctly. But I would like to limit what can be done with the widget area by the end user, right now the user can add any widget that they wish to the new footer widget area. I would like to limit the widg...
Widget areas are the wrong tools for what you need. They are built to offer a choice. Breaking that would be very difficult … and hard to understand for the user. Alternative: Use a custom setting, for example in <code> wp-admin/options-general.php </code> where the tagline and the site title is. There is even a hook f...
Add New Footer Widget Area with Limited Options?
wordpress
I am trying to grab number of comments to display per page. So far unsuccessful, looking for something similar to this <code> $wp_query-&gt;max_num_pages; </code> Thanks.
From quick look at core that would probably be <code> get_option('comments_per_page') </code> . However WP functions just use this internally, why not just let them take care of it? You are not describing why do you need to handle this directly.
Get number of comments per page
wordpress
I am trying to display the posts on my front page of the <code> roots theme's base.php </code> file. I have added the loop as <code> &lt;?php while (have_posts()) : the_post(); ?&gt; &lt;?php echo '&lt;h2&gt;'; the_title(); echo '&lt;/h2&gt;'; the_content( 'Read the full post »' ); ?&gt; &lt;?php endwhile;?&gt; </code>...
Just save it with a suitable name like: <code> home.php </code> <code> index.php </code> <code> archive.php </code> <code> category.php </code> This link can help you: WordPress Template Hierarchy
Trying to display posts but getting the pages as output
wordpress
I'm using this redirect after inserting a post. It's not working, it only refreshes the page the form is on. I know the $pid is getting the post ID so what is the problem? This is the very end of my php code for handling the form submission. <code> $pid = wp_insert_post($new_post); update_post_meta($pid,'domain',$domai...
You can only use <code> wp_redirect </code> before content is sent to the browser. If you were to enable php debugging you'd see a "headers already sent" error due to <code> get_header() </code> on the first line. Rather than process the form in the template, you can hook an earlier action , like <code> wp_loaded </cod...
wp_redirect not working after submitting form
wordpress
I'm currently writing a plugin that displays some images - possibly with captions. So, I was wondering whether to use XHTML ( <code> &lt;div&gt; </code> s and <code> &lt;span&gt; </code> s) or HTML 5 ( <code> &lt;figure&gt; </code> and <code> &lt;figurecaption&gt; </code> ) for output. I image that the answer to this q...
WordPress will not help you here. In back-end use conservative XHTML 5: <code> &lt;br /&gt; </code> , but not <code> &lt;figure&gt; </code> (see WP coding standards ). In front-end … it is hard to determine the Doctype and the usage of polyfills , so stay with regular HTML as long as possible or load the necessary poly...
Output in XHTML or HTML 5 for plugins?
wordpress
How can add a new menu item underneath the "insert From URL" on the left sidebar in the new Wordpress 3.5 Media Manager? I've been looking at the backbone js and tried my hand at hooking into it with my own JS but without success. Edit 2: This seems to do the trick: http://sumtips.com/2012/12/add-remove-tab-wordpress-3...
OK, I think that I have something that is really close to be an answer: I put my code in a gist Here is the result : I built several Backbone object to respect the MVC pattern : the <code> controller.Custom </code> is in charge of doing all the logic, the <code> view.Toolbar.Custom </code> deals with toolbar buttons, a...
Add a menu item to Wordpress 3.5 Media Manager
wordpress
I am working with a <code> paginate_comments_links() </code> function and the thing is that I have customized it slightly (wrapped with a div), I need to check if check box "Break comments into pages..." in WP admin -> Settings -> Discussion Settings -> Other comment settings was checked. So the question is how would I...
The check is done with <code> get_option('page_comments') </code> . But you could use another solution: <code> $prev = get_previous_comments_link(); $next = get_next_comments_link(); if ( '' !== $prev . $next ) echo "&lt;div&gt;$prev $next&lt;/div&gt;"; </code>
Check if "Break comments into pages" is selected
wordpress
I have a small WordPress install that I'm setting up, and have run into an issue that I've encountered before, but do not understand the cause. Issue: With permalinks set to <code> /%postname%/ </code> , on a site with the following: Home page About page (slug: "about") Two links to categories (there are two categories...
I was going to make this a comment but it was getting long and I think I see an answer emerging. I'll gamble. If this is the problem URL: http://whoosh.acgdemo.com/swampism/ , you are seeing an attachment page <code> &lt;link rel='canonical' href='http://whoosh.acgdemo.com/?attachment_id=114' /&gt; </code> WordPress sh...
Post incorrectly displaying as page
wordpress
Should a plugin be able to add a widget area above the_content? (Without requiring template/theme changes.) What would be the best way to do this? Doubts: widgets typically echo output to the screen; the_content filter examples always return $content. The code below does something but seems flawed: testing indicated th...
Anyone see any problems? What you have done doesn't create a sidebar panel in the backend at wp-admin-> Widgets (I tested it) so you can't really use your sidebar like a widgetized sidebar anyway. You'd have to programmatically add widgets to your sidebar, but if you are going to be doing that why bother with the sideb...
Can / should a widget plugin define its own Widget Area?
wordpress
I created a table using the dbDelta function and then removed a few columns and added a few. The new columns did get created but the old columns did not get deleted from the table. Is there a different way I am supposed to delete columns from the table ?
As far as I know, <code> dbDelta() </code> is primarily used to add tables to the database. It can also add or alter columns. To delete columns, you should use <code> $wpdb-&gt;query() </code> : <code> global $wpdb; $table = $wpdb-&gt;prefix . 'table_name'; $wpdb-&gt;query( "ALTER TABLE $table DROP COLUMN column_name" ...
Does dbDelta delete columns as well?
wordpress
i need to translate an english wordpress installation to italian language,but i would like to mantain both languages en/english, so the user can choose which to turn on fron the frontend side. I need italian as default language and english for choice, i would like to know if is it possible to have them without re-insta...
Refer to the documentation for more details: http://codex.wordpress.org/Installing_WordPress_in_Your_Language Skip the first two steps and the backend won't be translated. 1) Download the Italian version of WordPress. 2) Upload the files located in <code> /wp-content/languages/ </code> to your live site. These files ar...
Language translation on a fresh english installation
wordpress
I am trying to print out a bulleted list of all posts in the current posts category (i.e. "siblings") except for the current post itself. I have been able to get the tags of the current bost and print out the list of all posts with the same tags as the current post using the following code. However, I was then trying t...
First things first, you have a syntax error: <code> $page_title = the_title(); </code> The <code> the_title() </code> template tag echoes , rather than returns , the post title. You will want to use <code> get_the_title() </code> instead: <code> $page_title = get_the_title(); </code> Second, you can simplify things con...
Get titles of all posts with current tags except current post
wordpress
I have a code in my functions file that I am using to generate a list of categories so that I can use isotope to filter the current page. However I need to know how to - How to make it a drop down and how to make the isotope script work with it? How to populate the drop down with the terms/child terms of the current ca...
Ok, I was able to get the drop down working. I was not able figure out my second question though- How to populate the drop down with the terms/child terms of the current category being viewed? Here's how I got the drop down to work - The drop down -- <code> &lt;?php $terms = get_terms("videoscategory"); $count = count(...
Isotope Drop Down Categories Filter Function
wordpress