question
stringlengths
0
34.8k
answer
stringlengths
0
28.3k
title
stringlengths
7
150
forum_tag
stringclasses
12 values
Is there a way to display the comment field first and then the Name / Email / Website fields? I am using <code> &lt;?php comment_form( ); ?&gt; </code> in my theme. I am not looking for a CSS solution.
Some loose implementation of where I would start. The hooks <code> 'comment_form_default_fields' </code> , <code> 'comment_form_defaults' </code> , and the <code> 'comment_form_{location}' </code> hooks look promising. Line 1569 of comment-template.php is doing the fields, and line 1575 is doing the main field, you mig...
Change order of comment fields
wordpress
I have tried multiple plug-ins for ads and for each page refresh they all count it as 3 impressions. Any idea why this is happening or how to fix it? Currently using the Ad Engine plugin, and already tried Simple Ads Manager. Using an Image. Example Code: <code> &lt;!doctype html&gt; &lt;!-- paulirish.com/2008/conditio...
NEVER NAME THINGS ANYTHING CLOSE TO NORMAL!!!! I can't believe this entire problem was from naming my widget area 'ads'...
Advertising: Every page refresh counts as 3 ad impressions
wordpress
I'd like to add some text above my category archives, and I'd like to use the built-in Wordpress TinyMCE editor to do it. I've seen some plugins like <code> black-studio-tinymce-widget </code> which does a nice job of adding rich text to a widget, but I'd like to set up TinyMce to be used in the description area of the...
Something like this looks ot be what you are after http://wordpress.org/extend/plugins/rich-text-tags/
How can I enable a TINYMCE rich text editor in the admin interface?
wordpress
Can someone please tell me how to get the correct url of the page the user is on? I need to grab the url and construct a new link. Here is the issue that I am having. For example, let's say I am on http://localhost/myplugin/samplepage/?some_var=1&amp;some_var=2 <code> home_url() is http://localhost/myplugin $_SERVER['R...
The built-in <code> redirect_canonical() </code> uses the following: <code> $requested_url = is_ssl() ? 'https://' : 'http://'; $requested_url .= $_SERVER['HTTP_HOST']; $requested_url .= $_SERVER['REQUEST_URI']; </code>
Correct way of getting the current page uri
wordpress
I've had an idea in my head about creating a Wordpress Multisite environment that would have Plugins along with them that would not only have "default" settings, but be able to update each blog's plugin options based on a "master" site. That way, instead of having to change settings through every site - you'd be able t...
http://wordpress.org/extend/plugins/wp-multisite-mirror/ or http://wordpress.org/extend/plugins/yd-wpmu-sitewide-options/
"Master" Wordpress Multisite - Database Sync
wordpress
My Emacs org-mode projects get exported to XHTML files. I would like to loosely integrate them into my blog. In particular, I'd like to use the header (and possibly footer) from my theme in the XHTML file. Would it be possible to put something like <code> &lt;?php include("../blog-wp-content/themes/my-theme/header.php"...
The key to answer was found on SO; here is the solution for my case: create a PHP file with the following: <code> &lt;?php define('WP_USE_THEMES', false); require('path/to/your-wordpress-dir/wp-blog-header.php'); get_header(); ?&gt; //Contents of the body of your XHTML page go here &lt;?php get_footer(); ?&gt; </code> ...
Insert the current theme header into an external HTML/XHTML file
wordpress
I am trying to disable the tinyMCEeditor in wordpress so it is <code> readonly </code> if the post has already been published. I already have the logic for determining if the post is published (by using <code> $post </code> object's <code> post_status </code> variable)but I have not found a solution for setting the <co...
You can hook into <code> tiny_mce_before_init </code> to modify the TinyMCE arguments to set the <code> readonly </code> attribute. For example (using PHP 5.3): <code> add_filter( 'tiny_mce_before_init', function( $args ) { // do you existing check for published here if ( 1 == 1 ) $args['readonly'] = 1; return $args; }...
Set Wordpress TinyMCE Editor To Readonly
wordpress
I have on many occasions used <code> wp_enqueue_script </code> to pass some 'query variables' to scripts like this: <code> function my_enqueue_scripts(){ $tempurl = urlencode( get_bloginfo( 'template_url' ) ); wp_register_script( 'somescript', get_bloginfo( 'template_url' ) . '/js/somescript.php?url=' . $tempurl ); wp_...
<code> wp_localize_script </code> is the “WordPress way” to pass data from php to javascript. See this post by Otto for more info.
Is it recommended to pass some data to scripts in `wp_enqueue_scripts`?
wordpress
I'm trying to add a class to a container within a query, ideally I'd like to use the terms from a custom taxonomy I have setup (guide-categories). As an example: <code> &lt;div class="myclass *taxonomy term*"&gt; -content- &lt;/div&gt; </code> Any help would be much appreciated, been looking around trying to find out h...
You could do something like this <code> &lt;?php $terms = get_the_terms( $post-&gt;ID, 'taxonomy_name' ); ?&gt; &lt;div class="myclass&lt;?php foreach( $terms as $term ) echo ' ' . $term-&gt;slug; ?&gt;"&gt; &lt;!-- content --&gt; &lt;/div&gt; </code> http://codex.wordpress.org/Function_Reference/get_the_terms
Custom taxonomy term as class?
wordpress
EDIT: Reworded the question for more clarity I'm trying to sort by custom meta box data, which I am converting to a date using the <code> strtotime </code> function, but I'm having some difficulty. My chief problem seems to be a catch-22 with the <code> strtotime </code> function. If I use <code> strtotime </code> insi...
EDIT: Your problem is this: When you save your meta data, you want the date to be saved as a <code> strtotime() </code> date, but you want it to display the date back in the old <code> Y-m-d </code> format. What you need to do is save it as <code> strtotime() </code> and then when displaying the text back in the input,...
Sorting a query by custom field date
wordpress
I know that I can require all of the comments on my site to be moderated, but is there a way of forcing moderation for a specific custom post type (i.e. my CPT "species") whilst allowing instantaneous comments across the rest of the site? Thanks in advance,
Yes, this is possible. Comment moderation is an option, and is retrieved like any other option: <code> get_option('comment_moderation'); </code> the get_option function applies a filter before returning the value... <code> return apply_filters( 'option_' . $option, maybe_unserialize( $value ) ); </code> So what you'll ...
Comment moderation on custom post types
wordpress
Is there a plugin that works to be a marathon running event management tool? I need things like ways to accept registrations, payments, and displaying the results when the event is over.
I find it difficult for you to find a plugin SPECIFIC for marathon, but you can check out some "normal" event managers like : http://wordpress.org/extend/plugins/advanced-events-registration/ or http://wp-events-plugin.com/events-manager-pro/ http://wordpress.org/extend/plugins/events-manager/
Plugin for Marathon Running Event Management
wordpress
I am building a "podcast" post type in a wordpress build using custom-post-types, meta-boxes &amp; taxonomies. There may be a simpler way to do this.. I'm still learning and this is my first go at it. Either way, I'm almost finished, but I want to add some functionality that will help my client (make it easier to use)....
You should save the date in a format that is unambiguous so you will get predictable results. The particular format you prefer can't be parsed by strtotime because it's not clear which is the month, day, and year. If you convert the date when the meta data is saved, the contents of the field will change to that format ...
Using 'strtotime' function to convert a custom-meta-box to a date-stamp
wordpress
I am using the Jeditable plugin to enable inline editing on a table inside the admin area, generated by a small plugin I've written. (http://www.appelsiini.net/projects/jeditable). Basically everything is working, but only as long as the code for updating the database field is inside the plugin's code. As soon as I cop...
I think you will need to include some type of WP core file into the <code> save.php </code> file (I could be wrong). Since this file isn't being called specifically by your plugin (or WP for that matter), it won't have all of the variables that WP has to offer. Try adding this to the top of your <code> save.php </code>...
Jeditable Plugin working as it should - scope issue?
wordpress
I have several cron jobs all hooked to the same hook, but each with a different argument (a post ID). It appears <code> wp_clear_scheduled_hook </code> only clears job which match the argument passed with it (or jobs without any arguments, if no argument is provided). Is there a way to delete all the cron jobs associat...
I have just quickly wrote the below function, it will clear all crons for the specified hook, irrespective of the cron time and the hook argument. NOTE: I have NOT TESTED the function, so please don't run it on your live site. <code> function wpse39681_clear_all_crons( $hook ) { $crons = _get_cron_array(); if ( empty( ...
Delete all scheduled events with a particular hook
wordpress
I have the following code which should add a last class to the fourth post but doesn't appear to be, what is wrong with this coding? It show's 4 posts fine but the fourth one doesn't have the class last attached to it. <code> &lt;div class="headline-strip"&gt; &lt;ul&gt; &lt;?php if (have_posts()) : while (have_posts()...
<code> $count = 1; </code> is set in the while loop, so every time the loop runs it sets to 1 again. Place it before your loop and it will work. <code> $count = 1; if (have_posts()) : while (have_posts()) : the_post(); </code> Ow and the $count++ is outside the loop so it will only run after all the posts. Change that ...
Last class on last headline?
wordpress
I've been combing this site and google for the answer and I've come up completely empty. Basically I want to do exactly what stackexchange-url ("this post") asks, but I need a hierarchical taxonomy. The answer given in that post works great, but only with a single level taxonomy. Is it possible to do what I want? I've ...
After combining a bunch of pieces of other answers I got it working! So here's the solution for those of you who are struggling with this too: stackexchange-url ("This post") and stackexchange-url ("this one") helped me out some, so thanks to those guys. Note, all this code, plus your initial custom post type and taxon...
How to create a permalink structure with custom taxonomies and custom post types like base-name/parent-tax/child-tax/custom-post-type-name
wordpress
I have a page on my site that has customer testimonials. Each testimonial is a custom post. I want to order the testimonials arbitrarily. What's the best way to do this?
The way I previously did this, was by adding a custom field to my CPTs, and ordering by that value when I fetched my posts with WP_Query. <code> $myquery = new WP_Query( array( 'post_type' =&gt; 'your_post_type', 'meta_key' =&gt; 'my_custom_field_name', 'orderby' =&gt; 'meta_value' ) ); </code> However, I believe if yo...
Ordering custom posts
wordpress
When I register the taxonomy I have this which I thought might hide it: <code> 'show_tagcloud' =&gt; false </code> The default category page does not show a tag cloud so why does my custom taxonomy page, how do I disable it? <code> register_taxonomy('gmc_region', 'recipe', array( 'labels' =&gt; array( 'name' =&gt; _x( ...
A bit late but I just learned how to remove the taxonomy cloud. In your taxonomy label definition change this line <code> 'popular_items' =&gt; __( 'Popular Regions' ), </code> to this <code> 'popular_items' =&gt; NULL, </code> and the tag cloud will no longer appear
How to remove the tag cloud from custom taxonomy admin page?
wordpress
I've been struggling with this for a while now and need some help. I'm trying to create a quite specific navigation setup for a client. I have a top level navigation which is hard coded and not a problem. The second level of navigation should populate the left sidebar of the site, it should also show a third level of n...
Took a decent amount of tinkering, but I came up with something workable based around absolute positioning, I did not apply any hover actions, those should be relatively easy for you to do (don't forget to z-index). Here's the CSS I would use: <code> #m { list-style: none; } #m &gt; li { padding: 15px; float: left; } #...
Advanced Multi Tier Navigation across columns
wordpress
I am using a plugin to create custom fields in the user registration. I have created a check box field called g300 which is the name of the meta_key stored in wp_usermeta. It looks like the value in the database is a comma when the checked it off. How could I return a list of users that checked off this box?
I haven't touched user functions so far, but according to the codex, should look something like this. <code> $args = array( 'meta_key' =&gt; 'g300', 'meta_value' =&gt; ',' ); $users = get_users( $args ); </code> EDIT This assumes that all the users with the field unchecked have a comma value ( for example, it won't wor...
query usermeta from custom field
wordpress
I am using the <code> *_add_form_fields </code> action to add fields to a custom taxonomy. One of those fields is a wp_editor(). The problem I am facing is that when I output the WordPress editor on the page like so: <code> wp_editor('test', 'mydescription', array('textarea_name' =&gt; 'my_description')); </code> and t...
tinyMCE textarea is initially unseen by the used serialize function: <code> $.post(ajaxurl, $('#addtag').serialize(), function(r){ .... </code> you will need to call tinyMCE.triggerSave() to make it 'visible' a simple script with: <code> jQuery('#submit').mousedown( function() { tinyMCE.triggerSave(); }); </code> shoul...
wp_editor textarea value not updating
wordpress
I am following "Write your own plugin tutorial" and I made it, activated it, added it to settings to have it's own plugin page but upon trying to access that plugin page I get above message saying that "I do not have sufficient permissions to access this page" even though I am logged in as admin and I did <code> chmod ...
<code> add_options_page("OSCommerce Product Display", "OSCommerce Product Display", 1, "OSCommerce Product Display", "oscimp_admin"); </code> should be <code> add_options_page( 'OSCommerce Product Display', 'OSCommerce Product Display', 'administrator', 'os_commerce_display_main', 'oscimp_admin' ); </code> Solution is ...
"You do not have sufficient permissions to access this page" upon accessing my newly created plugin page
wordpress
I'm trying to create a page which display a few of sub pages (child pages), however if the page has not child I would like to display a message. I cannot get a query that allow me to do something like this: <code> if (Page has childs) { do this } else { display this } </code> Any help? Thanks in advanced
<code> $args = array( 'post_status' =&gt; 'publish', 'post_parent' =&gt; $post_id ); $children = get_posts( $args ); if( count( $children ) &gt; 0 ) { //has children } else { //does not have children } </code> Docs: <code> get_posts() </code> This should also allow you to have access to the data of the children, should...
query if page has not child
wordpress
I am making sidebars for my theme using the register sidebar function. The codex does it something like this <code> if ( function_exists('register_sidebar') ) register_sidebar(array( 'name' =&gt; 'Right Sidebar', 'id' =&gt; 'right-sidebar', 'before_widget' =&gt; '&lt;li id="%1$s" class="widget %2$s"&gt;', 'after_widget...
<code> dynamic_sidebar() </code> does not output a <code> &lt;ul&gt; </code> , so what your code should look like is as follows: <code> &lt;div id="sidebar"&gt; &lt;?php dynamic_sidebar(); ?&gt; &lt;/div&gt; </code> and that, along with <code> &lt;div&gt; </code> tags in before_widget and after_widget, will give you ne...
Register sidebar 'before' and 'after' html as div rather than li tags
wordpress
Is there a method of doing this? Can I use PHP to say <code> if(URL=page/2/) { } </code> or something like that within my template? Essentially, I want an ad to appear in my sidebar when a user clicks 'Older Entries' and Wordpress directs them to "myblog.com/page/2/". I'm pretty sure I know how to accomplish this with ...
PHP has the <code> $_SERVER[] </code> variable, you can use this to get just about anything contained in the URL, you'll probably want to look at <code> PATH_INFO </code> as a launching point. You can use <code> strpos() </code> (or, if you want to have better results, <code> preg_match() </code> ) to check whether or ...
Custom /Page/2/ Template Only
wordpress
My navigation bar of my wordpress theme is set up to wp_list_pages. I'd like to display text underneath those page links. Like: Home "Home Sweet Home" Do I need a widget to accomplish this or is it relatively simple to implement?
Yes, but you need to use a custom walker. You must modify the function that traverse the page and output the HTML. Extend the basic wordpress class and implement your function. See stackexchange-url ("this stackechange post") for a code example. Note: I suggest you to use wp_nav_menu (custom menus) instead of wp_list_p...
Custom Text Under Navigation Links
wordpress
With the default wp_link_pages the current/active page number is not a link. I would like to find a code/hack which turns the current/active page into a link to the top of the page. I am already using a custom code for wp_link_pages which can be found below: <code> &lt;?php wp_link_pages(array( 'before' =&gt; '&lt;p cl...
Doesn't look like there are proper hooks to modify the output as per your requirements. But you could write a function similar to <code> wp_link_pages() </code> and call that in your theme. The following function would do your trick. <code> function custom_link_pages($args = '') { $defaults = array( 'before' =&gt; '&lt...
Make Current/Active Page Number a Link (WP_LINK_PAGES)
wordpress
My ht access includes: <code> Options +FollowSymLinks RewriteEngine on RewriteCond %{REQUEST_URI} ^/preview/(.*)\-[0-9]+$ RewriteRule ^/preview/(.*)\-[0-9]+$ /$1 [R=301,L] </code> but still when I try to access something such as: http://sg.wyli.co.uk/preview/coronation-street-the-mystery-of-the-missing-hotpot-recipe-18...
Sooo the problem was my brackets around the content in the condition I think. I'm still not so hot on these things, but I use these rules and they work: <code> RewriteCond %{REQUEST_URI} ^/(review|preview|feature).*\-[0-9]+$ RewriteRule ^review/(.*)\-[0-9]+$ /$1 [R=301,L] RewriteRule ^preview/(.*)\-[0-9]+$ /$1 [R=301,L...
why doesn't my rewrite rule work? (is there something weird with wordpress htaccess?)
wordpress
I use the Foliopress WYSIWYG editor . I inserted overview-1.png via the 'Quick Insert Image' option. This added the following mark-up: <code> &lt;img width="166" height="263" alt="overview 1" src="images/2012/01/overview-1.png" /&gt; </code> The width and height attributes are correct yet the editor can't find the src....
A base-Element in the front-end's header was the reason, why it worked in the fe but not in the editor.
Foliopress WYSIWYG editor does not display images
wordpress
I've got three loops set up via jQuery UI tabs as seen in my code below. All works good but i'd like to be able to display the "count" of each loop in the tab label. I obviously can't just echo it because it's before the loop is even called and outside of it. Any suggestions? Maybe call the loops before and put each on...
You would have to perform the query for each respective tab. If you are using WP_Query then you can perform the query and then use <code> $found_posts </code> to return the total number of posts matching that query. For instance, <code> $query_tab_1 = new WP_Query($args); //Where $args is some arguments for your query ...
Loop info in jquery Tabs - loop into a variable?
wordpress
I am trying to stop latest blog items from displaying in the blog section of my site. I have used the following code: <code> &lt;?php if ( is_page('blog') ) { ?&gt; &lt;h2&gt;Don't display anything&lt;/h2&gt; &lt;?php } /* for all other pages */ else { ?&gt; &lt;h2&gt;Display blog&lt;/h2&gt; &lt;?php } ?&gt; </code> Ho...
Assuming that the <code> 'blog' </code> slug is correct, your code would work. I would suggest making a separate template for the page, namely page-blog.php (see http://codex.wordpress.org/images/1/18/Template_Hierarchy.png and http://codex.wordpress.org/Template_Hierarchy ) where you set up the structure and appearanc...
Don't display a sidebar widget when on a specific page
wordpress
I have a site where I display the same exact footer on every page. There is one exception, though. On one certain page I need to change one small part of the footer. I figure the simplest way to do this is to check, within the footer, whether I'm on that page or not. It wouldn't make sense to change the whole entire fo...
It sounds like you are altering the global <code> $post </code> data somewhere (usually another loop). Be sure to call <code> wp_reset_postdata() </code> after you are finished with something that sets up post data in an alternate loop.
$post-> ID and the_id() always return the wrong value
wordpress
I want my taxonomy pages have some custom text and an image before the list of posts and excerpts. I need it for a personal travel blog. I have a "travel" taxonomy that keeps all travels I've made ("egypt", "china", "italy"...) and now I want to show some introductory text before te list of post related to this travel ...
Use the description field and the plugin Taxonomy Images from stackexchange-url ("@mfields").
Text and image in taxonomy page
wordpress
Managing my Wordpress installation with Git is great. I get to deploy fixes via command line (with Capistrano), easy rollback plan, the Theme folder is a standalone project added as a submodule -- This seems like a good way to handle Wordpress' and its plugins rapid updates. However, Source Control is not right for han...
Would some form of this solution work? Capistrano: Managing an uploads folder describes a way to update the symlink when deploying so you don't lose the uploads folder.
How to manage a standalone media folder?
wordpress
I am using the Latest News plugin (made by James Piggot, plugin website is here ) and I have inserted code that displays 5 of the latest news items in the sidebar area. It's working fine, and displays all I need it to display. However, I want to be able to display the first few lines of the news article with a "Read Mo...
If you go into your /wp-content/plugins directory, and edit the <code> latest-news.php </code> file, on line 85 change: <code> &lt;?php the_content('read more...');?&gt; </code> ... to: <code> &lt;?php the_excerpt('read more...');?&gt; </code> Note that modifying plugins is risky, because if you do an automatic update ...
Limit the amount of words displayed by the Latest News plugin, or recommend an alternative
wordpress
I'm a wordpress noob tweaking a theme, so I'm trying to understand how it works. I've read about 10 related posts in SE but don't get it yet. My problem is as follows: header.php seems to generate the menu with, <code> &lt;?php wp_nav_menu(array('theme_location' =&gt; 'nav-menu','container' =&gt; 'div', 'container_clas...
To get this to work you need to go to the menu admin and on the pages section click the tab that says 'view all' . At the top of the list is a special option for your home page, whether it's the normal blog view or a specific page. Add that to the menu and you're good.
When at / ( or "home") my menu doesn't get a current-menu-item class
wordpress
Is it possible (and if so, how) to configure WordPress blog to support these feature for user comments? I want to use built-in comments, not 3rd party services like Disqus. If something cannot be achieved by configuring WordPress itself please suggest plugins that can achieve the following: 1 + 2) Every user that would...
1+2. what about the janrain engage plugin: http://wordpress.org/extend/plugins/rpx/ 3. subscribe to comments plugin mentioned by @chip bennet 4. chris pearson discusses flat, but referenced comments : http://www.pearsonified.com/2007/11/professional_stylish_comments_for_blogs.php i'm not aware of any automated way to i...
How to configure WordPress + plugins to support these commenting features
wordpress
I'm trying to create a function that would allow me to change the title of an established meta box (i.e, change Meta Box title 'Authors' to 'Team', etc.) I didn't want to use JS or have to unset the original meta box and re-add it. I started off with the following as per another thread that listed the code like so: <co...
Improved Answer I've decided to revisit this question after realising how unnecesarily hacky it is. The the best solution is to to remove the metabox, and then re-add it, specifying an alternative title. Here's an example for the post post-type. <code> add_action( 'add_meta_boxes_post', 'wpse39446_add_meta_boxes' ); fu...
Change The Title Of a Meta Box
wordpress
So I am currently running a multisite install where the super admin creates all new sites. One of the templates we're using has a blog page for a loan officer. I am extending the user profile so the new user can input critical data that needs to be displayed on their page. There is only one user per site, in addition t...
Not sure how this would differ with multi-site, but this is how you'd do this outside the loop normally: <code> &lt;?php # get post data $temp_post = get_post($post_id); # grab the author meta $user_id = $temp_post-&gt;post_author; # grab the field you're looking for $first_name = get_the_author_meta('first_name',$user...
Getting $user_id for the_author_meta outside the loop in multisite
wordpress
After following the guide for stackexchange-url ("How can I prevent uploading bmp image?") to remove bmp (and in my case tiff images) from being uploaded, I tested and it is working, but noticed users are now getting the error message: <code> Sorry, this file type is not permitted for security reasons. </code> That loo...
This is untested, but I think you can just define wp_handle_upload_error in your functions.php file and return custom error messages. If you look at where that function is defined in that file, <code> if ( ! function_exists( 'wp_handle_upload_error' ) ) { function wp_handle_upload_error( &amp;$file, $message ) { return...
How can I customize the upload error message in Wordpress?
wordpress
I cannot get a cookie to set properly through WordPress theme. I am putting the following code on the bottom of my <code> functions.php </code> page for my theme. <code> function set_cookie() { if (isset($_GET['id'])) { $referrerID = $_GET['id']; setcookie('referrerid', $referrerID,time()+ 3600 * 24, COOKIEPATH, COOKIE...
Make sure the HTTP headers are not sent already at the point you want to set the cookie. Here's how you can test that: <code> function set_cookie() { var_dump(headers_sent()); // should be bool(false) ... </code> Turning <code> WP_DEBUG </code> on in your config.php file may help also while debugging. By the way, you r...
SetCookie simply not working
wordpress
When save post, I made dir in wp_uploads_dir, and copied 2 files and one folder in this dir. Now I want to do the WP_insert_attatchment process to make the 2 files as attachements. How can I do it? Edit: I inset_attatchement by directly using their URL. Now they show up in Media Libray, but I can't see whether the atta...
You need the local path to add an attachment: <code> // add the file to the media library $attachment = array( 'post_mime_type' =&gt; 'image/png' // the MIME type , 'post_title' =&gt; 'Attachment title' ); // Adds the file to the media library and generates the thumbnails. $attach_id = wp_insert_attachment( $attachment...
How to add attachment without uploading?
wordpress
For various reasons, I can't use Wordpress' built-in Thumbnail functionality. What I want to do instead is to use the first image in the post as the thumbnail. Here's what I found in the codex: Show the first image associated with the post . However, the problem with that is that if the post has multiple images, but th...
I decided to use this, which is based on @AndresYanez's answer: <code> function get_image_id_by_link($link) { global $wpdb; $link = preg_replace('/-\d+x\d+(?=\.(jpg|jpeg|png|gif)$)/i', '', $link); return $wpdb-&gt;get_var("SELECT ID FROM {$wpdb-&gt;posts} WHERE BINARY guid='$link'"); } </code> This is much more succinc...
How can I get a different image size, if all I have is the link?
wordpress
I want to publish about 1GB of photos on my Wordpress-powered website. I want viewers to load the photos quickly, but also tobe able to download high-resolution versions. Here is what I have tried. 1) Using NextGen: This seems great, but when huge photos are uploaded, NextGen does not automatically shrink them, making ...
I don't understand the problem with NextGen. For a "gallery page" it creates thumbernails which are small (in fact as you can set the size up as you want it). The same goes for opening images themselves - you can set up the resize option for the full size size of images. Example - it means that if you upload a 5000x500...
What is a good way to implement photo galleries on Wordpress?
wordpress
Let's say for example: I have a custom taxonomy called "fruit", which has 3 terms "apple", "orange", and "grape". So in order to get all the posts within all these three terms, I would : <code> $args = array( 'post_per_page' =&gt; '-1', 'tax_query' =&gt; array( array( 'taxonomy' =&gt; 'fruit', 'field' =&gt; 'slug', 'te...
Here is how you can group your post listing based on their terms. First you need to add the following code to your functions.php <code> // join the term_taxonomy table so we can get the term id with the post add_filter( 'posts_join_paged', 'wpse39380_posts_join', 10, 2 ); function wpse39380_posts_join( $join, $query ) ...
Custom loop with conditional statement to separate each terms
wordpress
WP 3.2.1 I'm in a bit of a bind. I have to create some pagination for the blog, but I believe I'm running into the bug described here , and I don't have authorization to fiddle with the server's <code> php.ini </code> file. So, I need to find a way to create pagination for the blog without having max_num_pages. Is that...
Try: <code> ini_set( 'mysql.trace_mode', 0 ); </code> … in your <code> functions.php </code> . Maybe an .htaccess entry … <code> php_value mysql.trace_mode 0 </code> … works too. I haven’t tested it.
Blog pagination WITHOUT using max_num_pages
wordpress
WP 3.2.1 Changing the max number of posts to show on each page via Settings-> Reading isn't working. Could this reported bug be the culprit?
If it doesn't work then there must be some problem or overwrite in your custom theme, add this code in your index.php or where ever you want to show the custom number of posts, <code> query_posts( $query_string . '&amp;posts_per_page=1' ); </code> change '1' to any number you want
Changing max number of blog posts per page doesn't work
wordpress
I've used almost all of the Wordpress example code but it still doesn't work. I've put the php file under wp-content/plugins/menuitem/ .The code is simple <code> &lt;?php add_action('admin_menu', 'donations_overview_menu'); function donations_overview_menu() { add_options_page('Donations overview', 'Donations overview'...
The code itself is fine. But you would need to activate the plug-in: you can't simply place the file in the plug-ins directory. You will need to give the plug-in a 'header' too. See the Codex . Alternatively, place the code in your theme's functions.php, but really it should be in a plug-in.
How can I add a menu item to the admin area?
wordpress
I have a WordPress Network install with the individual sites installed on subdomains. example.com a.example.com b.example.com I would now like to launch a blog on each of the sites. It'd like the blog to be situated in a <code> /blog </code> sub-directory of each of the subdomains, but as the blogs would be completely ...
I've finally solved it by installing a separate WordPress instance in the /blog folder. Both the root and the /blog are Network subdomain installs. Surprisingly enough this works without any conflicts and I didn't even need the Multi Network plugin.
Sub-directory blog on a sub-domain WordPress network site
wordpress
How can I remove the admin bar in both the front and backend for all users in WordPress 3.3?
<code> /* Front end */ show_admin_bar( false ); /* back end */ function disableAdminBar(){ remove_action( 'admin_footer', 'wp_admin_bar_render', 1000 ); function remove_admin_bar_style_backend() { echo '&lt;style&gt;body.admin-bar #wpcontent, body.admin-bar #adminmenu { padding-top: 0px !important; }&lt;/style&gt;'; } ...
What code removes the admin bar for all users in WordPress 3.3?
wordpress
I have activated BuddyPress on a blog but the link <code> My Account </code> on the admin bar is broken. I have configured BuddyPress to auto create pages but still the problem persists. I have been searching Google for two days now. Please help. Thanks
Buddypress requires pretty permalinks to function properly. If you have set them up already try to go to the permalinks admin page and resave them and see if that helps. If your host won't let wordpress write to an .htaccess file, that page will also show you what should be in it. http://codex.buddypress.org/troublesho...
BuddyPress admin bar links are broken
wordpress
If I go to wp-admin/edit-tags.php?taxonomy=location then I correctly see a list of terms. If I loop through: <code> get_terms("category"); </code> Then I correctly see several terms for the taxonomy of category. Have I created my custom taxonomy incorrectly for the same function not to output any results for my taxonom...
If you are trying to use all of the terms in that taxonomy for something, try this: <code> get_terms( "location", array( "hide_empty" =&gt; 0 ) ); </code> You may be trying to return taxonomy terms that have no relationship to any object.
get_terms does not return any results for my custom taxonomy?
wordpress
Is there a way I can add a custom title &amp; subtitle to this shortcode function? <code> function spoiler( $atts, $content = null ) { return '&lt;div class="moreinfo"&gt; &lt;h3 class="click drop subtitle"&gt; &lt;!-- title &amp; subtitle go here --&gt; &lt;/h3&gt; &lt;div class="morecontent"&gt;&lt;p&gt;' . $content ...
<code> function spoiler( $atts, $content = NULL ) { extract( shortcode_atts( array( 'title' =&gt; 'default title', 'subtitle' =&gt; 'default subtitle', ), $atts ) ); return '&lt;div class="moreinfo"&gt;&lt;h3 class="click drop subtitle"&gt;' .'Title:'.$title.'Subtitle:'.$subtitle. '&lt;/h3&gt;&lt;div class="morecontent...
Add title & subtitle to shortcodes
wordpress
Trying to use paging in one of my Wordpress site but seems it is not working.for paging i am using SEO Pager Plugin. here is my code <code> $params = get_query_var('args'); $ppp = get_option('posts_per_page'); if (!is_paged()) { $custom_offset = 0; } else { $custom_offset = $ppp*($paged-1); } $args = array( 'meta_key' ...
@user702325 Here's how i got it working fine on localhost: I installed the plugin and set the option Place Pager Automatically in Template on " on ". Then in author.php i modified the original query to add some custom parameters. I added this: <code> global $query_string; // required $posts = query_posts('posts_per_pag...
get_posts() method and paging is not working
wordpress
I want to modify $path in the following filter. It has 1 input and 2 args. <code> function documents_template( $template = '' ) { $path = DOCUMENTS_INCLUDES_DIR . '/document/' . $template; return apply_filters( 'document_template', $path, $template ); } </code> This is my function to add filter, it gets error message, ...
<code> function my_locate_template( $path, $template ){ $path = MY_INCLUDES_DIR . '/document/'. $template; return $path; } add_filter( 'documents_template','my_locate_template', 10, 2 ); </code> add_filter takes 4 variables. The first and second are required. 1. name of the filter, 2. name of the function. The third is...
How to add filter with 2 args?
wordpress
Well I'm here again with almost the same problem as I had in stackexchange-url ("this post three weeks ago"), but let me explain what has happened since then: I was originally using one loop to display the most recent sticky post at the top of the front page, then a second loop to display every other post (except for a...
I see a few issues that are probably contributing to your issue: Only ever use <code> query_posts() </code> to modify the primary Loop. The <code> caller_get_posts </code> parameter has been deprecated , in favor of <code> ignore_sticky_posts </code> The <code> $wp_query </code> variable is a defined global. Using it o...
Broken pagination
wordpress
I run a multi-user site and for the past week or two I have been getting daily notices that someone is getting locked out due to failed login attempts for user "admin" via the Limit Login Attempts plugin. There is no user account for "admin" and I assume this is an attack in an attempt to gain access to the wp-admin se...
Yes, you can safely ignore it, especially if your site has no "admin" user. The brute-force attack will never accomplish anything. I also use Limit Login Attempts - mainly for this very purpose. It lets me know when manual brute-force attempts are being made on my back-end login. (Last time I bothered to WHOIS the IP, ...
Daily notices of failed login attempts for non-existent admin user
wordpress
I want to show the latest blog post content in my side bar with a read more link. So how will I do this?
Use <code> get_posts() </code> and set <code> 'numberposts' </code> to <code> 1 </code> . The first and only entry will contain your latest blog post as a post object.
how to show content of latest blog post with read more link?
wordpress
I'm looking to use the jQuery TreeView script on wp_list_pages to get a nice collapsable-tree effect going. The script requires that I add some classes to the list elements such as: <code> &lt;ul id="red" class="treeview-red"&gt; </code> So I tried putting this in my template: First, load scripts on my template page vi...
EDIT: After chatting with AlxVallejo, we came to a solution. Here's what we talked about: You were not properly using the <code> wp_enqueue_scripts </code> hook and the functions that go along with it, as I informed you these hooks and actions need to be done in <code> functions.php </code> . You also discovered yourse...
jQuery Tree View and wp_list_pages
wordpress
I have a multisite network where the super admins will be creating the individual sites. An important role we need to enable, for compliance reasons, is to restrict "Authors" to not be able to upload media, but be able to access the media library to choose from media that is uploaded by the super admin. I have download...
Just taking a rough stab at this... <code> add_filter('media_upload_tabs', 'modify_media_tabs'); function modify_media_tabs($tabs) { if (is_super_admin()) return $tabs; return array( 'type_url' =&gt; __('From URL'), 'gallery' =&gt; __('Gallery'), 'library' =&gt; __('Media Library') ); } add_filter('_upload_iframe_src',...
Restrict Author to pick from media library, but not upload media
wordpress
I'm wondering how I can show recent posts from the same taxonomy as the post that's currently being viewed (working with custom post types and custom taxonomies). If it was simply a category of a regular post, it would look like this: <code> &lt;?php global $post; $categories = get_the_category(); foreach ($categories ...
Have you tried using <code> get_the_terms() </code> ? Quick-and-dirty, from your code example: <code> &lt;?php global $post; $terms = get_the_terms( $post-&gt;ID, 'some-term' ); foreach ($terms as $category) : ?&gt; &lt;h3&gt;More News From This Category&lt;/h3&gt; &lt;ul&gt; &lt;?php $posts = get_posts('numberposts=20...
How can I show recent posts from same taxonomy as the post currently being viewed?
wordpress
Was trying to create author specific page with author specific URL and it was working fine,but when i created this URL did not taken in to account following 2 factors Author Name Conflict (similar name). Paging option to be added to author page (for his published posts) here is my initial rule <code> function add_my_ru...
<code> function add_my_rule() { global $wp; $wp-&gt;add_query_var('args'); $wp-&gt;add_query_var('arg_username'); add_rewrite_rule('writer/([0-9]+)/([^/]*)/page/([0-9]+)','index.php?pagename=writer&amp;args=$matches[1]&amp;arg_username=$matches[2]&amp;paged=$matches[3]','top'); add_rewrite_rule('writer/([0-9]+)/([^/]*)...
Add Rewrite Rule for custom page
wordpress
Is there a way I can edit / change the layout of the comments form (leave a reply form) in the TwentyEleven theme? I want to put the textarea on top and I can change the styles via css but physically moving the forms is where I'm having trouble. I'm not sure where to find the code for it. tl;dr Where's the comments for...
The comments template is added to template files via the <code> comments_template() </code> template tag. The <code> comments_template() </code> template tag includes the <code> comments.php </code> template-part file. The <code> comments.php </code> template-part file includes the comment-reply form via the <code> com...
Edit Comments Form in TwentyEleven
wordpress
My problems with my site continue. I got timeout errors initially. The server ground to a halt, very high memory use by Apache. Site came back with no pages. I found that deleting the most recent post in wp_posts brought the site back up. Sysadmin pointed out high cpu use by apache but this may be a red herring, the me...
To diagnose a load-intensive (either CPU cycles or memory) Plugin, start by deactivating all Plugins . Ensure that, with no Plugins active, you do not observe the same issues. If you observe the same issues with all Plugins deactivated, then the problem is somewhere else, either with your Theme, your database, or your ...
Memory issues - Fatal error: out of memory - plugins?
wordpress
Currently I'm having some difficulties with below snippet. As it currently works it shows <code> the_excerpt_rss </code> on a single post and single page. AND it shows the option on <code> is_home() </code> . But what if a page (instead of the 'blog') is the frontpage? If possible I'd like to include the option as well...
Try <code> if ( 'page' == get_option( 'show_on_front' ) ) {} </code> . Edit but I've tried adding and replacing <code> &lt;?php endwhile; endif; elseif (is_home()): ?&gt; </code> with both of your code. Could you perhaps include your snippet with mine? I'm not sure why you would do that. I was specifically answering th...
Showing option when page is frontpage
wordpress
There is any way of using the main site footer (blog id =1) on all the network sites. I want to have the same footer in all the network. On the main site i got a theme and the child sites created by users got another theme. Basically i want to use the same footer on both themes but manage all the widgets from just the ...
First of all, using the same <code> footer.php </code> file for multiple themes would be problematic, as different themes use different elements which need to be closed in this file. A better way would be to create a custom function that you call in every <code> footer.php </code> file. Such a function would be best pl...
Same footer on all multisites blogs
wordpress
I can do something like the following with a standard category: <code> $query-&gt;set('category__not_in', $term_id); </code> But how do I do the same with a custom taxonomy term? I'm using Wordpress 3.3.1 if it is relevant. Thank you. :)
For what it's worth, I just gave up on the '__not_in' approach and went with the following somewhat sneaky solution: <code> //Create the exclusion rule $new_tax_query = array( array( 'taxonomy' =&gt; 'x_category', 'field' =&gt; 'slug', 'terms' =&gt; array('y-slug'), 'operator' =&gt; 'NOT IN', ) ); //If there is already...
Can I use $query-> set() (in a pre_get_posts() hook) with a custom taxonomy in WP 3?
wordpress
Quick question here. I have a function that echoes out the post-type's content (if none available, the excerpt). It looks like this: <code> function era_excerpt($post, $length = 11, $ext = ' ..') { if(is_int($post)) { $post = get_post($post); } elseif(!is_object($post)) { return false; } if(has_excerpt($post-&gt;ID)) {...
Try removing the stripslashes() function.
Tags break custom Excerpt function
wordpress
One of my friends is going to launch a small article directory (ex: http://ezinearticles.com/ ) using WP. The site will be hosted on a shared hosting in the beginning and will be moved to a dedicated server in the future. The site will be open for public registration like any other article directory and each registered...
Wordpress is only as secure as you make it. Open registrations should not be a problem if you: Use CAPTCHA for registrations. Use double opt-in: have users verify their email after they register. By default, registered users must be subscribers and after they are verified, you can set them as authors. Wordpress users c...
Is Wordpress secure enough for a multi-user article directory?
wordpress
For instance if my plugin is creating a form on a page, what can I do to make it as easy as possible for theme developers to skin the form too?
First of all, provide a well-formed default HTML form . Use <code> &lt;label&gt; </code> , <code> &lt;fieldset&gt; </code> and <code> &lt;legend&gt; </code> where appropriate. This markup provides a good structure for CSS styling. Adding in some CSS classes may help too. Provide a filter that allows developers to tweak...
What is the correct way for a theme to support plugin UIs?
wordpress
I have been working with a client to redesign his site and we are at the stage where we are going live, except I'm running into a little problem. Time is of the essence, as the deadline is mid-day tomorrow. Since I began working on the site, he sent me a database of posts from the beginning of time up until September 1...
How can I get posts from 9/13/11 to today with SQL?
wordpress
You can use a variety of different comparison operators in meta queries, among which are <code> 'LIKE' </code> , <code> 'NOT LIKE' </code> , <code> 'IN' </code> , and <code> 'NOT IN' </code> . What is the difference in use between <code> LIKE </code> and <code> IN </code> ? Here's the relevant section of the WP Query C...
Meta queries are essentially wrapper for ease of setup, but end results is part of SQL query to run on MySQL database. These operators are those of MySQL, see in documentation: <code> LIKE </code> operator (performs pattern matching) <code> IN() </code> function (checks if value is in set)
Difference between 'LIKE' and 'IN' in meta queries
wordpress
I just inherited a site where the creator installed the Copperific Theme and then modified the source files to achieve customizations. My understanding of custom themes was that, in order to protect your modifications, you cloned the original theme and re-named it, housed it in its own theme folder etc. Is that correct...
In terms of dealing with the old developer's mess... I don't know. But if you want to make a child theme in order to protect your future changes from being wiped out from updates, it's easy: First create a new folder in wp-content/themes and call it whatever you want. Next create a file: style.css and place the followi...
Working with a modified WordPress & Theme and updating WordPress
wordpress
In a website I'm building (using my own designed theme, for a business site that doesn't have a blog, IOW, using WP for it's CMS), I have 5 templates: the homepage, the 404 page, the default (page.php), a small one-column and a large one-column. I use the default template for 6 pages in the site. That template is 2-col...
I misunderstood how the plugin worked. I can use one "block" call in a template and it shows different content from different pages. Do NOT need a different block for every page. MY BAD.
How properly write function to filter content in a template for plugin "multiple content blocks"
wordpress
I am trying to achieve a similar look to the image below, a working example can be found here: http://www.menshealth.com/celebrity-fitness/mark-wahlberg-fighter-workout The needed code must do the following (some of my questions have been answered, but these remain): Turn the non-linked active/current page number into ...
Your pagination links are wrapped in with this tag <code> &lt;p class="pagelinks"&gt; </code> so giving them all the same spacing is easy using CSS like so: <code> .pagelinks a { margin: 0 5px !important; } /* override other defined margins */ </code> maybe you want them all centered on the page too: <code> .pagelinks ...
Making a Killer wp_link_pages
wordpress
I'm building my friends blog and he asked me a rather odd request. He wants the latest five blog posts to be visible to non-registered members but not to others. I'm using s2Member for membership handling. My Initial attempt was just limiting the number of blog posts to 5 and hiding the pagination button based on if so...
Before the start of your loop on single.php, add this code to check the current post against the fifth most recent post date. If the current post is more recent than fifth, show the post, and if older, show a message that has to do with being loggedin/a member. <code> global $post; $tmp_post = $post; // Retain current ...
Restricting certain blog posts by date?
wordpress
I'm using the superfish dropdown menu to create a drop down menu. It's created the menu fine showing all the parent pages with the child pages in drop down's below. The only problem I have is that the parent pages are by <code> menu_order </code> which is what I want but the child pages are not by <code> menu_order </c...
I downloaded this plugin and took a look and it does work as advertised for me. The function it uses for displaying the page list is: <code> wp_list_pages(array( 'sort_column'=&gt;'menu_order', 'depth'=&gt;'4', 'title_li'=&gt;'', 'exclude'=&gt;$exclude )); ?&gt; </code> Which is very straightforward and does very expli...
Show child pages by menu order using Superfish Dropdown menu?
wordpress
As you can see in my next/previous link I have an extra space before the word "Previous" and I can't seem to find it. Any help is greatly appreciated: http://themeforward.com/demo2/?p=1813&amp;page=2 Custom function: <code> // Custom Next/Previous Page add_filter('wp_link_pages_args', 'wp_link_pages_args_prevnext_add')...
Ok, well it turns out it has more to do with WordPress then we realised. The <code> wp_link_pages </code> function, in which the hook being used in the question resides, is the culprit rather than anything you've done. If you want to have a look, the function is in the post-template.php file inside the wp-includes dire...
Unable to Find Space in Custom Function
wordpress
Alright, so first, I need you to check out this wire-frame so you can see what I'm trying to accomplish: Wire-frame What I've done so far is this: I created a custom post type for individual addresses. I created a hierarchical custom taxonomy where the "parent categories" are States, and the "child categories" are Citi...
Are you familiar with jQuery? You'll want to post the term to a admin-ajax, and use the response to populate the second select. Here is the codex documentation: http://codex.wordpress.org/AJAX_in_Plugins A loose example for your situation: <code> $first_term = $('#states'); $name = $first_term.children('option:selected...
How can I populate a select element with terms from a custom taxonomy and filter post results?
wordpress
I get this error when I enter data in my form Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING in \functions.php on line 77 <code> return '&lt;span class="vwbx"&gt;Views&lt;/span&gt;''&lt;span class="vwbx"&gt;$count.&lt;/span&gt;'; </code> ==== Whole function=== <code> function getPostViews($postID){ $c...
The problem is that you have two strings that aren't actually being appended together. Try replacing <code> return $count. '&lt;span class="vwbx"&gt;Views&lt;/span&gt;''&lt;span class="vwbx"&gt;views&lt;/span&gt;'; </code> With <code> return $count. '&lt;span class="vwbx"&gt;Views&lt;/span&gt;'.'&lt;span class="vwbx"&g...
Parse error: syntax error, unexpected
wordpress
I've been looking through the plugins to find one that will allow the user to resize &amp; crop images within WP. This has been the one area that clients struggle with - mainly those who don't have any photo editing software on their computers. Also, if there's one that deals with some kind of image compression options...
WordPress has cropping and resizing and rotation built in. Tutorial: http://www.wpbeginner.com/beginners-guide/how-to-crop-rotate-scale-and-flip-images-in-wordpress/
Image crop, resize and compression plugin?
wordpress
I'm sure this must be something simple, but I can't for the life of me work out why this isn't working. <code> if (!class_exists('FeaturedItem')) : class FeaturedItem { var $plugin_url; function FeaturedItem() { $this-&gt;plugin_url = trailingslashit(plugins_url('sf-featured-items')); } function enqueue_scripts() { /* ...
OK, this was actually a problem with another plugin. When using more than one Custom Post Type and the <code> save_post </code> action, a <code> wp_nonce </code> should be used to verify which plugin the action is actually coming from. Without this, all of my CPTs were trying to fire this CPT's <code> save_post </code>...
Custom post type - update_meta not working
wordpress
My Question is almost similar to stackexchange-url ("author-specific-urls-in-wordpress") and stackexchange-url ("mapping-multiple-urls-to-same-page-in-wordpress"). And i have followed the following steps Created a custom page (writer.php) Associated that page from dashboard since all the writer are not being registered...
Your example works if I delete the newline. So this should work: <code> function add_my_rule() { add_rewrite_tag("%args%", '([^/]*)', 'args='); add_rewrite_rule('writer/([^/]*)','index.php?pagename=writer&amp;args=$matches[1]','top'); } add_action('init', 'add_my_rule'); </code>
Creating author Specific page URL
wordpress
I was looking for a solution to exclude the featured image/thumbnail in each post, so I found stackexchange-url ("this great piece of code") and added it to functions.php. It worked perfectly except for one thing: it renders the Lightbox jquery plugin useless. The difference I see in code is this. With the code: <code>...
I solved this by using this code <code> function exclude_thumbnail_from_gallery($null, $attr) { if (!$thumbnail_ID = get_post_thumbnail_id()) return $null; // no point carrying on if no thumbnail ID // temporarily remove the filter, otherwise endless loop! remove_filter('post_gallery', 'exclude_thumbnail_from_gallery')...
Exclude featured image from gallery code stops Lightbox from working
wordpress
I just want to ask how can I add pagination here in this code: <code> &lt;?php if ( get_option('webly_display_media') == 'on' ){ ?&gt; &lt;div id="recent-projects"&gt; &lt;div id="recent-projects-right"&gt; &lt;div id="recent-projects-content" class="clearfix"&gt; &lt;?php $args=array( 'showposts' =&gt; '7', 'category_...
Add this to functions.php: <code> // Pagination function pagination($pages = '', $range = 4) { $showitems = ($range * 2)+1; global $paged; if(empty($paged)) $paged = 1; if($pages == '') { global $wp_query; $pages = $wp_query-&gt;max_num_pages; if(!$pages) { $pages = 1; } } if(1 != $pages) { echo "&lt;div class=\"pagina...
How to add pagination to my code?
wordpress
I keep getting this on my WordPress site after I moved it from my development server to the live site. It's happening in one file that is using a few functions which I think is causing it, but I don't know how to fix it. Allowed memory size of 268435456 bytes exhausted (tried to allocate 452314848 bytes) in Unknown on ...
Clearly, this is an issue specific to the Theme. You should consult the developer and/or ThemeForest for Theme-specific solutions. As this is a commercial Theme, we have no way of seeing the Theme files, or of helping to troubleshoot.
WordPress: Allowed Memory Size Exhausted - After Moving from Dev to Live
wordpress
I am using a version control system to manage my wordpress code (git). What is the betst way to store the database information into version control? I want to go to my staging machine, run <code> git pull </code> to get the latest code from my development machine, then maybe click one button or something like that to u...
This is more a git question than a WordPress one IMHO, but what you need to do is write a bash script and associate with a git hook that does what you want.
storing database in version control
wordpress
I know I can set up post, pages, and custom post types to use featured images in wordpress by enabling theme support: <code> add_theme_support( 'post-thumbnails'); </code> Or enabling theme support for a specific set of post types: <code> add_theme_support( 'post-thumbnails', array('post','page')); </code> I also know ...
I believe that is what the <code> set_post_thumbnail_size </code> function is for. Set the default Post Thumbnail dimensions. To register additional image sizes for Post Thumbnails use: add_image_size(). See http://codex.wordpress.org/Function_Reference/set_post_thumbnail_size
How do I set the default "feature image" size?
wordpress
I never really dug into the compression options I have for my plugins and themes, so here I am. I was reading a few articles about PHP compression like this one and I had a question. Is it really as easy as adding the following code in the appropriate spot? <code> &lt;?php if (substr_count($_SERVER['HTTP_ACCEPT_ENCODIN...
To answer your question, yes, it is that easy to enable compression. However, that's only a small step when configuring a site for performance. You should not attempt to handle compression from your plugin, unless the entire purpose of the plugin is load time optimization. Leave that to dedicated plugins, such as the W...
How to Compress PHP output in my plugin?
wordpress
I have a custom loop from a custom post type and I want to NOT display posts with the category 'slider'. I'm using this to set up the query: <code> $args = array( 'post_type' =&gt; 'hotwives', 'posts_per_page' =&gt; -1); $loop = new WP_Query( $args ); while ($loop-&gt;have_posts() ) : $loop-&gt;the_post(); </code> I wa...
<code> $args = array( 'posts_per_page' =&gt; -1, 'post_type' =&gt; 'hotwives', 'post_status' =&gt; 'publish', 'tax_query' =&gt; array( array( 'taxonomy' =&gt; 'category', 'field' =&gt; 'slug', 'terms' =&gt; 'slider', 'operator' =&gt; 'NOT IN' ) ) ); </code> Use that as the args for your <code> WP_Query </code> and you ...
Modify output of custom loop using WP_query
wordpress
I have a widget that I need to add a category select list to. The end user should be able to select a category and I need to save the category ID with the widget. I've hit a stumbling block in that I cannot get my exclude array to work. The excluded cats still show up in the dropdown. What am I doing wrong? <code> func...
Per http://codex.wordpress.org/Class_Reference/WP_Query you would need to prefix the numerical identifier of the array with a minus-sign, such as <code> $query = new WP_Query( 'cat=-12,-34,-56' ); </code> , which would exclude the categories with the identifier 12, 34 and 56. You could achieve this by changing the <cod...
How to exclude categories from get_categories() select list inside a widget admin panel
wordpress
WP 3.2.1 The title just about says it all. I'd like to make a parent page of the blog that will dynamically show a little teaser of certain entries (either the most recent or random, depending on what my client wants). Is something like this possible? If so, how?
If you're wanting to display some posts but not have it function like the blog (with the prev/next links) then this should do the trick. <code> &lt;?php global $post; $args = array( 'numberposts' =&gt; 10, 'post_type' =&gt; 'post', ); $myposts = get_posts( $args ); foreach( $myposts as $post ) : setup_postdata($post); ...
Can I make a parent page of the blog and have it display a paragraph/thumbnail of certain entries?
wordpress
I have a form in a page template that allows users to submit posts into a custom post type from the front-end: <code> $post = array( 'post_status' =&gt; 'draft', 'post_type' =&gt; 'stories', 'post_content' =&gt; wp_kses_post( $story_content ), 'post_title' =&gt; esc_attr( wp_kses( $story_title, array() ) ), 'post_autho...
The issue is in using the <code> $post </code> variable for arguments. After changing this to something like <code> $new_post </code> I no longer get the notices. There must be some conflict with the <code> global $post </code> that WordPress uses. I took this from the Codex, but looking back at the page, I realize tha...
Notices when submitting custom post type from front-end
wordpress
I'm trying to assign a different ID to each sub-menu wordpress generates using the wp_nav_menu function. As it is, wordpress assigns the same class (sub-menu) to every sub menu generated. <code> &lt;ul class="sub-menu"&gt;&lt;/ul&gt; </code> I'd like to have it generate something like: <code> &lt;ul class="sub-menu" id...
Ended up using the following <code> &lt;script&gt; $(function(){ var i =0; $('ul.sub-menu').addClass (function(idx) { return "item-" + idx; }); }); &lt;/script&gt; </code> It adds a class of item-0, item-1, etc to each sub-menu it finds.
ID of parent Menu
wordpress
Is there any way to share 'templates' between JS and Wordpress? For instance, this sort of modest seat-of-the-pants templating feels ok: <code> var AJAXSuccessFunc = function(data){ // calling this on ajax.success var title = data.page.title; var content = data.page.content; var string = '&lt;h1&gt;' + title + '&lt;/h1...
You can use <code> wp_localize_script(); </code> : <code> // Example: wp_register_script( 'your-template-script', $path, $dependencies, $version, true ); wp_enqueue_script( 'your-template-script' ); wp_localize_script( 'your-template-script' ,'your_template_object' ,array( 'ajaxurl' =&gt; admin_url( 'admin-ajax.php' ) ...
Sharing templates with the JSON API?
wordpress
I got this image from one E-book for WP plugin development. Could you please clarify me why the Plugins are loaded before Pluggables.
Directly from source for <code> pluggable.php </code> : <code> &lt;?php /** * These functions can be replaced via plugins. If plugins do not redefine these * functions, then these will be used instead. * * @package WordPress */ ?&gt; </code> So, there's your answer, the functions in <code> pluggable.php </code> are int...
why plugins are loaded prior to pluggables
wordpress
Is there a way to add the template selection dropdown to the custom post type? Perhaps under Page Attributes?
So far it seems there is no native way to do it in WordPress, correct me if I am wrong. If you are okay with using plugins there is Custom Post Template that you could try.
Set template for custom post type?
wordpress
I would like to display just the first term from a custom post type custom taxonomy. Inside my loop I've been displaying all the terms using: <code> &lt;?php echo get_the_term_list( $post-&gt;ID, 'traits', 'Physical Traits:', ''); ?&gt; </code> but I would like to only display the first term. Thanks!
A little bit more involved but: <code> &lt;?php function get_single_term($post_id, $taxonomy) { $terms = wp_get_object_terms($post_id, $taxonomy); if(!is_wp_error($terms)) { return '&lt;a href="'.get_term_link($terms[0]-&gt;slug, $taxonomy).'"&gt;'.$terms[0]-&gt;name.'&lt;/a&gt;'; } } //example echo get_single_term(5, ...
In a loop of custom post type, display first custom taxonomy term
wordpress
I'm having some trouble with this sample widget code. I want to get all images (Minus the post thumbnail) from a page called "Gallery" but for some reason this is pulling all uploaded images from the entire site. Also, how would I go about excluding the post thumbnail from this query? <code> query_posts('pagename=galle...
Use get_children I used this code to extract all the images from a page gallery in the chosen order. you can include this code in the loop or use it stand alone. just choose the appropriate post_parent code (see bellow the code example). This example show all images associated to the page id 1, have a look: <code> $ima...
Get all image from single page using this query
wordpress