question
stringlengths
0
34.8k
answer
stringlengths
0
28.3k
title
stringlengths
7
150
forum_tag
stringclasses
12 values
I've added tags and categories to a custom post, but the search bar doesn't find them when I use it. It does find the 'uncategorized' category (default category) that's inherent in wordpress though. The Categories I've entered show up in the sidebar, as well as w/the custom post type (as do the tags I've entered). What...
Perhaps this article will help you... http://new2wp.com/noob/wordpress-search-custom-post-types/
Search doesn't find tags or categories in custom post types
wordpress
This is a sample of the Vote it Up plugin: <code> //Run this to create an entry for a post in the voting system. Will check if the post exists. If it doesn't, it will create an entry. function SetPost($post_ID) { global $wpdb; //prevents SQL injection $p_ID = $wpdb-&gt;escape($post_ID); //Check if entry exists $id_raw ...
Hi @janoChen: The correct answer is: "It depends." In general it is better to use built-in WordPress functions than to use direct SQL when there are built-in functions that can provide you what you need. However, the answers to many of the questions I see here on WPSE are (unfortunately) "you need to use direct SQL for...
Is it a bad practice to go directly to the mysql database while developing a plugin?
wordpress
I use 'constants' a lot. I set them in functions.php like <code> define('mytheme_town', 'Orlando'); </code> and then call them into the theme <code> &lt;?php echo mytheme_town ; ?&gt; </code> . It's simple and easy. But I need them to be site-specific (for multisite) so I thought it might be possible to append the curr...
You can access the blog ID you are on by <code> global $blog_id; </code> and then you can use that how you want it to work.
How can I append blog_id to ... echo [functions-defined-constant]?
wordpress
I inserted an excerpt into a Page using the "More" button in WP GUI. I have a custom loop-page.php from which I want to display the excerpt. But it appears to be empty? Is it possible to display excerpts from child pages? <code> $pageChildren = get_pages('sort_column=menu_order&amp;hierarchical=0&amp;child_of='.$post-&...
Using the "more" tag does not create an excerpt. It simply creates a "Read More" link when displaying the_content() on index pages. Excerpts are created/displayed as follows: To display an excerpt, your template file needs to call "the_excerpt()" rather than "the_content()". Note: you use the equivalent $post-> post_ex...
Excerpts for Pages
wordpress
Is it possible within the current theme file naming hierarchy to define a template for for all pages that are a child of a specific page? For example, in this navigation: About Us Contact Who We Are Message Statement Is there any way to just make a theme file named something like: page-about-us-all.php That would autom...
I have a handy little custom made conditional function that would do the job for you. The function: <code> function is_child_page($page = NULL){ global $post; if ($page == NULL){ $p = get_post($post-&gt;ID); if ($p-&gt;post_parent &gt; 0 ){ return true; }else{ return false; } } $args = array( 'child_of' =&gt; (int)$pag...
Theme file for all pages that are a child of a specific page
wordpress
I tried deleting the plugin, reinstalling, and entering a new api key. However, I get this message: The owner of that API Key (username) is not on the access list for this blog (blog id). Stats was installed using a different API key. Is there anyway I can install the Wordpress.com Stats plugin with a new api key?
Actually, you should be using the JetPack plugin now, not the stats plugin. Automattic (the team behind WordPress.com) have begun bundling their stats system with a few other features (social network sharing, LaTeX support, to name a couple) and aren't updating the older systems any more . JetPack will use oAuth to con...
Installed Wordpress.com Stats with api key and forgot key. How can I register w/ new key?
wordpress
Here's how I have my code set up in the functions file: <code> register_sidebar(array( 'name' =&gt; 'Latest Updates', 'before_widget' =&gt; '&lt;span&gt;', 'after_widget' =&gt; '&lt;/span&gt;', 'before_title' =&gt; '', 'after_title' =&gt; '' )); register_sidebar(array( 'name' =&gt; 'BBRB Loves (Video Width - 200px)', '...
If I had to venture a guess, the problem is that your first register_sidebar() gets called in functions.php, and hooked into widgets_init, but the second one gets called in the head, and therefore NOT hooked into widgets_init. I don't know the impact of registering a sidebar other than at widgets_init. Is there any par...
One register_sidebar function works, the other doesn't?
wordpress
I have registered a custom post type with the right parameters. By that I mean I have added <code> 'taxonomies' =&gt; array('post_tag','category') </code> , I have also tried using <code> register_taxonomy_for_object_type('post_tag', 'custom-post-type-name'); </code> I have a custom function in my functions.php to load...
Down the rabbit hole..... I found a fix. From this post stackexchange-url ("Custom Post Type Archives by Date and Taxonomy") Which let me to this trac ticket http://core.trac.wordpress.org/ticket/14589 and the following <code> function post_type_tags_fix($request) { if ( isset($request['tag']) &amp;&amp; !isset($reques...
Custom post type tag archives don't work for basic loop?
wordpress
i've just created a new post type. It's name is Academias so the first menu option is Academias as well. But I would like to change it to something like See All Academias (just an example), is that possible?
The function register_post_type() takes an argument <code> 'labels' </code> . This is an array, one of the possible keys is named … tada! … <code> 'menu_name' </code> . Sample code <code> register_post_type( 'academias' , array ( 'can_export' =&gt; TRUE , 'exclude_from_search' =&gt; FALSE , 'has_archive' =&gt; TRUE , '...
Post Type Label Name
wordpress
For example, I used the plugin Vote it Up but it haven't been updated since 2010-5-28. Now I moved to GD star rating which was last updated in January 6, 2011 (and still maintained by he author). Is it not recommendable to stick with plugins that are no longer supported by the author for production sites?
As for me key questions here are: Is plugin outdated? Not using approaches and coding practices of current WP versions. When will it become outdated? This can range from months (next WP version changes something relevant) to years (plugin does something simple on using common and basic hooks). Can you handle when it wi...
Is it not recommendable to stick with plugins that are no longer supported by the author for production sites?
wordpress
All of my theme's custom options are preceeded with "mytheme_" + option. For example, mytheme_color1, mytheme_color2, mytheme_body_font_color, etc... I'd like to create a plugin that uninstalls all of the items in wp_options where the option is preceeded with "mytheme_" If you have a reference or example, please share ...
All of my theme's custom options are preceeded with "mytheme_" + option. Not safe enough. Use set_theme_mod() , get_theme_mod() and remove_theme_mod() instead. You’ll find these and more related functions in <code> wp-includes/theme.php </code> .
Example of uninstaller routine to remove all custom theme options from wp_options
wordpress
I am quite new in WP Plugin World. I am trying to develop a plugin in WP 3.1 when I am trying to insert data into my table named " <code> wp_enam </code> " in the following way: <code> $wpdb-&gt;insert($wpdb-&gt;enam, array('username' =&gt; "enam" , 'useremail' =&gt; "myemail@somedomain.com")); </code> it is not workin...
You can check database function for database here http://codex.wordpress.org/Function_Reference/wpdb_Class . For the table prefix matter you should use <code> $wpdb-&gt;prefix . 'enam' </code> and it will return the table prefix. Just add the table name with this. So the total code would be : <code> $yourtablename = $w...
insert data in database table from plugin with WP3.1
wordpress
I added a TinyMCE editor to my plugin settings page, but once I move (drag) the metabox, editor's content get lost. (the TinyMCE editor is completely not editable until refresh) Here is how I added TinyMCE editor: <code> add_action( 'admin_head', 'add_tinymce_editor' ); function add_tinymce_editor() { if ( function_exi...
I had a similar problem with radio buttons losing their status when I dragged a metabox on a settings page. I hacked together a workaround and posted it as a reply to the original wordpress trac ticket http://core.trac.wordpress.org/ticket/16972#comment:4
Moving/dragging a metabox removes TinyMCE's content
wordpress
How can a plugin create a page/form in the front end thats not listed in pages (if possible). it should only be accessed through a direct link.
See stackexchange-url ("How do you create a “virtual” page in WordPress") for the solution. This should work for your case as well.
How can a plugin create a page/form in the front end?
wordpress
What I'm currently trying to make is an activities stream wich list : The posts, the comments, both mixed between them and ordered by date. My idea is to make two queries, but i don't know how to mix them up. Here are my queries : <code> // Query the posts : $queryPosts = " SELECT * FROM $wpdb-&gt;posts WHERE post_type...
I believe you're looking for SQL UNION .
How to make an activities stream mixing posts and comments?
wordpress
I'm working on a website where the client wants a static page displaying information about a certain category. Then under the static information she wants all the posts from that category in a 2 column list. So I need to have an alphabetically ordered list linking to all the post in a selected category. I have the code...
Updated answer: Use two floated lists to emulate columns, same approach as previously though. <code> &lt;?php /* Template Name: PageOfPosts */ get_header(); ?&gt; &lt;div id="content"&gt; &lt;div class="t"&gt; &lt;div class="b"&gt; &lt;div class="l"&gt; &lt;div class="r"&gt; &lt;div class="bl"&gt; &lt;div class="br"&gt...
How can I display only the post titles from a selected category in columns?
wordpress
Hi WordPress Experts please help me i want to get nav_menu_item_id and slug from wp database by given a page template like (store.php) this a page template and how we can get nave menu item id and slug that use this page template
Hi @Anjum: I think the function <code> get_nav_menu_id_by_page_template() </code> is what you are looking for? You can place the code for this function in your theme's <code> functions.php </code> file, or in a <code> .php </code> for a plugin you are writing: <code> function get_nav_menu_id_by_page_template($template)...
How to get nav_menu_item_id and slug from wp database
wordpress
hey guys, I really really need your help. I have just no idea why that happens. I'm trying to load a wordpress page with the jquery $ajax method. However my browser is crashing all the time when I try to load this page. I've build a kind of ajax search that requests a wordpress page when typing inside of an input field...
I'm guessing the page your calling executes an wp_redirect with a 301 response somewhere. Dont really have an answer for you but maybe you can try the following. Ajax does not know what type of page your calling from and there might be some strange query_vars loaded that trigger a redirect. Your using a permalink to lo...
php ajax problem - weird 301 responses!
wordpress
I'm trying to get the ID of a post in the first loop (using <code> &lt;?php $postid = get_the_ID(); ?&gt; </code> ) and use it in a variable ( <code> $postid </code> ) to exclude that very post from a second loop (using <code> post__not_in </code> ): <code> &lt;?php /** * Replies Loop * * @package bbPress * @subpackage...
<code> post__not_in </code> accepts an array so change <code> &lt;?php $postid = get_the_ID(); // capture the id ?&gt; </code> to <code> &lt;?php $postid[] = get_the_ID(); // capture the id ?&gt; </code> and you'll be fine.
Error while excluding a post from another loop (using its ID)
wordpress
A client currently has a website set up with three distinct sub-sites (run off a single WordPress install), each with a slightly different theme (same layout, different colour scheme. I currently have it set up so each sub-site is a page, with all of it's pages as children. The header.php checks which page is the paren...
Hi @Ross Bearman: I'm still struggling with the exact requirements but if I understand correctly I think you can do to accomplish your goals if you use the code I provide you below and then do the following: Create a page for each of your services (which it sounds like you have already done): <code> /service1/ </code> ...
How to show the same content on multiple URLs?
wordpress
I want to add permanently boxes below Visual/HTML editor for each page/post. I've never played with custom fields before, and I'm not sure is it way to go? If yes ten tell me, good people of StackExchange, how to achieve something like that (grey boxes):
Your looking for custom meta fields, which you can style anyway you want using CSS. http://codex.wordpress.org/Custom_Fields You would either have to write your own functions to accomplish this or use one of the many custom fields plugins, I would recommend the WPAlchemy MetaBox.
Custom options below pages/posts editor?
wordpress
How to add a random image to a post from gallery and only show one? I know how to add an image and a gallery. I need to have one image from the galley show on the page at random each time the page is loaded. The page should only show one image at a time. Is there a plugin or short code to do this? I know how to make ga...
You should use the <code> 'orderby' =&gt; 'rand' </code> parameter for the <code> get_children() </code> attachments function. For instance: <code> $images = get_children( array( 'orderby' =&gt; 'rand', // this is random param 'post_type' =&gt; 'attachment', 'post_mime_type' =&gt; 'image', 'post_parent' =&gt; get_the_I...
How to add a random image to a post from gallery and only show one?
wordpress
I have added a custom button to the tinymce to insert my shortcodes, but I have so many and I want to make a splitbutton instead and I can't figure how. Anyone can help. Here's the code that I've used to create the normal button: in functions.php : <code> /** Hook into WordPress */ add_action('init', 'onehalf_button');...
It should be pretty straight-forward, copy the relevant pieces of code from the page you linked to into your existing TinyMCE plugin, update a few strings... done!.. Start with this for your TinyMCE plugin JS and see how you get on.. <code> // JavaScript Document (function() { // Creates a new plugin class and a custom...
How i can i add a split button or list box to the WordPress TinyMCE instance
wordpress
I'm making a WordPress site using the Thesis framework. It has a widgetized footer area. I expect to be changing all the font styles frequently and don't want to have to change them in a few places every time to make the footer widget styles match the body styles. Does anyone know how I can make the footers styles (h3,...
The footer is a child of the body element. It does already inherit all the styles. Find and remove all the styles which are ruling out the inherited styles. Tools like Firebug or Dragonfly will help you to find these rules.
How to make widgetized footer styles be inherited from body?
wordpress
I've been pounding my head on the pavement for some time now regarding implementing the_editor functionality outside the post/page/cpt editor and retaining the look and feel of the function without having to rewrite a ton of things. The problems I've run into are all problems within WP Core. the_editor and it's surroun...
The solution was actually to contact Andrew Ozz and he was already planning on working on a new TinyMCE API which would allow for the functionality needed here. It's currently in use as of Pods 1.9.6+, and we're hoping that it makes it into WP 3.3 if everything goes right.
Replicating the_editor (Media Bar, TinyMCE, Visual/HTML Tabs) functionality without a huge rewrite
wordpress
I've managed to get my "semi noob proof" site installer plugin 98% complete, but I'm having a slight issue with the theme activation. The plugin is able to copy the theme into the themes directory fine. However, my switch_theme statement that attempts to set it to the active theme is missing something. I'm using... <co...
I think, you must also set the options <code> template </code> and <code> stylesheet </code> , thats all. I use this via filter to set a theme for testing or on a category, post-type and so on. But you must change the fields in table options for active the theme ready. I hope this help, i dont tested - only my idea.
Fully automated theme install and activation via a plugin
wordpress
When i try to access feeds for tags,categories and authors, i get empty list. If i try to open feeds for the site, i get "Page not found" Empty Feed: http://thinkzarahatke.com/category/advertisement/video/feed http://thinkzarahatke.com/author/amty/feed Page not Found : http://thinkzarahatke.com/feed I had tried fix rss...
As per @Zeo suggestion, i activated default wordpress theme (Twenty Ten) -> I opened feeds then -> it was getting opened properly. I again to switched my theme without any changes. And it started working. If someone knows then please reason behind this.
Empty RSS Feeds
wordpress
I want to load some of the pages(not wordpress page, a template file other than wordpress's default template file) according to the url came on the address bar. for instance, I have page in my template file ie my_account.php to show my profile pic and other informations from to my wordpress pofile. and it is placed in ...
You should be able to use template_redirect. I haven't tested it though, should be something like this. <code> function page_redirect() { if ($_SERVER['REQUEST_URI'] == 'your_url') { require(TEMPLATEPATH . '/mY-account.php'); } } add_action('template_redirect', 'page_redirect'); </code>
How to load a new template page according to a particular URL?
wordpress
hey, i have the following page template for a sitemap. <code> &lt;?php /** * Template Name: Sitemap */ ?&gt; &lt;?php if (have_posts()) : while (have_posts()) : the_post(); ?&gt; &lt;div&gt; &lt;h3&gt;Pages&lt;/h3&gt; &lt;ul&gt; &lt;?php wp_list_pages('title_li=&amp;depth=0&amp;exclude='); ?&gt; &lt;/ul&gt; &lt;h3&gt;P...
Search all your theme and plugin files for: <code> &lt;!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" </code> Disable all plugins and re-enable them step by step. This document type declaration is not part of WordPress’ core files; there is a filter active somewhere. Update Try to remove all filters from ...
page template - undefined structure in source code
wordpress
Ok ,i am not a great fan of the menu of WP, but now it manage this inside pretty ok, i have to make theme that use that menu. Now for styling i am a bit challenge... here is the problem... the menu should look like | page1 | page2 | page 3 | Do you see the problem, the border, let say each will be style with border rig...
Are you using CSS3? You could use: <code> ul#navmenuid:first-child { border-left: 1px; } </code> Or you could use (any LI that immediately follows an LI): <code> ul#navmenuid li { border-left: 1px; border-right: 1px; } ul#navmenuid li + li { border-left: 0; } </code> Or you could use (any LI that follow an LI, even if ...
New wp menu menu styling
wordpress
I am currently building a site using a child theme for the first time. Basically, I have a flash banner the client has already had made, and want to replace the twentyten image banner with the flash. I know how to do this by editing the header.php (I think!) but was wondering if there was a better way to do it - using ...
A child theme is definitely the way to go for the reason you outlined: upgradability. To start with, here is the documentation for creating child themes: http://codex.wordpress.org/Child_Themes You'll want to create the child theme directory and edit the <code> style.css </code> file as described in the Child Theme doc...
How to replace the twentyten image header with my flash banner?
wordpress
How can you trigger a 404 when using custom query vars? I've got re-write rules written for a custom query var, but if you were to request a URL for the query var that should technically be a 404 it returns a normal WP page, but no content, because nothing technically exists for the URL.
There is a method specifically for this: <code> function my_parse_query( $wp_query ) { if ( $wp_query-&gt;get( 'my_custom_var' ) &gt; 42 ) $wp_query-&gt;set_404(); status_header( 404 ); } add_action( 'parse_query', 'my_parse_query' ); </code> That should load the 404.php template in your theme, if you have it. Otherwis...
How to trigger 404 for custom query var?
wordpress
I currently have a plugin that lets me display a random post in a widget. The problem is that if I activate w3 total cache it will only display that post as long as the cache hasn't been cleared. Is there a way to cache everything except this plugin? Sorry if the question is rather newbie, I just installed the plugin b...
You can try fragment caching, from plugin's FAQ: <code> Edit your templates to with the following syntax to ensure that dynamic features remain so: Example 1: &lt;!-- mfunc any PHP code --&gt;&lt;!-- /mfunc --&gt; Example 2: &lt;!-- mfunc --&gt;any PHP code&lt;!-- /mfunc --&gt; Example 3: &lt;!--MFUNC --&gt; echo rand(...
Can I ignore caching of a plugin in W3 Total Cache?
wordpress
I am pretty new to this and hence facing a bit of a problem. Currently I am designing a website on my localhost using WordPress. I noticed that the permalink structure wasn't very appealing in the default mode. I then found that it can be changed through settings and after looking around I found that I wanted <code> %p...
You should never have to touch the mod_rewrite rules. WordPress flushes/rewrites them to .htaccess whenever you save settings on Dashboard -> Settings -> Permalinks. If that's not happening, then something is wrong, either with your file permissions, or your local server setup. Also, it is strongly advised NOT to use %...
Changing permalink of WordPress
wordpress
I am using a short piece of code(which is modified, originally it was a plugin-Taxonomy Terms List) to display custom taxonomies after the post, When the terms are displayed, it is displayed with a <code> href </code> tag. I don't want the terms to be a link, I just want simple terms text. How can I get that? Here is m...
You could use get_the_terms() instead: http://codex.wordpress.org/Function_Reference/get_the_terms This just gives you an array of the associated terms. Then use that array to create your own list without links.
Remove a href from this code
wordpress
I am using a function to display the URL on title tag, I coded this function which works properly but I would like to customize it more further. <code> function title_tag() { $a = $_SERVER['REQUEST_URI']; $b = strtoupper($a); $c = str_replace('-', ' ', $b); $d = str_replace('/', ' - ', $c); $e = substr($d, 2); return $...
<code> function title_tag () { // 0. uppercase string $str = strtoupper ( $_SERVER['REQUEST_URI'] ); // 1. remove trailing and init slash $str = trim ( $str , '/' ); // 2. add search and replace chars; // two array, with same element size, // 1. element of search array will be replaced // with the first element of repl...
title tag function
wordpress
For example, I want to query posts in a page. But I don't want to show them when the user clicks the pagination links. Pretty much like what happens in Youtube. You only see the Top comments in the first page but when you click <code> Next </code> they disappear. Any suggestions to accomplish this? URL example: Query t...
The current page number is available in a global variable <code> $paged </code> . <code> if ( ! isset ( $GLOBALS['paged'] ) or ( $GLOBALS['paged'] &lt; 2 ) ) { // run your code } </code>
Querying posts only if the current page is not paged?
wordpress
This is the code: <code> &lt;?php get_template_part( 'pagination', 'bbp_replies' ); ?&gt; &lt;?php query_posts('gdsr_sort=thumbs&amp;post_type=bbp_reply&amp;posts_per_page=2'); ?&gt; &lt;?php while ( have_posts() ) : the_post(); ?&gt; &lt;h2&gt;&lt;?php the_title(); ?&gt;&lt;/h2&gt; &lt;?php the_content(); ?&gt; &lt;?p...
I would not do it this way, but it should not be a problem. When your template file is executed the "real main loop" already contains the posts for this page. You then execute <code> query_posts() </code> to do a second query, which "hides" the "real" loop, but after you are done you execute <code> wp_reset_query() </c...
It is possible to encounter horrible bugs if I place a main loop that uses `query_posts` right above the main bbPress loop?
wordpress
I have a site with about 900 pages that I was using custom permalinks <code> /%year%/%monthnum%/%postname%/ </code> for. I have a custom nav menu with tons of items in it. This combination seems to be simply too much for the server and they keep suspending my account for CPU usage. (I'm pretty sure this is what's causi...
Changing the permalink structure back won't reduce your CPU usage that much. That stuff happens on the Apache side of things (using mod_rewrite), and it's pretty fast. It might help a bit, but it's a HUGE pain if you have nice, readable, search-engine friendly URLs at the moment. One of the best ways to reduce CPU usag...
Changing permalinks back to default ( ?p=123 )
wordpress
My theme has a custom menu assignment... <code> function my_register_my_menus() { register_nav_menus( array('header-menu' =&gt; __( 'Custom Header Menu' ) ) ); } </code> ...and I'm creating an "installer" type plugin that, upon activation, I would like to hook into this custom menu and assign some pages to it as if the...
You can use <code> wp_nav_menu_{$menu-&gt;slug}_items </code> hook and add you link with a callback function, for example if your menu slug is <code> header-menu </code> then something like this: <code> add_filter('wp_nav_menu_header-menu_items', 'add_my_extra_links',10,2); function add_my_extra_links($items, $args) { ...
Can I add pages to my custom menu via script?
wordpress
I did a pretty thorough search and found a couple of closed (and unanswered) topics on the WP forums. Does anyone know if this is possible? The codex doesn't specify this as an option. Thanks!
You use a lowercase y for a 2 digit year. For example (l, F j, Y) --> returns, Friday, September 24, 2004 and (l, F j, y) ---> returns Friday, September 24, 04
How do you format the date as a two digit year? (ex. "10.12.10" instead of "10.12.2010")
wordpress
I am trying to get all products from the wpsc-product post type and then display them by a custom meta field called release_date_year. However, it doesn't appear to be ordering my posts by this custom meta value. I have read through countless blog posts, support posts on the Wordpress forums and a lot of questions and ...
The plugin ' Post Types Order ' was the culprit. As Scribu pointed out above the plugin is filtering the Raw SQL query which it shouldn't be doing. As a result, the argument ' suppress_filters ' wasn't stopping the query being modified and the ' orderby ' argument was being completely ignored. As to how this behavior c...
Wordpress Orderby Numeric Value Not Working
wordpress
I am trying to email a custom input <code> &lt;input type="text" name="total" id="total" class="wpcf7-text" readonly="readonly" /&gt; </code> I tried <code> [total] </code> but it does not work. Or isit possible to make a field readonly with WPCF7?
Contact form 7 is one of my favorite plugins , now after I've said that you can either create your own module to add a filed of "readonly" by following this tutorial http://blog.ekynoxe.com/2010/09/06/extending-contact-form-7/ or maybe even digging through Contact Form 7 Modules plugin to see how to add new modules, bu...
Contact Form 7: Email custom HTML inputs or make a field readonly
wordpress
What's the best way to use <code> &lt;?php the_post_thumbnail();?&gt; </code> in my loop BUT only show a thumbnail on the FIRST post? Meaning, only the first post in the loop will have it's image shown? Here is an example of a loop that shows the image for ALL posts: <code> &lt;!-- Start the Loop. --&gt; &lt;?php if ( ...
add a variable before the loop (before the while), for example $first = true; add a check inside the loop for this variable after the use, change the flag Code: <code> &lt;!-- Start the Loop. --&gt; &lt;?php $first = true; ?&gt; &lt;?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?&gt; &lt;!-- Display t...
Display thumbnail only on the very first post in the loop?
wordpress
How do I increase Author Role permissions to be able to add Categories? Other solutions welcome. We just need guest authors to be able to add categories while ensuring there is not already a existing appropriate category.
The easiest way is to use a plugin like Capability Manager or User Role Editor
How would I increase the Author Role to be able to add a new category?
wordpress
I'm using the following function to get some posts based on their vote (Vote it Up plugin): <code> function top_voted($number){ $a = SortVotes(); echo '&lt;div class="voted"&gt;'; $rows = 0; //Now do not include deleted posts $i = 0; while ($rows &lt; $number) { if ($a[0][$i][0] != '') { $postdat = get_post($a[0][$i][0...
<code> $the_posts = get_posts(array('post_type' =&gt; 'post_type_name')); </code> That will get all posts from the post type called "post_type_name" so replace that with whatever custom post type you are using. I mean this in the nicest possible way, but you should probably read the documentation as this is a pretty we...
Getting only a specific post type with get_post?
wordpress
I have a custom table inside my wordpress database called test. What if i query this table using mysql_query() instead of using for example $wpdb-> get_results() Will this affect my performance? Ty very much:)
Simple and short: mysql_query() = Faster! $wpdb-> get_results() = Safer! But in most cases since <code> $wpdb </code> is a global object and already in the memory using it will be be as fast as <code> mysql_query() </code> . Will this affect my performance? It can affect for better performance changes but they would be...
Use mysql_query instead of $wpdb query
wordpress
This is going to sound a little nuts. I have a situation where I'm displaying a list of products that a user selects to move to the products' page. I also have documents and videos that I created custom post types and fields for. I need to run a second loop within the current loop to pull a custom field from a custom p...
I'll presume you are using something like this...to get the custom value you want. Once you are inside the loop. <code> $customfieldvalue = get_post_meta($post-&gt;ID, "metakeyname", true); </code> Since you are using $model as the base for a query. You could create a function That will query what you want, and then re...
Pull custom fields from custom posts within a loop
wordpress
I have posts and I have recipes. Recipes is a custom post type. Recipes make use of the category taxonomy and a newly added recipe has been categorized under beer. When I browse the listing page for the category beer I see all my previous posts categorized under beer while the new recipe does not appear. How do I link ...
You can use pre_get_posts hook to add your custom post type to the query <code> function include_recipes( $query ) { if ( $query-&gt;is_category ) { $query-&gt;set( 'post_type', array('post','recipes') ); } return $query; } add_filter( 'pre_get_posts', 'include_recipes' ); </code>
How do I display custom post types through a common taxonomy?
wordpress
I see that w3 total cache can't offer CSS sprite generation. Is there another plugin that can complement this feature? Thanks. update: I didn't mean that w3 total cache doesn't allow CSS sprites to be used, but that it doesn't generate them automatically as a way to improve sites performance. My question is what plugin...
Are you asking about how to create css sprites? Try http://spritegen.website-performance.org/ if the manual way seems too time-consuming. But yeah, not really a WordPress question.
Plugins to generate CSS Sprites?
wordpress
For some reason a <code> title </code> attribute is not appended to <code> next_post_link </code> and <code> prev_post_link </code> calls in WordPress. How can I add one?
Update As I deleted the Repo on GitHub, here's a new answer. <code> add_filter( 'previous_post_link', 'wpse13044_adjacent_post_link_tooltip', 10, 2 ); add_filter( 'next_post_link', 'wpse13044_adjacent_post_link_tooltip', 10, 2 ); function wpse13044_adjacent_post_link_tooltip( $format, $link ) { $previous = 'previous_po...
How can I add title attributes to next and previous post link functions?
wordpress
I'd like to display daily archives differently than monthly/yearly archives. How do I check to see if the archive template is being pulled for a daily archive vs. a monthly/yearly archive?
Conditional tags FTW. is_month() : Currently viewing a monthly archive is_day() : Currently viewing a single day archive is_year() : Currently viewing a yearly archive is_time() : Currently viewing a time-based archive (hourly, minute, or even seconds) So to test for each of these conditions, add something like this to...
Displaying year, month and day archives differently
wordpress
I've got a routine (see below) that creates and inserts several widgets into the active theme's sidebars. However, I need more control over either the order/index the are assigned (ie, one of my widgets need to be at the top of any other widgets in the sidebar) OR, I need to be able to specify a custom css name for the...
If you want to change the orders, you can use the filter <code> sidebars_widgets </code> , the argument to which is an array of all the widget ids and their locations. You can change the id positions in that array as per your need.
How to specify widget order or css name via script?
wordpress
Ok, i need to setup a shop, my choice, WP, now, the shop should be french and english, with product variation and newsletter tracking, this is the baseline Now, everybody is talking about wp e-commerce from instinct, a company that look serious, but now, there is a paid, a free, a commercial version. There is getshoppe...
Yes, it is extremely frustrating to find a plugin that works without errors and is still customisable. I have tried the following: Shopp - www.shopplugin.net (very good, but will only support WPML in the next update - unknown release date) Marketpress - http://wordpress.org/extend/plugins/wordpress-ecommerce/ (workes w...
WP E-commerce wpml translation or multilingual
wordpress
People are often confused about how to get data from global objects/vars Question: In which ways can you inspect global variables? This Q was written because it's needed pretty often over here at WA. I just wanted to have it as a fav to link over here (people often don't take a look at github gist links). Feel free to ...
How to inspect the data: Use this to get an insight view of what you can use from the current request/wp_query. <code> function inspect_wp_query() { echo '&lt;pre&gt;'; print_r($GLOBALS['wp_query']) echo '&lt;/pre&gt;'; } // If you're looking at other variables you might need to use different hooks // this can sometime...
How to: inspect global variables in WordPress
wordpress
I'm using this code to display my menu: <code> &lt;?php $menu_args = array( 'container' =&gt; '', 'menu_class' =&gt; '', 'menu_id' =&gt; 'main-menu', ); wp_nav_menu($menu_args ); ?&gt; </code> It works totally fine, but I don't know how to get rid of all these classes attached to every li in my menu? Example: <code> &l...
you can use <code> nav_menu_css_class </code> filter hook to remove the classes: <code> add_filter('nav_menu_css_class' , 'my_nav_menu_remove_class' , 10 , 2); function my_nav_menu_remove_class($classes, $item){ $my_class = array('menu-item-class'); return $my_class; } </code>
WP navigation list classes
wordpress
I've gotten as far as creating my new tab and getting it to show up and I've taken a copy of the gallery screen (I'm making an audio plugin with a playlist feature). The list of media items shows up fine but I can only get it to show just the audio files when I don't pass a post ID into the <code> get_media_items() </c...
The answer ended up being to copy that function and filter the results it returned. It's hacky but until there are more hooks/filters available in that section of the core there's no better way :(
How do you filter get_media_items by mime type in a custom media upload tab?
wordpress
I have a custom loop pulling out videos all assigned to various categories. However there is a category called "new-video" and I need to pull out all videos using my custom loop, but I would like the posts assigned to the category "new-video" to be shown first. So basically the loop will treat the category "new-video" ...
Just run 2 queries, the first to pull just the new-videos and the 2nd to pull everything else but the new-videos. Probably just use WP_Query for the first one to get the new-videos and then alter the loop query for the 2nd one to exclude new-videos.
Prioritising and Ordering Posts By Category Name Using A Custom Loop
wordpress
If I would export a WordPress database, posts and comments etc. are saved to an XML file. Would comment metadata be included in this XML file? I.e. the table <code> wp_commentmeta </code> , mentioned here: http://codex.wordpress.org/Database_Description#Table:_wp_commentmeta . Here: The WordPress eXtended Rss &#40;WXR&...
My latest export from my blog (WP 3.3.1) now has the commentmeta in the XML. It's in this format: <code> &lt;wp:comment&gt; &lt;wp:comment_id&gt;...&lt;/wp:comment_id&gt; ... &lt;wp:comment_user_id&gt;0&lt;/wp:comment_user_id&gt; **&lt;wp:commentmeta&gt; &lt;wp:meta_key&gt;name_of_meta&lt;/wp:meta_key&gt; &lt;wp:meta_v...
Is comment metadata included in the export file?
wordpress
I am trying to mimic the dashboard meta boxes UI in my WP plugin - the small metaboxes. I have already styled them and also the drag &amp; drop feature works as I loaded the following script and style: <code> wp_enqueue_style('dashboard'); wp_enqueue_script('dashboard'); </code> However I also would like to save my cus...
When ordering or closing metaboxes, those actions require nonces, add the following to your code and see if that resolves the problem. <code> &lt;?php wp_nonce_field('closedpostboxes', 'closedpostboxesnonce', false ); ?&gt; &lt;?php wp_nonce_field('meta-box-order', 'meta-box-order-nonce', false ); ?&gt; </code> Additio...
Dashboard like meta boxes in my plugin - how to save their position and open/closed state?
wordpress
By default WP seems to display all posts of all types in the main RSS feed. You have to add a post_type query variable to show post of a certain type... So how can I turn this: <code> http://site.com/feed/?post_type=book </code> into <code> http://site.com/feed/books/ </code> ? And if possible rewrite <code> http://sit...
If you set <code> 'has_archive' =&gt; TRUE </code> in <code> register_post_type() </code> the post type will have its own feed on <code> /books/feed/ </code> and its items are not included in the main feed. Example plugin <code> &lt;?php /* Plugin Name: WPSE13006 feed for CPT demo */ ! defined( 'ABSPATH' ) and exit; ad...
Nice RSS Feed URLs for each custom post type
wordpress
As I already told, I'm setting up a Blog for a friend. Next to not being him an administrator stackexchange-url ("but an editor that can make changes to theme options")) I have an additional question. I don't want him to worry about updates as well nor do I want him bothering me, but the problem is, editors do see a sl...
You may have to adjust the capability. <code> add_action( 'admin_init', 'hide_update_msg', 1 ); function hide_update_msg() { ! current_user_can( 'install_plugins' ) and remove_action( 'admin_notices', 'update_nag', 3 ); } </code>
How can I disable the update notice for non-administrators?
wordpress
I have a plugin that installs a folder of themes and other plugins into the WP site during plugin activation. I would like to place script into the plugin which will activate one of the themes that the plugin installs. Can someone post a quick example of script that registers and activates a known theme via a plugin's ...
switch_theme() should work: <code> function myplugin_activate() { switch_theme('default', 'default'); } register_activation_hook( __FILE__, 'myplugin_activate' ); </code>
Activate theme via plugin script?
wordpress
I have a blog on wordpress.com in which I make use of the Twenty Ten theme. For each Post I can set a Featured image. On Wordpress.com that image is then displayed in the header above the menu. I'd like to gain the same for a Wordpress.org setup. How can I do this?
Not sure I understand your question completely hakre but here is the code that shows the featured image for twenty-ten in header.php.The image sizing is defined in the functions.php file. It also uses a function called http://codex.wordpress.org/Function_Reference/get_header_image . <code> &lt;?php // Check if this is ...
Use Featured Image of Post as Header Image
wordpress
Here is what I'm doing: <code> wp_logout(); var_dump(is_user_logged_in()); </code> var_dump returns: <code> bool(true) </code> Why is wp_logout() not logging me out?
wp_logout() calls clear_auth_cookie() , which expires all authorization cookies set. It doesn't change the value of the global $current_user variable. So technically you're still logged in for the duration of the script. If you're using <code> wp_logout </code> in your own code, its probably best to <code> exit </code>...
wp_logout Not Logging Me Out
wordpress
Basically, I want to allow the user to select which template files he or she wants to use in a post: single-asc.php : <code> &lt;?php $custom_posts = new WP_Query(); ?&gt; &lt;?php $custom_posts-&gt;query('post_type=bbp_topic&amp;order=ASC'); ?&gt; &lt;?php while ($custom_posts-&gt;have_posts()) : $custom_posts-&gt;the...
If the differences in the pages are just query arguments the you can add query vars and use them in the same template: <code> //add your arguments to query vars add_filter('query_vars', 'my_query_vars'); function my_query_vars($vars) { // add my_sortand ptype to the valid list of variables you can add as many as you wa...
Is it possible to give the user the chance to select between two single template files to use in a post?
wordpress
I am wanting to display the number order of a post. I tried using <code> &lt;?php the_ID(); ?&gt; </code> but this just displays the post ID and doesn't seem to do go in sequential order due to post revisions and whatnot. Is there a way to to display if the post is #2 or #3 or #4 and so on? Thanks!
Post ID's aren't meant to be sequential. To number your posts sequentially, you'd have to use a meta field. There was discussion of this while back on this question: stackexchange-url ("Change Permalinks Structure to a Sequential Number for Each Post?") And the best answer for what you're looking to do seemed to be a s...
Display post number not post ID number
wordpress
<code> &lt;?php $my_query = new WP_Query("cat=1&amp;day=''&amp;posts_per_page=-1"); ?&gt; &lt;?php while ($my_query-&gt;have_posts()) : $my_query-&gt;the_post(); ?&gt; </code> I'm trying to display all posts from a single day on my homepage, restricted by category. The code above is what I'm using, but I've tried a bun...
You'd have to specify day, month, and year to get today's posts: <code> $my_query = new WP_Query( array( 'cat'=&gt;1, 'year'=&gt;date('Y'), 'monthnum'=&gt;date('m'), 'day'=&gt;date('d'), 'posts_per_page'=&gt;-1 ) ); </code> Leaving day blank just doesn't set that query var, so its not restricting your query at all.
How do I display posts by day?
wordpress
Regarding the <code> WP_USE_THEMES </code> constant, the Codex states: If you are using The Loop inside your own design (and your own design is not a template), set WP_USE_THEMES to false. But what is the actual effect on WordPress from <code> WP_USE_THEMES </code> being set to true or false? I would like to know how i...
This is only used in <code> template-loader.php </code> , to determine whether it should load a theme file or not. The normal "boot sequence" of WordPress (started in <code> wp-blog-header.php </code> ) loads the plugins, parses the URL, executes a post query based on the URL, and calls the theme. This main post query ...
What is the constant WP_USE_THEMES for?
wordpress
What's the best way to check current url for endpoint in a template file? I have a plugin that creates endpoints in author.php ... so now i'm trying to check in author.php so that only certain code is executed if the URL ends in a specific endpoint? <code> example.com/author/username/endpointA </code> <code> example.co...
Check out this tutorial for query variables: http://www.rlmseo.com/blog/passing-get-query-string-parameters-in-wordpress-url/ . Essentially what you will be adding is a custom query variable with value either A or B to show different content. I.e. /author/username/contentA is actually index.php?author=username&amp;cust...
How to check current URL for endpoint in a template file?
wordpress
I have my own function called breadcrumbs(). In it I call is_author() to determine whether I am on an author page. If true I would like to know which author's page I am on. I tried the_author(), but nothing came up. I looked through the WP codex also. Can someone please help?
Call <code> echo $GLOBALS['wp_query']-&gt;query_vars['author_name']; </code> and it should show you the author. You can also <code> echo $GLOBALS['wp_query']-&gt;post-&gt;post_author; </code> or <code> echo $GLOBALS['wp_query']-&gt;queried_object-&gt;post_author; </code> . hope i didn't mix up with arrays and objects.
Breadcrumbs - get the author?
wordpress
i'm trying to separate categories/subcategories in author.php so they each have their own endpoint link. It's very similar to this question BUT for the life of me I can't enable the plugin provided: stackexchange-url ("How to set up sub-categories for author pages?") The solution provided was this: https://gist.github....
Hi @Pwn: Add the text "Plugin Name: * in front of the text "Author Endpoints Example." You may need to remove the leading asterisk ("*").
How to create rewrite endpoints it in author.php?
wordpress
I'm planing a custom post type functionality for my theme and need to be able to display more than just one <code> post_type </code> in a admin overview table. That request I imagine might look like <code> edit.php?post_type[]=theme_slide_nivo&amp;post_type[]=theme_slide_other </code> . Haven't actually tried that but ...
I tried it out to get an idea of the problems you will run into. The following code allows you to specify multiple post types with the <code> multi_post_type </code> parameter: <code> add_action( 'pre_get_posts', 'wpse12970_pre_get_posts' ); function wpse12970_pre_get_posts( &amp;$wp_query ) { if ( is_admin() &amp;&amp...
Get multiple custom type posts at once in edit.php?post_type request
wordpress
hey guys, I really need you help with this one. I'm using the subscribe2 Plugin (for email subscriptions). I want to show the signup form as a widget. The plugin author recommends doing it the following way. <code> $content = apply_filters('the_content', '&lt;!--subscribe2--&gt;'); $content = remove_filter('the_content...
Its extremely difficult to remove a filter that's added as part of an object. You have get the reference to the original object and pass that as part of the function to remove. Luckily the filter was added at an unusual priority, so you will probably be safe removing all filters at priority 100: <code> remove_all_filte...
problem with implementing widget via the_content()
wordpress
I've just setup a new Blog for a friend and thought it's better to not give him Administrator Access right away as a pre-caution. I created a new user as Editor therefore. But then I saw that this user can not change the Theme Settings like Background and Header. Is there an easy way to allow the Editor Role to edit an...
you can add capabilities to the editor role using the role object and add_cap from you functions.php <code> &lt;?php // get the the role object $editor = get_role('editor'); // add $cap capability to this role object $editor-&gt;add_cap('edit_theme_options'); ?&gt; </code> you can also remove capabilities: <code> $edit...
How can I allow the Editor Role to change Theme Settings?
wordpress
I'm suffering from the issue of lots of fake registrations for my site. I'd like to add a captcha for registrations. What is the best plugin that will require a captcha at registration? Recommendations based on real installs are most appriciated! Also: I'm using the most up-to-date install of WP.
My favorite captcha plugin is reCaptcha. The captcha images are scans from old, damaged books. A computer identifies possibilities with OCR, then the user, in correctly filling out the captcha, confirms it. It helps digitize whole books this way. It's an initiative by Google. Read about them on their website.
What is the best Captcha plugin for registration?
wordpress
I really need some help, I dont know where else to turn with this request. I'd like to add a shortcode to one of my posts. The template tags get_next_post() and get_previous will not work for me since I dont want post navigation on each post page and I want to control where it displays. In a DIV in an HTML structure I'...
this is very simple to do... <code> // next function next_shortcode($atts) { // global $post; -unnecessary return '&lt;div class="nav-next"&gt;'.next_post_link( '%link', '%title &lt;span class="meta-nav"&gt;' . _x( '', 'Next post link', ' ' ) . '&lt;/span&gt;',true ).'&lt;/div&gt;'; } add_shortcode( 'next', 'next_short...
Making a Shortcode [NEXT] and [PREVIOUS] to place into specific posts for post navigation
wordpress
I am integrating a payment gateway into a distributed wordpress plugin. The notification page (page that the gateway sends info to after the payment has been made) requires only a message of "success" or "fail" to be printed. In that page, I need access to the database and some org options. Can someone please tell me h...
See http://codex.wordpress.org/Pages#Creating_Your_Own_Page_Templates Just don't include <code> get_header() </code> , <code> get_siderbar() </code> , <code> get_footer() </code> .
Produce a plain page with only a message
wordpress
I have a custom loop (used in a shortcode) that lists items from custom post type. Everything works fine but "order" for posts doesn't work, no matter what I type as order attribute on post page - items are always displayed the same way (the most recent first and the oldest last). Why doesn't "order" work in my case? T...
Add <code> orderby </code> clause to your query! Here is the complete list of order parameters <code> $loop = new WP_Query( array( 'post_type' =&gt; 'images', 'orderby' =&gt; 'menu_order', 'paged' =&gt; get_query_var('paged') ? get_query_var('paged') : 1, 'posts_per_page' =&gt; $per_page, ) ); </code> This query order ...
"Order" doesn't work in custom loop?
wordpress
I am creating a plugin that adds two custom post types, one of which will always be a child of the other. The parent post type is for Events, the child for Performances. Before entering the Loop, I'd like to be able to find a set of Events that have Performances on a specific date. Performance date is stored as a meta ...
Child posts are related to their parents (through the "post_parent" field), and not vice versa. So you would have to query your child post type first, then get the parents of all the results. <code> // obviously these variable names and key names might not apply, // change them as necessary $performances = get_posts( a...
Find Posts based on Child Post value
wordpress
Update From reading the answers, i think i didn't make myself clear, so i try to post it again. I register taxonomies from data from parsed xml files. The arguments passed should be absolutely correct. What i wanted to know is on which of the arguments of the <code> register_taxonomy() </code> function the <code> sanit...
First: Sorry , if i wasted your time. The problem couldn't have been guessed by anyone and was lying in the middle of my class. I simply build an array where i pushed all needed stuff into. This array was rebuilt before i pushed it into the <code> register_taxonomy() </code> function. There i simply forgot to unset tho...
remove sanitize_title() for register_taxonomy()
wordpress
Using WP3.1 I Have a custom page with a WP_Query and the query gets dynamic variables from the url. And i want safe variables and clean urls. Example: carpage/?carmodel=honda&amp;location=finland TO carpage/honda/finland/ I made add_rewrite_rule in to functions.php and it works, but iam not sure it's safe to use this. ...
I think the <code> add_rewrite_tag() </code> is not needed, and can be replaced with adding the variables to the public query vars directly: <code> // Either directly (in your init hook): $wp-&gt;add_query_var( 'var1' ); $wp-&gt;add_query_var( 'var2' ); // Or via a filter: add_filter( 'query_vars', 'wpse12965_query_var...
Custom page with variables in url. Nice url with add_rewrite_rule
wordpress
ok - so i'm listing categories and their sub-categories. How can i get the ID of the category that's being shown with a function? ( i know what it is in the admin ) ie /category/events/women-in-art/ women-in-art-ID = ? any help appreciated! Dan.
How about get_query_var('cat'). I think that should get the ID of the current category.
get listed category's id?
wordpress
I checked in my list of plugins, and I have nothing that seems like Related Posts or Similar Posts. Yet, at the end of my posts I find two very similar sections titled as such. Any idea how to turn one of them off, and how to understand what plugins are responsible for generating them?
Similar posts section has following comment in page source <code> &lt;!-- Similar Posts took 18.313 ms --&gt; </code> which quick search identifies as belonging to Similar Posts plugin. Nothing to identify "Related" section by. I'd try to search sources for that heading.
What is generating Similar Posts and Related Posts on my blog?
wordpress
Some plugins use the <code> 'template' </code> , <code> 'option_template' </code> and <code> 'option_stylesheet' </code> to dynamically serve (alternative) wordpress templates. For example, Nathan Rice's <code> ServeDefaultToIESix </code> . For Example - <code> add_filter('template', 'change_theme'); add_filter('option...
You could also write your own simple get_template_part alias function: The following allows 3 subfolders for template parts that sit in a theme root folder named devices . <code> &lt;?php // STYLESHEETS function print_device_styles( $client = 'desktop' ) { $client = apply_filters( 'set_theme_client', $client ); wp_enqu...
Dynamic template serving, change theme_root using add_filter from current theme
wordpress
This question is related to my stackexchange-url ("earlier question"), but I think it's specific enough to qualify as a standalone question. I am modifying an existing theme (the Twenty Ten theme that ships with WordPress), and I would like to completely control the colors used. The Admin Screen allows the administrato...
In TwentyTen’s functions.php the custom background is added in twentyten_setup() which is called on the action <code> 'after_setup_theme' </code> . So, in your child theme, the following should remove the option completely: <code> // Higher priority to work after TwentyTen add_action( 'after_setup_theme', 'wpse12934_re...
How to Disable Color Options?
wordpress
I have 2 older WP blog installs with regular posts that I would like to bring over to a new blog. One of the older installs is for "news" posts and the other is for "blog" posts (I know this was not the best way of setting things up). In my new blog, I have created two custom post types ("news" and "blog") and I would ...
Try importing and then using a plugin ( Post Type Switcher ) to change the type. There are a few other plugins out there for this, I seem to remember one which would convert multiple posts, but I couldn't find it just now.
Importing old blog with regular posts into new custom post types
wordpress
How do I completely remove widget support from a theme/plugin ? Like removing the appearance -> widgets page , and prevent WP from loading widget classes and all widget-related stuff.
One option would be to simply flush the widget code out of the sidebar.php file, as well as the header/footer/post pages if they are using widgets. However, take a peek at this code snippet (courtesy of this site ), which you can add to your functions.php file and will disable the widgets. I think this would be a clean...
Completely disabling widgets
wordpress
How would I grab a photo, that has been added to a post, and use it elsewhere on a site when there have been several photos added to the post? For example, my site has a blog (Wordpress) and a non-blog section. I want to pull one image from my latest post for use in this non-blog section. Keep in mind that there might ...
Well one photo can be assigned as the thumbnail as you can see in the post editor screen. Otherwise as the comment above suggested create a post meta field for example 'my_post_image' and place the id of the image attachment in that field. That is how WordPress saves the post thumbnail (look in the database, something ...
Special purpose photos with each post
wordpress
I'm using bbPress. I'm in a single page of the custom post type <code> bbp_topic </code> . As you can imagine this custom post type stores another custom post type called <code> bbp_reply </code> . I'm using the following query to list the most voted replies at the top (like Youtube), helped by the GD start rating plug...
It appears the topic of a reply is stored in the <code> _bbp_topic_id </code> meta field . Older versions stored this in the <code> post_parent </code> field, but it seems this is deprecated? So you can add <code> '&amp;meta_key=_bbf_topic_id&amp;meta_value=' . $post-ID </code> to your query to get only replies to this...
Query for bbPress replies to current topic?
wordpress
This correctly sort posts by thumbs vote ( GD star rating plugin): <code> &lt;?php query_posts('gdsr_sort=thumbs&amp;post_type=bbp_reply&amp;posts_per_page=2&amp;post_parent='.$post-&gt;ID); ?&gt; &lt;?php while ( have_posts() ) : the_post(); ?&gt; &lt;h2&gt;&lt;?php the_title(); ?&gt;&lt;/h2&gt; &lt;?php the_content()...
It seems GD Star Rating uses <code> get_query_var() </code> to read query variables, which only reads this global <code> $wp_query </code> variable. <code> query_posts() </code> overwrites the global <code> $wp_query </code> variable, so it works there, but creating a new <code> WP_Query </code> (which is a good practi...
Why is that gdsr_sort=thumbs (GD start rating plugin) only works with query_posts and not with WP_Query?
wordpress
Under Media Settings I edited the Image Sizes to the following: Thumbnail size: 170x80 Medium size: 550x170 Large size: 550x320 ("Crop thumbnails to exact dimensions" is checked) Maximum embed size: Width 1000, Height 1000 My problem is when I upload an image it ignores these dimensions. For example, when I upload a 55...
The issue is that WordPress always maintains the aspect ratio on your photos. For a lot of uses, this makes sense. However, if you're trying to line up a bunch of images — some in portrait, others in landscape — it can be a real pain. If you want to fix this, you can register a new image size in your <code> functions.p...
Media > Image Sizes aren't being applied to uploads
wordpress
I can't get WordPress pretty permalinks to work on my Fedora LAMP server. If I set them and click a page/post link I'll get a ""Oops! This link appears to be broken." The .htaccess file is writable and being updated, mod_rewrite module seems to be loaded in my httpd.conf (See below) The errors in my apache log say simp...
Inside of your config you have the following: <code> &lt;Directory /&gt; Options FollowSymLinks AllowOverride None &lt;/Directory&gt; </code> You should change it to the following: <code> &lt;Directory /&gt; Options FollowSymLinks AllowOverride All &lt;/Directory&gt; </code> The <code> AllowOverride </code> directive i...
Can't get permalinks working!
wordpress
I'm trying to customize a theme, and I see that the header.php calls "wp_head()". I can't seem to find an implementation of this in the theme, so I presume there is a default implementation that implements, for example, the Color Options settings as specified on the admin page. So my related questions are: Is there som...
Is there somewhere I can see this default implementation? <code> wp_head() </code> function simply triggers the <code> wp_head </code> action hook that runs all callback functions that were added to this hook using <code> add_action('wp_head','callback_function'); </code> So there is no default implementation . Can thi...
Where is default wp_head() implemented?
wordpress
I'm building a website that uses the GD star rating plugin . Right now, I'm using the following code to retrieve two posts of the current page (a custom post type called <code> bbp_topic </code> ) and sort them by vote: <code> &lt;?php query_posts('gdsr_sort=thumbs&amp;posts_per_page=2&amp;post_parent='.$post-&gt;ID); ...
<code> gdsr_ftvmin=1 </code> is probably the query parameter you need
Is there any way of only retrieving posts with one or more thumbs up (GD star rating plugin)?
wordpress
As the title says, i would like a nice bit of coding to stick in my functions that pre-loads any images that are attached to the next post. This means that whilst my users are browsing, they page will load, but it will actually be loading the next page, so when you click-through, the images should already be there and ...
This is what cam of the other piece of code - BIG thank you to @Ivan Ivanic <code> &lt;?php $next_post = get_adjacent_post(false, '', false );// set last param to true if you want post that is chronologically previous //for debug if(!empty($next_post)){ echo 'Next post title is: '.$next_post-&gt;post_title; } else { ec...
Wordpress: Preload next post images
wordpress
Is there any way of changing the post order, posts number, etc via user click? The same way you can choose displaying questions by time and vote here at StackExchange. How to accomplish that?
Check the WP Sort Plugin, it does exactly what you need: http://wordpress.org/extend/plugins/wp-post-sorting/
Is there any way of changing the post order via user click?
wordpress
I have been at this for days now, going through plenty of answers here, guides on using .htaccess, guides on using add_rewrite_rule() within Wordpress and examples throughout the web. I am not sure if there is a malfunction in my regex to detect the correct URL, or a disconnect between what I want to accomplish and wha...
WordPress rewrite rules by default are no longer stored in the Apache configuration, but are handled by WordPress itself. This was probably not the case when that forum topic was written (5 years ago), but currently only "external" rules end up in the Apache configuration, all others are stored in the database and hand...
Separate page for comments using permalinks and add_rewrite_rule
wordpress
Hi to all it's a few days that I'm trying to add some new functions to my theme option-panel, you can see my questions here: stackexchange-url ("How to add an export function to a custom Option Theme Page") stackexchange-url ("Add a preview to a Wordpress Control Panel") stackexchange-url ("Modify CSS via Theme Control...
3 steps: php <code> &lt;?php wp_enqueue_script( 'jquery-ui-sortable'); </code> html <code> &lt;div class="metabox-holder"&gt; &lt;div class="postbox-container"&gt; &lt;div id="my_div" class="meta-box-sortables ui-sortable"&gt; &lt;div class="postbox" id="el1"&gt; &lt;h3 class="hndle"&gt;&lt;span&gt;title2&lt;/span&gt;&...
How to add drag and drop functionalities to a div inside option panel
wordpress
I'm having an issue with a third party plugin called WP-Calendar, where clicking on the "next" and "prev" links in a small calendar results in a redirect error. This problem only appears to be happening on archive pages, as I have the calendar on the front page of a few MU pages and it does not have the same problem. C...
As per the discussion in the comments, using <code> . </code> as a value for the "Category base" will send Apache into an infinite loop. Getting rid of the Category base in the URL is actually pretty tricky, just because of the way WordPress expects things to work. It you want to use a single character for this, though...
Redirect Problems with Archive Page and GET variables
wordpress