question
stringlengths
0
34.8k
answer
stringlengths
0
28.3k
title
stringlengths
7
150
forum_tag
stringclasses
12 values
For some reason, I'm having difficulty converting a date value stored in a meta field to a unix timestamp (and back again). If I save the date as a string it all works fine, but if I convert it to a timestamp using <code> strtotime </code> it won't save the value. My working code looks like this: <code> &lt;?php add_ac...
Looking at http://www.php.net/manual/en/datetime.formats.date.php I dont think strtotime will convert a DD/MM/YYYY to time correctly. However it can do MM/DD/YYYY or YYYY/MM/DD. Try using the date format of YYYY/MM/DD Or if thats not to your liking then you can use the same date format but you will have to, on save, sp...
custom field value date convert to unix timestamp problems
wordpress
I am using <code> get_posts </code> and <code> get_comments </code> to build several loops on the page, at which I am having some issues in pagination. I have the global posts per page option (Settings > Reading) set to 10 , and this seems to vary the problem. As of now, I can easily get to Page 2 - http://dev.ashfame....
t31os says: [See edit history for previous code and comments] Using Ajax to paginate your queries I've put together some code that will fetch your posts and comments via ajax using simple prev/next navigation via ajax. 1) Replace all the code you posted in your author.php with the following.. <code> &lt;?php $cat_setti...
Stomping WP_Query in author archive to facilitate pagination with custom queries
wordpress
I have a question. How can I clear the cache when a post is submitted ? Actually, I need to clear two speficied pages which display these articles ? By default, I have noticed the <code> index.php </code> is cleared automatically when a post is submitted. But not <code> Archive page </code> or <code> Category page </co...
Hm, I am not sure but I think that whole cache should be invalidated on publishing of new post... Had you tried to enable debug info in W3TC and check why are those pages aren't refreshed? As for manual cache clear, from plugin's FAQ: How can I flush the cache without using the WP Admin interface? It's possible to empt...
Clear cache when a post is submitted
wordpress
I'm finding a way to redirect to a sub-domain. Sub-domains contain instances of multiple languages, say for an example -: <code> http://mysite/?p=7694 </code> This is the English site and I want it to redirect to (when user selects particular language) <code> http://chinese.mysite/?p=7694 </code> Is there a simple way ...
You can Use qTranslate , this WordPress plugin let you have an easy to use interface for managing a fully multilingual web site. One-Click-Switching between the languages - Change the language as easy as switching Choose one of 3 Modes to make your URLs pretty and SEO-friendly. - The everywhere compatible ?lang=en, sim...
Wordpress | Sub-domain switching
wordpress
Is there any RSS feed to keep track of the Newest Plugins published on wordpress.org?
Update: Found it from the dashboard widget code, its http://wordpress.org/extend/plugins/rss/browse/new/ As a workaround, you can use Page2rss.com to create a feed for that page - http://page2rss.com/page?url=wordpress.org/extend/plugins/browse/new/
How to keep track of new plugins published on wordpress.org?
wordpress
So what i would like to do is order in some CSS depending on the value of a custom field. The code below just says that if there is ANY value, do X, else do nothing... <code> &lt;?php $pageNumbered=get_post_meta($post-&gt;ID, 'page-number', true); ?&gt; &lt;?php if ( $pageNumbered ) : ?&gt; &lt;div class="page-number l...
Sorry but it's not clear what you want to do. From what I understand is you simply want to use an elseif statement: <code> &lt;?php $pageNumbered=get_post_meta($post-&gt;ID, 'page-number', true); ?&gt; &lt;?php if ( $pageNumbered ) : ?&gt; &lt;div class="page-number left"&gt; &lt;?php echo get_post_meta($post-&gt;ID, "...
How to make condition, based on custom fields value?
wordpress
I have a website that needs to display state-specific versions, for a few states. Obviously, I will need to parse the IP address to gain geographic information. Before I start making that plug-in, I figured I'd shoot a question out to the collective. To further explain my situation, the website has a different "version...
I guess stackexchange-url ("this thread") will steal you more than a day. After reading through it and all the code it contains, you'll be more than happy... or maybe just confused ;)
What is the best practice to localize content? (Geographic not langauge)
wordpress
I have over 400 interviews on my site and my audience keeps asking me for a way to sort through them. I don't have time to tag all 400 interviews. Do you think there's a way for my audience to tag interviews themselves?
Andrew, Matt Mullenweg uses a similar feature on on his blog, Ma.tt , that lets users tag photos. He released the code as a plugin, Matts Community Tags . You will have to create a custom taxonomy for the tags and add some additional code to your templates to make it work. See the discussion on the WordPress.org forums...
How can I let my audience tag my posts?
wordpress
I'd like to find an optimized, WP_Query-safe method for generating a dynamically-populated copyright statement for the bottom of my themes. That is to say, I'd like to check the date (by year) of my oldest and newest posts and then output something along the lines of <code> [blog name] &amp;copy; [oldest post year]-[ne...
Here's what I use: <code> function oenology_copyright() { global $wpdb; $copyright_dates = $wpdb-&gt;get_results(" SELECT YEAR(min(post_date_gmt)) AS firstdate, YEAR(max(post_date_gmt)) AS lastdate FROM $wpdb-&gt;posts WHERE post_status = 'publish' "); $output = ''; if($copyright_dates) { $copyright = "&amp;copy; " . $...
How do I create a dynamically-updated copyright statement?
wordpress
Anyone who has experience in building wordpress plugin using eclipse PDT? My situation is: I need to build plugin that extend another plugin (look at it as premium version from another plugin) I already created project <code> plugin core </code> (the original plugin) by importing from svn repository I created eclipse l...
Create WordPress as a project. I have several such projects, trunk, old versions … for the following, I just use a project named WP Latest Final . You can use the standard installation with <code> /wp-content/plugins </code> . I put my <code> wp-content </code> directory in a Dropbox and stackexchange-url ("tell WP via...
Strategy On Building Plugin Using Eclipse
wordpress
Is it possible to clone the plugins and settings from a WordPress site to a new fresh install? I don't want any of the content from the original site I just want all the plugins used and their settings. Just ftp'ing the plugins into the new install doesn't work. It's really important that all the settings are saved fro...
Usually blog settings, sidebars and plugins option are located in wp_options table. If you copy whole table except option_name IN ( 'siteurl', 'home' ), You get whole "old" configuration.
Clone plugins (and settings) to new installation?
wordpress
I want to include a slider in the default Wordpress theme on the home page. I did manage to get the page to show using <code> &lt;?php if ( is_home() ) { include ('slider.php'); } ?&gt; </code> but it doesn't look like it's loading the jquery script it needs or the style sheet. I know there's a conflict with scripts an...
UPDATE! What I did was just include the slider I was trying to use. I linked the jquery scripts that page needs via the <code> &lt;?php bloginfo('template_directory'); ?&gt; </code> method. I did notice that it takes a couple of seconds to load that portion of the page, but it works. I still think this can be improved,...
What's the correct way to include files in Wordpress TwentyTen theme with it's own jquery scripts and css?
wordpress
This question is a little different then the others floating around here. The most similar one is "stackexchange-url ("How to get the parent's taxonomy ?")". I have a music cms setup that utilizes two post types: album and album media and a few taxonomies: genre , year , and artist . In the footer of every single-album...
As per comment I also see some trouble understanding <code> album </code> and <code> album media </code> essence. You are also mixing up terminology a bit with <code> terms </code> and <code> taxonomies </code> ( <code> term </code> is item in <code> taxonomy </code> ). So I am going to focus on your summary and leave ...
How to dynamically build a multiple taxonomy query loop within a post type's single loop?
wordpress
is it possible to add extra fields via the functions.php script for attachments in wordpress? Tried loads of examples but none seem to work. Worried an existing plugin might be affecting my attempts but its not clear if its even possible. best, dan.
Here is a tutorial that shows how to add custom fields to the attachments/media gallery/thickbox/iframe/whatever-you-call it overlay. I've successfully used it, but have not yet taken it much further by adding radio buttons/checkboxes/etc or messed with limiting the changes to particular post types, but that all looks ...
custom fields for attachments?
wordpress
I have 7 posts, like this: 1 2 3 4 - this is the current post 5 6 7 As noted, number four is the current post being displayed. I need to create a query that will allow me to display the previous 3 posts (by publication date) and also the three posts after. This can be done with two separate queries. I've been able to d...
This can be done in a single query, though i can't speak specifically about how well this query will perform(i've not spent a great deal with Union queries - never had a need, till now).. First, a function to select two sets of results, but using union to return them as a single result set. <code> function get_post_sib...
Get Next / Prev 3 Posts in Relation to Current Post
wordpress
Why doesn't wp_title() display the author's name on an author archive as it does for a category or date archive? How can I hack this functionality? header.php calls: <code> &lt;title&gt;&lt;?php wp_title ( '|', true,'right' ); ?&gt;&lt;/title&gt; </code> Here is my author.php: <code> &lt;?php get_header(); ?&gt; &lt;?p...
I see my name in the title when viewing author pages. <code> wp_title() </code> runs this code during execution.. <code> // If there's an author if ( is_author() ) { $author = get_queried_object(); $title = $author-&gt;display_name; } </code> Perhaps your author(s) don't have a display name set? Additionally be sure to...
wp_title() handling of author page
wordpress
I have a main menu where I display pages. All the pages have associated sub-pages, however in the menu some of them are displayed by themselves without sub-pages and some are displayed with a submenu as a list of all sub-pages. The pages in the menu are sorted according to the menu order specified for them. (Please see...
wp_list_pages has limited functionality, and would be difficult to inject Categories into the mix without rewriting the function itself. Using the built in Menu functionality is likely the best way to go, because you can at least set individual item classes, allowing you to create Menu headers for your top level catego...
Add a specific category at a specific place to the menu that uses wp_list_pages
wordpress
I'd like to make a grid view that can be used to list items with a thumbnail, a primary description heading, a subheading, and possibly pricing details. This will not necessarily be for eCommerce as initially there will be no shopping cart. Similar to a post, clicking on the item should take you to a full "post" for th...
It's not that difficult at all its simply styling you category loop in to a table something like this: <code> &lt;table&gt; &lt;tr&gt; &lt;th&gt;Photo&lt;/th&gt;&lt;th&gt;Item Brand, Model&lt;/th&gt;&lt;th&gt;Description&lt;/th&gt;&lt;th&gt;PSI&lt;/th&gt;&lt;th&gt;GPM&lt;/th&gt;&lt;th&gt;RPM&lt;/th&gt;&lt;th&gt;HP&lt;/...
How to Make a Custom Grid View
wordpress
I recently published a podcast hosted on WordPress.com on iTunes and it says "Podcasts by Unknown". It seems like it is missing the author tag. My question is that how can I add the author tag to the RSS since I used the RSS widget to expose my RSS?
iTunes uses extra tags for author information, category classification, ... I believe you can't add these using WordPress.com . What you can do is pick up your feed using FeedBurner and submit that URL to iTunes instead. FeedBurner has support for podcasts and allows you to fill in the extra iTunes tags.
WordPress.com podcast feed missing iTunes tags?
wordpress
I'm using the following code branch to execute some theme setup options... <code> $myTheme_initialized = get_option('myTheme_initialized'); if (is_admin() &amp;&amp; !$myTheme_initialized &amp;&amp; isset($_GET['activated'] ) ) { //do setup stuff } </code> What hook can I tap into when the theme is deactivated?
http://www.krishnakantsharma.com/2011/01/activationdeactivation-hook-for-wordpress-theme/# Pretty good writeup for activation and deactivation Same thing is here on SE stackexchange-url ("Theme Activate Hook")
How to determine when my theme is deactivated?
wordpress
Basically if you see the picture below there are 5 tab items in my groups page: Now, I want to be able to remove some of them. I want to be able to remove "Members" and "Send Invites" (for instance). This is on the frontend groups page. When you select a group and go to view it. I don't want to edit core files really, ...
Managed to crawl through the core code and find this function: <code> bp_core_remove_subnav_item </code> So you can do something like this: <code> function remove_group_options() { global $bp; bp_core_remove_subnav_item($bp-&gt;groups-&gt;slug, 'members'); bp_core_remove_subnav_item($bp-&gt;groups-&gt;slug, 'send-invit...
Remove tabs from buddypress groups and members pages
wordpress
I'm trying to add an image in my CSS with the theme folder code, <code> &lt;?php bloginfo('template_directory'); ?&gt; </code> , which works in HTML but for some reason it's not working in the CSS. Does anyone know why or a solution? Here's my code: <code> background: url("&lt;?php bloginfo('template_directory'); ?&gt;...
That's because php code inside a CSS file is not parsed unless you configure your server to. Just use it as a relative path to the image (as per the CSS file). <code> background: url("images/bg.jpg"); </code>
I'm trying to add an image in my CSS
wordpress
I'm finding that SEOmoz is showing page titles with ASCII when indexing my customer's site http://bulldogfencespokane.com . I'm concerned that this is how search engines will index the site. I'd love to remove commas and apostrophes but it would change the sentence structure entirely. Is there a way to clear up this fo...
ASCII characters will not cause any issues with search engines and they will be displayed properly. SEOmoz does this to avoid any chance of sql injection via its form fields.
ASCII titles with Yoast SEO plugin
wordpress
Hey Guys, I'm using a meta box to store a bunch of page ID's. When I try to pass the page ID's to the post__in parameter of WP_Query it doesn't work becuase the metabox comes throug as a string, when it needs to be a comma separated integers. So, say the "relatedpages" meta box contains: 55, 33, 22 <code> $relatedpages...
<code> 'post__in' =&gt; explode( ',', $relatedpages ) </code>
Passing meta_box string to post__in?
wordpress
Im trying to build a Featured post slider to show any post that i <code> mark as a "featured" </code> (with a in-post option) regardless the category or tag type... Im new to wordpress and although I understand a little bit php language im not a coder :( The slider is already working. The question is, how can can i bui...
All you need is a simple query and to iterate over that query a couple of times so you can build the two required lists. <code> WP_Query </code> has a convenient method for resetting the pointer in the posts array, so you can loop over it again, called <code> rewind_posts </code> though i believe inside custom loops yo...
PHP loop that selects posts with a particular in-post option
wordpress
I've created a page that includes a size such as 5x10 since the given term is something people often Google for, together with some other words. Wordpress is converting 5x10 to: &amp; # 2 1 5 ; (without the spaces) Is there any way to prevent this? I suppose that there are places where this feature would be useful but ...
This is performed by <code> wptexturize() </code> . Unfortunately it saves replacement lists as static variables which you can't modify. So your options are: Remove <code> wptexturize </code> filter from related hook (depends on where you have that replacement done). Write and add your own filter that will replace conv...
'x' Converted to html code in example: 5x10
wordpress
Since WP 3.1, it's been possible to use Tumblr-style post formats. I want to use the 'aside' option in a theme, but I want it to have a different title in the WP admin area. So, for example, when a user is writing a post, they have the option for the post to be, say, either 'Standard' or 'Quick' -- rather than 'Standar...
I think this is the only way for now. Put this in your functions.php in your theme folder or create a simple plugin: <code> function rename_post_formats( $safe_text ) { if ( $safe_text == 'Aside' ) return 'Quick'; return $safe_text; } add_filter( 'esc_html', 'rename_post_formats' ); //rename Aside in posts list table f...
Is it possible to rename a post format?
wordpress
I'm using the following code to create custom write panels: <code> &lt;?php $key = "project"; $meta_boxes = array( "project_services" =&gt; array( "name" =&gt; "project_services", "title" =&gt; "Services", "description" =&gt; "List the services provided for the project."), "project_name" =&gt; array( "name" =&gt; "proj...
Try this? <code> &lt;?php function get_project_services() { global $post; $data = get_post_meta( $post-&gt;ID, 'project', true ); $project_services = $data['project_services']; return $project_services; } ?&gt; </code> Then in your template file: <code> &lt;p&gt;&lt;?php echo get_project_services(); ?&gt;&lt;/p&gt; </c...
How to display this meta data (an array) in form of a function (created with a custom write panel)?
wordpress
Is there a way of for instance, insert a post and assign a category to it, without accessing Wordpress' back-end?
Yes @janoChen, you can use wp_insert_post, take a look at this answers: stackexchange-url ("WP insert post PHP function and Custom Fields") stackexchange-url ("Fron-End Post Submission")
Is there a way of posting or inserting content directly to the database (without entering the wp-admin)?
wordpress
Pretty self-explanatory. How does one add another user to this function for functions.php, i.e., user2, who will be shown different menu items than user1? I tried adding another <code> if($current_user-&gt;user_login == 'user2') </code> condition, but no luck. User2 will have different admin rights, if that matters. Bu...
Why not just add another if? <code> function remove_menus(){ global $menu; global $current_user; get_currentuserinfo(); //check first user if($current_user-&gt;user_login == 'user1'){ $restricted = array( __('Links'), __('Comments'), __('Appearance'), __('Plugins'), __('Profile'), __('Tools'), __('Settings') ); end ($m...
How to add another user to this remove_menu function?
wordpress
I have post type 'product' and hierarchical taxonomy 'types' attached to it. In this taxonomy, I have terms: 'dry-clean', 'washer', etc. With several sub terms on each terms. In my situation, I need to display, eg: http://example.com/types/washer -> display all sub terms on it http://example.com/types/washer/ {subterm}...
These types of URLs are supported since WP 3.1: <code> register_taxonomy( 'types', 'post', array( 'hierarchical' =&gt; true, 'rewrite' =&gt; array( 'hierarchical' =&gt; true ), ... ); </code> Remember to flush the rewrite rules after making the change. The template you would use for both parent and child terms is taxon...
Taxonomy, Terms, and Template Files
wordpress
When a post is split on more pages TwentyTen theme use the native function <code> wp_link_pages </code> to display a navigation page bar at the end of post. I am trying to style those elements for my theme, but unfortunately it seems that the current page number cannot be styled. I imagine that I should override the <c...
Unfortunately, there is no way to do this just with native functions: WP is … request agnostic and produces always links to the current page (nav manus, list pages …). Also, you cannot use a filter, because <code> wp_link_pages() </code> has no appropriate filter. In my themes, I use an own function, based on this code...
How to style current page number (wp_link_pages)?
wordpress
We're using Facebook Comments for the comment functionality on our WordPress blog. I thought it'd be nice to embed the page with Facebook Moderation tools on the WP Dashboard. That way, we can immediately see who commented on what when we log in. I've looked for the functionality to embed an html page in a dashboard wi...
<code> function facebook_setup_function() { add_meta_box( 'facebook_widget', 'Facebook Moderation Tools', 'facebook_widget_function', 'dashboard', 'normal', 'low' ); } function facebook_widget_function() { include ('facebook.php'); } add_action( 'wp_dashboard_setup', 'facebook_setup_function' ); </code> add the above t...
Embed a page within WordPress dashboard?
wordpress
How can I force the user to first choose a category before continuing to the editor when creating a new post? I want to stackexchange-url ("set some default content"), but this is based on the category, so I need to know that before showing the editor (unless I do some fancy Ajax stuff, but in this case I don't want to...
I solved this by hooking into <code> post-new.php </code> , and checking for a <code> category_id </code> request parameter. If it does not exist, I display a form with a category dropdown that submits back to this page, and then call <code> exit() </code> so the regular post form does not display. If it exists, I set ...
Force category choice before creating new post?
wordpress
I am developing a theme for my blog using Twenty Ten as starting point. Now, I am trying to understand how it manages the background image that can be set in theme options but I wasn't able to find the code. Can you help find where is that implementation?
This is native WP feature, it is set up in Twenty Ten with simple <code> add_custom_background() </code> call in <code> functions.php </code> .
Where is the code that set the background image in TwentyTen theme?
wordpress
hey guys, when posting a youtube video link in the backend (in a post or a page) wordpress is automatically creating the embed code for me. Is it possible to add a filter to that? I'd love to change the width and height of all embedded videos to 100%? e.g. <code> &lt;object width="100%" height="100%"&gt; &lt;param name...
Yes, there is a filter for Oembeds. Two (or even more) in fact: <code> oembed_result </code> will be called before it is put in the cache (so only once per external embed), and <code> embed_oembed_html </code> after the cache (so every time the item is displayed). If you only need to modify it once, <code> oembed_resul...
add_filter to youtube embeds?
wordpress
This is the code I used to create the meta boxes: <code> &lt;?php $key = "project"; $meta_boxes = array( "project_services" =&gt; array( "name" =&gt; "project_services", "title" =&gt; "Services", "description" =&gt; "List the services provided for the project."), "project_name" =&gt; array( "name" =&gt; "project_name",...
Modify your array definition with something like this to add a new element of the array that specify the type of the field <code> "project_overview" =&gt; array( "name" =&gt; "project_overview", "title" =&gt; "Overview", "description" =&gt; "Write an overview of the project.", "type"=&gt;"textarea") </code> Then in you...
How to add a textarea to only one of the fields of this custom metabox?
wordpress
I want to make minor css-changes based on the choice of the top (root) menu. What's the proper way to handle this in WP? //edit// It's a website (pages), no blog, and basically, the colors of some links and some images should depend of the choosen top-menu-item. Example, page-structure: * Start * Products * Prod.categ....
My answer adds a class to the <code> &lt;body&gt; </code> element via the <code> body_class </code> filter. This is probably the easiest way to apply extra formatting to any element on the page. The added classes are <code> wpse14430_products </code> , <code> wpse14430_services </code> or <code> wpse14430_contact </cod...
Minor css-change based on topmenu - how?
wordpress
I'm running several Wordpress installs on my desktop machine using XAMPP. I would like to move them to my laptop as well. Can I simply copy the htdocs, mysql and phpMyAdmin directories to the laptop, replacing the ones from the new install? What if I copied everything in the directory structure under XAMPP? Will this w...
From personal experience sync between two different computers work best in one direction. For example your desktop is primary and notebook is precise mirror (yep, of whole directory tree preferably with tool that doesn't touch unchanged files). Two way sync gets messy very fast for web stack. If you need to actively wo...
I have a desktop and a laptop: What's the best way to move between local installations?
wordpress
I have a site that displays the content only to registered users. Most of the content is available to all the users, but some of it is user specific (i.e. all users have that page, but each sees a it's own content which no one else can see). Any idea as to how I can restrict(and display) specific content per specific u...
I had coded something like this a while back and i remember wanting to upload it to the plugin repository but never had the time, Basically it adds a meta box to the post or page edit screen and lets the user select specific users by name or roles and then it check using <code> the_content </code> filter, so here you g...
How do I display a user specific content?
wordpress
This is kind of a stupid question... I scheduled a action to run every hour: <code> if(!wp_next_scheduled('my_hourly_events')) wp_schedule_event(time(), 'hourly', 'my_hourly_events'); add_action('my_hourly_events', 'the_function_to_run'); function the_function_to_run(){ echo 'it works!'; } </code> How can I test if thi...
My favorite plugin for that is Core Control which has very nice module for display of what is going in the cron - which events are set up, when are they next firing, etc. On getting your hands dirty level see <code> _get_cron_array() </code> , which returns internal stored data for cron events (top level of keys are ti...
How to test wp_cron?
wordpress
How to find out if a particular plugin is enabled in a sub-blog in a multisite blog?
Hm, I am not entirely sure about mechanics here. Usual <code> is_plugin_active() </code> checks if plugin is in <code> active_plugins </code> option. By this logic you could probably retrieve <code> active_plugins </code> of specific blog with <code> get_blog_option() </code> and check it for plugin.
How to Check If A Plugin Is Enabled Through API?
wordpress
I registered custom post type by <code> register_post_type('new_post',$args); </code> So new post url looks like `http://myweb.com/new_post/post_name Can I change _ later _ the part of url from <code> new_post </code> to something else?
It would help if you listed your $args array, but, the portion you are looking for is under 'rewrite'. Here's the way I like to build an $args array for registering a post type: <code> // set up the labels $labels = array( 'name' =&gt; _x('Archived Jobs', 'post type general name'), 'singular_name' =&gt; _x('Archived Jo...
can I chage url for register_post_type
wordpress
After installing wordpress and some plugins i am getting this error when i create a sitemap. I realy have no idea what this is and how to solve. Any help would realy be appreciated! <code> Warning: file_put_contents(/home/ugywhzos/domains/mydomain.com/public_html/sitemap.xml) [function.file-put-contents]: failed to ope...
If you already have the files <code> sitemap.xml </code> and (if you have gzip enabled in Simple Google Sitemap) <code> sitemap.xml.gz </code> in the root directory of your WordPress installation, try deleting them and create new empty files with the correct permissions for that plugin, then manually run the sitemap ge...
What is this error message?
wordpress
Hi I'm running a site that makes heavy use of a custom taxonomy called 'Games' and using the Simple Term Meta plugin the metadata for these terms. Using pretty much a copy of the code from wordheavy.com it's working fine except for two things: it throws an error on the 'Game' taxonomy page (Warning: Missing argument 2 ...
The issue at first glance appears to be here.. <code> add_action('game_edit_form_fields', 'game_form_fields'); add_action('game_add_form_fields', 'game_form_fields'); function game_form_fields($tag,$taxonomy) { </code> Your function is expecting 2 vars to be passed from the hook, but your <code> add_action </code> call...
Error in Custom Taxonomy UI
wordpress
I am using the <code> &lt;?php wp_create_user( $username, $password, $email ); ?&gt; </code> function in a contact form to create a subscriber when the user enters infomation on the contact form, thus in the background adding their email address to the database and giving them an account for site access. Does this way ...
The function <code> wp_create_user </code> calls <code> ‪wp_insert_user‬ </code> which check to see if <code> $username </code> and <code> $email </code> already exists and if so it returns a new WP_Error so you wont have duplicate users in your database and it wont send the new user email more then once, but i'm not s...
WP Create User - Preventing repeated information
wordpress
This is a common function that adds default text to all posts: <code> add_filter( 'default_content', 'my_editor_content' ); function my_editor_content( $content ) { $content = "default content goes here...."; return $content; } </code> How would this be changed to add the default content only to a post in one category?...
One possibility is this question/answer here by Jan Fabry, which asks for the default content in the process of creating the new post: stackexchange-url ("Force category choice before creating new post?") I ended up using a Quicktag as a way of easily getting the content into a post, and because the default content hap...
Default content for a post in one category?
wordpress
I have a page (not a blog post) I need to embed an iframe on (it's to "integrate" an external service's product catalog). I added the iframe code in the raw HTML editor and saved the page. I viewed the page, everything worked. I went back to the editor and switched from raw HTML to the Visual editor tab, added a line o...
I've had this code in a custom local plugin for a while. Or you could just stick it in your theme's <code> functions.php </code> : <code> // Allow iframe in TinyMCE function tinymce_add_iframe( $arr = array() ) { $extra = 'iframe[id|class|title|style|align|frameborder|height|longdesc|marginheight|marginwidth|name|scrol...
Switching From HTML to Visual Editor and Back Completely Strips Page Contents
wordpress
I am running Contact 7 form, and looks good for my needs. I have added it to Wordpress , for people to suggest ideas for our product. When users send an idea, they are given a message to say thanks. This message is configurable via the settings for the form in wp-admin Does anyone know how I could get Mr Burns to appea...
You can customize the "Your message was sent successfully. Thanks." message with-in the the form's edit page at the bottom so add something like this: <code> Your message was sent successfully. Thanks.&lt;/p&gt; &lt;p&gt;&lt;a href="http://pages.sbcglobal.net/bluealbino/SYP/images/mrburns-oh.gif"&gt;&lt;img width="234"...
Contact Form 7 - Show image on successful send?
wordpress
Using WP 3.1.1 as a CMS, using the Boldy theme. Home page is at http://www.dekho.com.au Advantage of using this theme, is that it comes setup with a homepage that has a gallery slider and some homeboxes at the bottom. To get to the blog, I had to dump all my posts into a category called blog. - The themes docco advises...
First, you need to change your Front Page settings: 1) Create a Static Page , called "Blog" (and a slug of "blog") 2) Create another Static Page , to serve as your site Front Page 3) Go to Dashboard -> Settings -> Reading 4) Change "Front Page Displays" from "Your latest posts" to "A static Page (select below)" 5) In t...
Change URL for Blog?
wordpress
I have 2 custom post types 'bookmarks' and 'snippets' and a shared taxonomy 'tag'. I can generate a list of all terms in the taxonomy with get_terms(), but I can't figure out how to limit the list to the post type. What I'm basically looking for is something like this: <code> get_terms(array('taxonomy' =&gt; 'tag', 'po...
Here is another way to do something similar, with one SQL query: <code> static public function get_terms_by_post_type( $taxonomies, $post_types ) { global $wpdb; $query = $wpdb-&gt;prepare( "SELECT t.*, COUNT(*) from $wpdb-&gt;terms AS t INNER JOIN $wpdb-&gt;term_taxonomy AS tt ON t.term_id = tt.term_id INNER JOIN $wpd...
Get terms by taxonomy AND post_type
wordpress
I was wondering if there was a way to prevent the addition of new categories into a taxonomy, essentially 'locking' the taxonomy. I'm programatically registering a taxonomy and filling it with terms via functions.php and would like it so you cannot add anymore into it. The Vision, REALIZED... Heres how my solution ende...
Categories, Tags & Taxonomies First i want to make this one clear: Everything is a Taxonomy . Tags is a non-hierarchical, Categories a hierarchical and both are built-in taxonomies. Same goes for eg. post formats (aside, chat, etc.). It's the same concept as with post-types (post, page, attachment, nav_menu_item, etc. ...
Is there a way to 'Lock' a Taxonomy?
wordpress
Just wondering if anyone had tried using any of the structure tags available to post permalinks with custom post types... I'm moving my "listings" posts on a site I manage from a category hack under Posts to their own custom post type, but I'd like to still keep some sort of numeric date reference in the permalink stru...
Hey goldenapples, rewriting the permalink structure does the trick. I've posted an example on my blog: http://madpress.org/display-date-in-custom-post-type-permalinks/564/ . This process, and other issues related to custom post type permalinks, are described more fully here .
Can /%year%/%monthnum%/%day%/ structure tags be added to custom post type permalinks?
wordpress
I'd like some posts to look different from others. Wordpress let's me easily switch themes for pages, but not posts. Is there a plugin that will let me do that for posts?
http://wordpress.org/extend/plugins/custom-post-template/
How can I change the theme of different posts using a plugin?
wordpress
I'm using CF7 to send some information to my email and everything's working fine, but I need to redirect the users to a different page after the email has been sent, by default the forms are sent to the same page via ajax, I was thinking about setting a hidden field with the page url but since the form submits asynchro...
Got it, needed to add this to the additional settings option: <code> on_sent_ok: "location = 'http://www.url.com';" </code>
Redirect to another page using contact form 7?
wordpress
I've got a CSV file of new posts which I'll be importing straight into the database. Is it safe to give a GUID of <code> http://domain/?p=[n] </code> where <code> [n] </code> is any number, as long as it's not a duplicate of an existing post?
Short answer: yes The GUID field is meant to represent a globally unique identifier for the post. In WordPress we just happen to use the URL. The GUID field should never be thought of as an actual URL, though ... just an identifier for the post. In reality, the GUID field could contain anything that's unique. But if yo...
Importing Direct to DB - GUID Question
wordpress
My question is simple, I'm using WP_Query to retrieve some custom type posts filtering by a taxonomy using tax_query. Now my problem is I would like to orderby the taxonomy, but from documentation and searching in the web I can't find a solution. The orderby in WP_Query let's you order by a bunch of fields even custom ...
No, it is not possible to order by taxonomy, because from a certain type of standpoint, that doesn't actually make much sense. Taxonomies are ways to group things together. So the point of having a taxonomy on posts would really be to have terms in that taxonomy that are shared between posts. If a taxonomy had terms th...
Using wp_query is it possible to orderby taxonomy?
wordpress
I have a child-theme -> parent-theme setup, where I need to have stylesheet called generated.css loaded in addition to the style.css file added by the active child-theme. The generated.css file is residing in the parent-theme and is being dynamically generated and provided by the parent-theme.. I started out the obviou...
Absolutely! Into functions.php, like you said. I'll call it cache_busting_styles because I like how it sounds. First, you set up the style via wp_enqueue_style, then call it during the action hook wp_print_styles, Also, you'll want to set up a variable and pass it in there as the version number as well: <code> function...
add generated stylesheet from parent theme after child-themes style.css
wordpress
I just stepped into the concept of post formats and was wondering why there are two out of 3 functions from the post format "API" offer absolutely the same functionality. Consider the following two concepts (A vs. B): <code> if ( have_posts() ) { while ( have_posts() ) { the_post(); // A) has_post_format if ( has_post_...
Edit <code> has_post_format() </code> requires a string, <code> $format </code> , as the first parameter; which means that it can only be used to test for explicit post-format types: <code> if ( has_post_format( $format ) { // Current post has the $format post format; // do something } </code> To determine if a post ha...
has_post_format() vs. get_post_format()
wordpress
I want to be able to create custom login errors. For instance if a user visits a restricted area without being logged in then I am redirecting to <code> wp-login.php?ref=access </code> and I would like to output <code> Restricted area, please login to continue. </code> or something similar. Any idea how to do this. I f...
From quick look at the login screen code (ouch): <code> add_action('login_head','ref_access'); function ref_access() { global $error; if( !empty($_GET['ref']) &amp;&amp; 'access' == $_GET['ref'] ) $error = 'Restricted area, please login to continue.'; } </code>
Creating custom login errors
wordpress
I have lots of posts in my website . I have used <code> default pagination </code> function for paging the post list in homepage . But I wanted to implement <code> lazy loading </code> instead of pagination just like in twitter . I don't have any idea about it's implementation in Wordpress . Please help me with this.
Take a look at Infinite Scroll plugin which Automatically append the next page of posts (via AJAX) to your page when a user scrolls to the bottom.
Implementing lazy loading in homepage posts instead of pagination
wordpress
I have added a custom user role of super_poster, basically they make 20 posts and once they hit $postlimit get auto-moved back down to contributer level, the moving down and post counting works ok, my problem is that the wp system adds the user into "none" instead of into contributer role <code> if ($count_posts &gt;= ...
You might want to use <code> WP_User::set_role( 'contributor' ) </code> instead. It unsets all current roles and sets the new one (the argument) too. So the above would be <code> if ($count_posts &gt;= $postlimit) { $current_user-&gt;set_role( 'contributor' ); } </code>
User Roles Not Sticking
wordpress
I've added a custom post type, which is working great; I've also added two metaboxes, which appear to work well, but the content in them always disappears after a few minutes. If anyone could help out on this I would be eternally grateful, S. //meta box code// <code> add_action( 'admin_init', 'add_custom_metabox' ); ad...
You need to check for <code> autosave </code> and avoid that , also check if you are in the right post type as <code> save_post </code> works on all posts: <code> function save_custom_details( $post_id ) { global $post; //skip auto save if ( defined( 'DOING_AUTOSAVE' ) &amp;&amp; DOING_AUTOSAVE ) { return $post_id; } /...
Custom Post Type Metabox - Not Saving
wordpress
A few weeks ago I created a new WordPress blog. I bought a new domain name for it, and I have not published/linked to the blog yet (because I wanted to get a few articles up first, I only have 2 so far). I have gotten about 10 spam comments already. I am confused how the spammers could be finding me?
What are your privacy settings? Go to Dashboard -> Settings -> Privacy If it is set to I would like my site to be visible to everyone, including search engines (like Google, Bing, Technorati) and archivers , then your site is actively being crawled/indexed by search engines, and thus visible to spammers. If it is set t...
How is my non-published blog getting so much spam?
wordpress
This is such a simple question, but I'm having trouble getting the answer. Is it possible to have a blog at WordPress.com and not have the WordPress.com banner (shown below)? Is it simply a matter of purchasing the "master of your domain" premium feature ? Or must I host my own WordPress.org installation (which is not ...
The ribbon is merely a way to quickly administer your site. It's actually there for self-hosted WordPress.org setups, too (though you can turn it off with a filter). But think for a few minutes about why you want it hidden. Do you want it hidden from just you because you don't need it? Do you want it hidden from you re...
Removing the WordPress.com ribbon
wordpress
can't seem to get this but how can i load info in a child's page from its parent? ie, i'm looking at an attachment and i can get the parents ID easy enough but not sure how to get the parents title, excerpt etc. <code> // attachment content above here then want to get and show some parents' content echo $parent = get_p...
You can try <code> get_post($post-&gt;post_parent) </code> or <code> get_page($post-&gt;post_parent) </code> so if you do: <code> $parent = get_post($post-&gt;post_parent); </code> You can get the title like this: <code> $parent-&gt;post_title; </code> And anything you want, you can <code> var_dump($parent) </code> to ...
get parent fields title, content excerpt etc
wordpress
I could not find a thread discussing this, so starting this one. I am currently working on a rather elaborate theme for 3.1+, and by elaborate I mean that in addition to styling and regular front-end functionality, I am including plugins at the core of the theme, both for back-end and front-end. So, to keep this a litt...
1) Is integrating plugins a common practice? Not really. Normally you got a theme that offers a base functionality. You then only extend the theme with plugins for special purpose like twitter stuff, event calendars, etc. Imo it makes sense. I'm currently working on an extremly slim theme that has some plugins (OOP app...
Integrating plugins in themes
wordpress
I can see <code> validate_user() </code> calls <code> sanitize_user() </code> with strict argument as true, which means uppercase letters are not allowed too. In source code, I found this comment <code> // If strict, reduce to ASCII for max portability. if ( $strict ) $username = preg_replace( '|[^a-z0-9 _.\-@]|i', '',...
Uppercase characters are not blocked in usernames on single site setups. Uppercase characters ARE blocked in usernames on multisite setups. The wpmu_validate_user_signup function forces lowercase a-z and numbers 0-9 only.
Reason for Lowercase usernames
wordpress
I'm in the middle of moving to WordPress from another CMS. I definitely have to keep the links intact, which are like this: example.com (Redirects to /blog) example.com/blog (The blog, displaying all the articles) example.com/blog/article (A specific article) example.com/about (A static page) example.com/portfolio (Ano...
Setting your permalinks as <code> /blog/%postname%/ </code> will solve your structure problem. In your theme, drop in a <code> home.php </code> file which redirects the user to /blog/ and you can set the blog to appear on a page with slug blog as the blog in your Settings > Reading Regarding the menu, you would have to...
How to display blog posts on a dedicated page?
wordpress
(First of all, sorry for bad english) If there are people here using wordpress as cms, you probably realize that you dont need comment system that much. Esspecially custom post types like products need a contact form system that saves coming input. What i am dreaming but cant coding: Changing comment system for custom ...
I also (ab?)use comments for "private" replies to posts, like product inquiries, suggestions, answers to contests, ... The advantage is that they are stored in the database and displayed in the interface without extra code from me (sometimes I add a filter to improve the formatting). Spam filtering and e-mail notificat...
Custom comment type maybe?
wordpress
Okay, I think I'm pretty close. I have the following going on: <code> $cat_id = get_cat_id('library'); wp_dropdown_categories('hierarchical=1&amp;parent=$cat_id'); </code> However, it doesn't work with $cat_id in there. It does work when I put the category's ID number in there (which I got when I echoed $cat_id), but o...
If you change your single quote marks in to double quote marks it should work : <code> $cat_id = get_cat_id('library'); wp_dropdown_categories("hierarchical=1&amp;parent=$cat_id"); </code> but if you really want to make it more flexible you can phrase your arguments as an array: <code> $args = array( 'hierarchical' =&g...
How do I list only children of a specific category in a drop-down?
wordpress
I'm setting up a WordPress site that has Flash puzzles embedded in the pages. (My site will have pages instead of posts). Each week I'll add a new puzzle to the site's Home page. When the site loads you'll see the newest puzzle. Older puzzles would be accessed through a dropdown menu. My question is how should I design...
I am not sure why you need pages over posts here. Using posts gives you ready made index home page, slugs and pretty permalinks give you link structure you want. You can just add some blurb on home page that says "bookmark this puzzle" with direct permalink.
Front Page Settings
wordpress
Summary: How can I get the name and the permalink of the object returned by wp_get_object_terms() ? Detailled: I created a custom post type called "ge_zielgruppe" and a taxonomy called "ge_zielgruppe_taxonomy". The latter can be attached to posts and to "ge_zielgruppe" post types. On the single page of "ge_zielgruppe" ...
To fetch the archive url for that taxonomy term, use something like this (I'm using your naming conventions above, and assuming that <code> $theZielgruppe </code> is a term object. <code> $url = get_term_link( $theZielgruppe, 'ge_zielgruppe_taxonomy' ); </code> To get the name, just use <code> $theZielgruppe-&gt;name <...
Proper use of wp_get_object_terms
wordpress
Why is it? I tried the same query in the console and it returned multiple rows. Here's the query: <code> $this-&gt;wpdb-&gt;get_row("SELECT * FROM ".$this-&gt;wpdb-&gt;users." WHERE status = 'active'", ARRAY_A); </code> It keeps returning the same single row when there are several active users. Am I missing something?
Indeed, use <code> get_row() </code> only when you expect to get one result, else you can use <code> get_results() </code>
$wpdb-> get_row() only returns a single row?
wordpress
I've got an <code> if ($comment-&gt;user_id) </code> block to pick an default admin comment gravatar (different than a non-user's). But I'd still like this gravatar to be used if a user comments using their registered email, even if they comment while not logged in. What is the best way to test for this? EDIT I'm alrea...
<code> if ($comment-&gt;user_id || email_exists($comment-&gt;comment_author_email)){ //comment by registered user $avatar = '/images/registered_user.png'; }else{ //comment by none registered user $avatar = '/images/non_registered_user.png'; } </code> with <code> &lt;div&gt;&lt;?php echo get_avatar($comment, 70, get_blo...
Best way to tell if a comment is from a user?
wordpress
I am setting up a site where there will be multiple users as Author, the owner doesn't want the authors to be able to view each others posts, since there are some meta fields with information he'd rather not have shared between the authors. Is there a way to remove the ability to view other authors posts? Thanks, Chuck...
If you want to prevent a user with the "Author" role to view other users' posts in the overview screen (they won't be able to view the details anyway), you can add an extra filter on the author: <code> add_action( 'load-edit.php', 'wpse14230_load_edit' ); function wpse14230_load_edit() { add_action( 'request', 'wpse142...
Prevent Authors from viewing each others Posts
wordpress
I am trying to figure out how to add a custom field to display an image instead of a title on the stats_get_csv from Wordpress stats. <code> &lt;?php if ( function_exists('stats_get_csv') &amp;&amp; $top_posts = stats_get_csv('postviews', 'days=2&amp;limit=6') ) : ?&gt; &lt;ol&gt; &lt;?php foreach ( $top_posts as $p ) ...
Return of that function should have post ID, right? Then it's straight <code> get_post_meta() </code> using that ID and name of your field. Update In your second code snippet <code> $post </code> is global variable, <code> $post-&gt;ID </code> is not tied in any way with return of <code> stats_get_csv() </code> functio...
Wordpress.com Stats stats_get_csv with custom field?
wordpress
I found a great piece of code here that returns the ID's of users by role. What I would like to do is modify it so it only returns the ID's of the users who have at least one post. I have tried to <code> INNER JOIN </code> the <code> $wpdb-&gt;posts </code> table and feel that I did that correctly but not sure. Here is...
Instead of a <code> JOIN </code> , you can use a <code> IN </code> with a subquery, to prevent duplicate results because of the join: <code> SELECT ID, display_name FROM wp_users WHERE ID IN (SELECT post_author FROM wp_posts) </code> This will not look at capabilities. If you also want that you can add them like a join...
Return ID of authors who have at least one post
wordpress
I have run into an issue trying to use the sidebar args (before_widget,after widget,after_widget,before_widget) as theme style friendly parameters for the function wp_list_bookmarks, that is that the wp_list_bookmarks output will look just as the one inside WP_Widget_Links. I almost copied verbatim the code of the link...
After a few <code> var_dumps </code> I know this: 1) When wp_list_bookmarks is called whithin WP_Widget_Links-> widget The <code> 'class' </code> parameter is ignored because the <code> 'category_before' </code> parameter doesn't have the <code> %class </code> wildcard. Instead <code> 'category_before' </code> will loo...
Problems with the sidebar args and wp_list_bookmarks
wordpress
my situation: I have a frontpage which filters 12 thumbnails out of 24 (each thumbnail represents a post's featured image), and displays them. The user has the ability to hide whichever post he wants from the frontpage. Let's say the user chooses to hide thumb #4, that means we now have thumb 1,2,3,5,6,7,8,9,10,11,12. ...
Will do. It's just a bit more complicated, but here it goes: <code> &lt;?php /** * WP Practica * Home Page Template */ get_header(); ?&gt; &lt;?php $options = get_option( 'practica_theme_settings' ); ?&gt; &lt;div id="main"&gt; &lt;!-- start div#main --&gt; &lt;!-- Optional 3D style --&gt;&lt;div class="dimWrap_content...
Query Posts (post meta)
wordpress
Right now, I'm able to dynamically generate js and css, based on my theme options To do that i set up a query var, that if present redirects to a php file, which then loads itself as a javascript file. Afterwhich it then takes the jqpostID, and and grabs any options i need to generate my js. I basically have to include...
adding these functions should do the trick. First things first, add this line to functions.php while you are working on this: <code> add_action('init', 'flush_rewrite_rules'); </code> What that code will do is constantly flush the rewrite rules, it makes this easier to test while you are working on it, instead of havin...
How Do I add a redirect rule to Wordpress?
wordpress
I see the following pattern over and over, stackexchange-url ("on this site") and on other places: <code> add_action( 'save_post', 'wpse14169_save_post' ); function wpse14169_save_post( $post_id ) { if ( defined( 'DOING_AUTOSAVE' ) &amp;&amp; DOING_AUTOSAVE ) { return $post_id; } // Other code... } </code> Why should I...
The <code> 'save_post' </code> action was added to core in 2.0 , and has always been an action. Looking through the current autosave procedures, it doesn't appear to call the <code> 'save_post' </code> action directly at any time. So the short answer is, no. There is no reason, and has never been any reason, to return ...
Return $post_id when DOING_AUTOSAVE?
wordpress
Each post has a lat/lng value attached to it via postmeta. I'm trying to grab all posts within a bounding lat/lng value. Here's the <code> get_posts </code> query: <code> $posts = get_posts(array( 'posts_per_page' =&gt; 100, 'post_type' =&gt; 'place', 'post_status' =&gt; 'publish', 'meta_query' =&gt; array( array( 'key...
You can filter generated SQL and add precision parameters that you need. Enable filters for <code> get_posts() </code> by adding following to query: <code> 'suppress_filters' =&gt; false, </code> And: <code> add_filter('posts_where','cast_decimal_precision'); function cast_decimal_precision( $where ) { return str_repla...
meta_query: using BETWEEN with floats and/or casting to DECIMAL
wordpress
Bought some hosting with BlueHost, and when I signed up, I carelessly choose 'DekhoForum' as my domain name. I proceeded to setup a website with Wordpress 3.1 at the root folder of that address. Realised that my company had already reserved some domain names with a different provider, that were more suitable. So we got...
Changing the Site URL
How do I switch my Wordpress to point to Parked Domain?
wordpress
I would like to use WordPress to not only run my site, but also to manage users, handle authentication, and read/write content via a client application, but I would like to avoid writing everything from scratch on the PHP-side, as I don't know PHP that well. Is there a "Services" plugin similar to that in Drupal , or s...
WordPress uses an XML-RPC interface in which you can define your own custom methods to it . And if server side coding is not your thing , then there are a few plugins that do most of the job for you: WordPress Web Service Extended API WP RESTful
WordPress as a data-store?
wordpress
I am using the code below to include jQuery in my Wordpress installation. I was previous calling the jQuery file using the standard HTML script but this was causing problems with a Wordpress plugin in IE9. When I use the wp_enqueue_script function, it solves the problem but then it breaks my custom Javascript file whic...
1) Only include scripts via wp_head(). For your custom script, register and enqueue it as such: <code> function mytheme_custom_scripts() { if ( ! is_admin() ) { $scriptsrc = get_stylesheet_directory_uri() . '/js/'; wp_register_script( 'mytheme_custom', $scriptsrc . 'custom.js' ); wp_enqueue_script( 'mytheme_custom' ); ...
Including jQuery in Wordpress
wordpress
Hi to all I need to run this twice a day: <code> UPDATE wp_posts SET post_content = REPLACE ( post_content, '[img]', '&lt;img src="' ); UPDATE wp_posts SET post_content = REPLACE ( post_content, '[IMG]', '&lt;img src="' ); UPDATE wp_posts SET post_content = REPLACE ( post_content, '[/img]', '" /&gt;' ); UPDATE wp_posts...
Creating your own schedules is a little messy (because they need to be persistent and stored in database), but it is quite easy to hop on one of the native schedules that run twice a day. <code> add_action( 'wp_version_check', 'my_function' ); function my_function() { //stuff } </code> As for running actual queries you...
Use Cron to modify posts via sql
wordpress
I have a rating system where the user can enter a custom field of either "Stars" or "Hearts", but whichever one they choose they have to enter a value of 1 thru 5. Using wp_query, I can successfully sort by one of these custom fields, but I'm not sure how to sort by both. Here is the code I'm using to sort by one of th...
I had the same problem and could not find a way to make this work with wp_query alone. Instead, I caught the posts_clauses filter and stuck my order_by there. This also meant doing a few joins. Basically, you set a function to catch the posts_clauses (or one of the more restrictive query filters; but let's just use thi...
How do I order by multiple custom fields using wp_query?
wordpress
Hi to all I would like to add a "premium" section to my wordpress blog and I would like to force users to click on a banner before being allowed to register to my blog, any step 2 step idea on how to solve this problem? The banner will be html or js. Thanks a lot to all!
This is a WAY open-ended question. I feel that if you did some research you'd find LOTS of answers. Here's how I would go about it. Install or modify your code to use a members only plugin. Lock all the Non-Member pages. I'm confused on what you men by check a banner, but if the banner is just going to a registration p...
Click on banner to register to the blog
wordpress
I am unable to access the new lightbox-style link popup window. When I try to open it, I get an "error on page" message, and the popup doesn't appear. I've tried on ffx, ie &amp; chrome, on a pc and a mac. I go to work and all is well, on all those same browsers, pc &amp; mac. I can't find any pattern. I've logged out ...
The problem turned out to be that I added some custom javascript further down the page hat was somehow ruining the tinymce popup js. I wasn't able to figure out exactly what was causing the problem, I needed to comment it out and it works okay now.
tinymce "Link" popup throwing error, not working
wordpress
Im using wordpress 3.1.1, in frontpage i need to display only the media uploads, now im using this acction: <code> add_action( 'parse_query', 'custom_query' ); function custom_query( &amp;$query ) { $query-&gt;set( 'post_type', array('attachment') ); } </code> add_filter( 'pre_get_posts', 'my_get_posts' ); function my_...
You almost have it right, it should be <code> attachment </code> instead of <code> media </code> since all media uploads are "called" attachments" in WordPress, so: <code> $query-&gt;set( 'post_type', 'attachment' ); </code>
How to change default post type / post to media or attachments
wordpress
have a website (www.americanbankingnews.com) that gets 40,000-50,000 page views today. It's currently sitting on a dedicated quad-core Xeon server with 8GB of ram. The site is powered by WordPress and MySQL (sitting on the same server) and I'm currently using W3 Total Cache for page and MySQL query Caching. Unfortunate...
Hi Matthew Paulson, I see your using W3 Total Cache but your database and object cache is set to disk. Caching objects and your database to disk can actually have a negative performance effect especially if your getting that much traffic. You can read more about the effects on caching database and objects to disk in an...
WordPress MySQL & PHP Performance
wordpress
I'm getting a puzzling error when I var_dump on $menu_id in the code below... First, the test code to create a custom menu on the fly and assign it to a registered menu location called "header-menu" (creates the menu but fails in assigning it to the theme's menu location)... <code> $menu_id = wp_create_nav_menu('my_tes...
I got that same error when i put the code you posted in my functions file so i wrapped it up in an if to run only once and i get the menu id using get_term_by and i assign the menu location using set_theme_mod() so here is your very own function to assign a menu to a location: <code> function scotts_set_nav_menu($menu_...
WP custom menus error > menu name already exists?
wordpress
I have one "branch" of my main site's navigation tree that should only be accessible to a set of registered, logged-in users. I understand how to query a user's role and capabilities. This question is specifically about what is the best way to leverage the build-in nav menu, but just hide an item conditionally. Do I ne...
Use your stackexchange-url ("own walker") and check the capability before you create an item.
Display navigation menu item conditionally based on user capabilities
wordpress
When you paste an image with a <code> class </code> attribute in the Wysiwyg editor, the pasted image no longer has this <code> class </code> attribute. This makes it harder to copy and paste images that are aligned with the <code> alignleft </code> or <code> alignright </code> classes. This used to work in WordPress 2...
Instead of pasting into the Visual editor, switch to the html editor for pasting any kind of html, or using shortcodes. I'd recommend checking the "disable the visual editor" checkbox in your user profile. Then install Mark Jaquith's Markdown on Save plugin for more readable formatting without the wysiwyg pitfalls.
Pasting images removes class attribute
wordpress
I'm using esc_url to sanitize my url. The only problem is that "my link" becomes "mylink". I wouldreally like it to become "my-link". Is there a way to change this?
<code> $url = esc_url ( str_replace(' ' , '-', $url ) ); </code> Replace the spaces to - chars before activating esc_url function, and your problem is solved.
esc_url removes white space. Can I change that to using '-'?
wordpress
http://blog.sanspace.in/ My blog home page is messed up. None of the plugins or sidebar widgets are working. Only the latest post is showed that too partially. However, other pages and posts (accessing through their URL) seems fine. http://blog.sanspace.in/contact/ [page] http://blog.sanspace.in/hello-world/ [post] I a...
I believe the page is truncated due to a fatal error. Look for an error log file in the wp directory or add the following line to wp-config.php to hopefully see the error text: <code> define( 'WP_DEBUG', true ); </code>
Wordpress home page doesn't work, but other pages do. How to rectify?
wordpress
how can I delete a background for #main only on my posts. I know that I have to create a conditional <code> if </code> statement in my functions.php file with <code> if (is_post()) </code> but I'm just not sure how to write it.
Take a look at the classes offered by your body_class() function to your <code> &lt;body&gt; </code> element. Then overwrite your div with the ID <code> #main </code> on your posts page with a higher specifity and set this div to <code> display: none; </code> .
Delete backgound for ID with conditional if statement
wordpress
I had a user recently who reported an issue with my plugin's options page not loading. They would click on the "settings" link but only got a blank page. There was also an issue with the rich text editor showing up on the category edit screen. I could not figure out why, on almost every other site but their's, the plug...
I think it has to do with http://core.trac.wordpress.org/ticket/15044 The problem appears to be localized around the use of ob_get_clean in the definition of apache_mod_loaded in the branch that has to parse phpinfo.
apache_mod_loaded setting can fubar plugins?
wordpress
I've made a custom widget which shows thumbs of my latest videos. These thumbs are set to be 300px wide, which is the same width of my sidebar. My problem is that i also want to be able to use it in my footer where the width of widgets are only 220px wide. So basically what i want to do is: if the widget is shown in th...
you can always get the thumbnail, but size it with CSS as Xavier mentioned.
Show widget differently depending on if it's in the sidebar or footer
wordpress