question stringlengths 0 34.8k | answer stringlengths 0 28.3k | title stringlengths 7 150 | forum_tag stringclasses 12
values |
|---|---|---|---|
I'm heavelly modified my Wordpress, it's amazing what you can do with wordpress hooks, actions.. But i'm not able to find how can i add mass action for users. Let's say i select 5 users and i want to asign them some user_meta value. | Unfortunately this isn't possible. Custom actions cannot be added to the bulk actions dropdown (see trac tickets: http://core.trac.wordpress.org/ticket/12732 and http://core.trac.wordpress.org/ticket/16031 ). For posts you can use the <code> restrict_manage_posts </code> hook to create another drop-down / add buttons t... | Add mass action to wp-admin/users.php | wordpress |
The Problem I first noticed this with the plugin Quick-Cache, which activates without problem, but doesn't shows up anywhere. Its menu it's simply not there. Found why, and became aware of the conflict, in the forums . Problem is that the plugin does all the capability checking using <code> edit_plugins </code> , remov... | I guess this would be of better use as a <code> mu-plugin </code> . EDIT: Now available as drop & play MU-Plugin. Also disables the »Theme« editor. <code> <?php ! defined( 'ABSPATH' ) AND exit; /** Plugin Name: Disable »Theme/Plugin Editor« */ if ( ! class_exists( 'disable_admin_editor' ) ) { add_action( 'plugin... | Alternatives to DISALLOW_FILE_EDIT wp-config Constant? It Breaks Some Plugins | wordpress |
Anyone know how to add quick comment moderation links for users who have permission to add/edit posts and comments? (Upprove / Unappove / Edit / Spam / Trash ). Note: in my comments.php I call the loop with <code> <?php wp_list_comments(); ?> </code> | Per default <code> wp_list_comments() </code> calls the class <code> Walker_Comment </code> . Its method <code> start_el() </code> calls <code> edit_comment_link() </code> and here we find a filter for your question: It is called <code> 'edit_comment_link' </code> and it passes two variables, the link text and the comm... | Add delete, approve, spam Links to Comments | wordpress |
Im trying to create a blog page that has each post separate with a border around each one. A good example I can think of would be http://blog.pagodabox.com/ . How every post is divided into its own style box. I tried running the loop, but I end up getting the border around the entire posts.. the code that i have so far... | You can do that entirely with CSS, almost no PHP coding required... try something like this: <code> <div id="services"> <?php if ( have_posts() ) : ?> <?php while ( have_posts() ) : the_post(); ?> <div id="post-<?php the_ID(); ?>" <?php post_class(); ?>> <?php the_content(); ?>... | How to separate each individual blog post? | wordpress |
I'm sold on this one. A client has reported he can't edit any text on posts or pages on his WordPress site, claiming the visual editor text is white and he can't click on any buttons. Not even the HTML tab works. He sent me a screenshot where I can see his text is appearing on white (even with red markings from the spe... | Since it works on some machines and not on all, chances are good it's not plugin or theme related. However, be sure to switch to twentyeleven and see if it's working there, as sometimes theme authors will enqueue scripts like jQuery or TinyMCE from Google CDN, which would be disabled if there's something (browser or OS... | Customer Support: TinyMCE stopped working (on some computers) | wordpress |
I am using Pronamic Google Maps ( http://wordpress.org/extend/plugins/pronamic-google-maps/ ) to add Google Maps to my post...I would like to do a couple of things: I noticed that the balloon, or info window, has to be clicked in order for it to appear, is there a way to make it appear by default? Also on the balloon, ... | I ended up just switching plugins...I am now using MapPress: http://wordpress.org/extend/plugins/mappress-google-maps-for-wordpress/ | Pronamic Info Window | wordpress |
In <code> wp-config.php </code> you're able to change how WordPress deals with post revisions. Specifically you're able to turn them off or specify a max number of revisions. I'd like to be able to set a max number or revisions on a post type basis. Is this possible? | Remove the action <code> 'wp_save_post_revision' </code> from <code> 'pre_post_update' </code> . It is set per default in <code> wp-includes/default-filters.php </code> with the default priority (10). Add your own function to this hook. You get the <code> $post_ID </code> as parameter, so detecting the post type is eas... | Per Post Type Revision Numbers | wordpress |
When I use the following code in a ( wpalchemy ) custom meta box, everything works fine. That is until I pressed 'add new'. At this point, the title, slug, featured image, etc.. are being pre-populated with the content from my 'products' post type. The code builds a drop down within my 'case studies' post-type, and pop... | After you create a custom loop, you need to restore the global post variables with <code> wp_reset_query() </code> . | using the loop in custom meta is messing up 'add new' post type | wordpress |
I'm getting an php-error on an server that runs php version 5.2.17 which doesn't support anonymous functions. I've never heard of that before (really new to php) but found out that only php 5.3.x supports the following code: <code> add_action('init', function() use($name, $args) { </code> Is there any way to solve that... | You have to rewrite your code without closures. It could look like this: <code> function wpse54191_plugin_init() { add_post_type('Netherlands', array( 'supports' => array('title', 'editor', 'thumbnail', 'comments') )); } add_action('init', 'wpse54191_plugin_init'); /* Add Post Type */ function add_post_type($name, $... | Custom post type causes php-error in php version 5.2.17 | wordpress |
I have set up a custom taxonomy on a custom post type using the following: (For the sake of example, the custom post type is called <code> newtype </code> and the new taxonomy is just called <code> newtax </code> . <code> // Create Custom Post Type for newpost add_action( 'init', 'create_post_type' ); function create_p... | What is the best way to allow <code> http://www.domain.com/newtype/newtax-term/post-name/ </code> to load, without redirecting? You have to add a custom rewrite rule to make this work. Otherwise WordPress doesn't understand the <code> newtax-term </code> part of your permalink structure and redirects you to the URL whi... | Custom Taxonomy Permalinks Redirection | wordpress |
How can I get the number of widgets that are active on a specific sidebar? Is there a core function for this? I want to add a class to each widget on a sidebar based on how many of them are displayed. Thanks. | After some research and based on the answer from Eugene Manuilov I made a function that adds custom classes to widgets in a specific sidebar ('sidebar-bottom' in my case) based on the number of widgets set in that sidebar. This will suit perfectly in horizontal sidebars and themes based on twitter bootstrap that need s... | Get number of widgets in sidebar | wordpress |
Hi I installed w3 total cache on my nginx powered site, I'm having errors however. For example when I enable page caching disk:enhanced I get: It appears Page Cache URL rewriting is not working. If using apache, verify that the server configuration allows .htaccess or if using nginx verify all configuration files are i... | Your main configuration file at <code> /etc/nginx/nginx.conf </code> has some pitfalls and it shouldn't be that complex. Let me share a simpler version for you to start with... <code> server { server_name www.yourdomain.com; # please replace the root path # ex: /srv/www/mysite.com/public_html root /path/to/wordpress/in... | W3Total Cache problem with Nginx | wordpress |
I have a function that is giving me this error - <code> Catchable fatal error: Object of class stdClass could not be converted to string in.... blah blah </code> Below is some of the code from the function. It is the last line that is giving the error but I can't work out why. I'm trying to display the term with ID 7 i... | Function <code> get_term_by </code> returns object or array (based on <code> $output </code> arg) on success and false if failed. But you treat it as string and try to concatenate it. So your code should be following: <code> $cat = get_term_by('id', 17, 'project_cats'); $html_content .= "<h3>" . rgpost('input_1')... | Trying to display terms from custom taxonomy within function | wordpress |
When submitting API key information and clicking "Connect to Twitter" in the WordPress "Twitter Tools" plugin, I get a 500 internal server error. Nothing is logged by apache or php. I'm using WP 3.3.2, Ubuntu Meerkat, apache2, PHP 5.3.3-1ubuntu9.10. Although I am not sure what their wp/web/php/wordpress server settings... | As the author of Twitter Tools, I can confirm it is alive and well. Twitter Tools 3.0 beta 2 was released earlier this year: http://alexking.org/blog/2012/01/22/twitter-tools-3-0-beta-2 Now that Social 2.5 is out, a final release of Twitter Tools 3.0 will be available once we have some time to finish testing. You can a... | Why Does the WordPress Twitter Tools Plugin give a 500 Internal Server Error? | wordpress |
what is the correct way to query the a Wordpress database, meaning to pull row and column info, and then place it into a corresponding table in the Wordpress admin? I'm wanting to do a query similar to that of the "links" section in the Wordpress admin, being able to both "edit" and "delete" the rows/columns individual... | Querying in WordPress is done by using the the <code> wpdb </code> variable. Be sure to always prepare your sql so WP can make it database safe. Example: <code> global $wpdb; $rows = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM `{$wpdb->prefix}TABLE_NAME` WHERE `var` = %d", 1) ); </code> Then you can loo... | How to query / DB requests? | wordpress |
When user writes a comment and hits the submit button, WordPress reloads the page, before the comment is shown to the user. Is there an Ajax-based solution that allows users to submit questions dynamically, without refreshing the whole page? | Save the following javascrip file <code> wpse54189-ajax-comments.js </code> inside your plug-in folder - say <code> plugins/plug-in-name/js </code> (or if this must go your theme, in your theme folder). <code> /* * jQuery autoResize (textarea auto-resizer) * @copyright James Padolsey http://james.padolsey.com * @versio... | Enable Submit Comment Without Page Reload (Using Ajax)? | wordpress |
Some of my posts' titles have leading words, followed by a colon. I am removing the leading words and the column of every post title in the loop with the following: <code> <?php $title = get_the_title(); $title_array = explode(':', $title); $first_word = $title_array[1]; echo $first_word; ?> </code> How can I als... | <code> $title = get_the_title(); $title_array = explode(':', $title); $first_word = $title_array[1]; $total_length_limit = 100; echo mb_substr( $first_word, 0, $total_length_limit ) . '...'; </code> | How can I remove the first two words and shorten get_the_title() | wordpress |
A client has requested we use a theme, and that theme has a Timthumb dependency. I know that there has been some serious vulnerabilities in the past, but what is the current state of that plugin? Can someone point me to an authoritative resource that addresses this vulnerability? It doesn't appear that the plugin is st... | Take a look here: http://ma.tt/2011/08/the-timthumb-saga/ I assume you know who Matt is. Also, Matt mentioned this guy in that link, and he's got some updates on the issue posted to his site http://markmaunder.com/2011/08/01/zero-day-vulnerability-in-many-wordpress-themes/ The short is, there's now TimThumb 2.0 which i... | Is Timthumb still broken? What security measures should be taken? | wordpress |
I would like to hide/lock the submit button to prevent comments with 15 characters or less for subscriber and contributers in the comment section below postings/pages. It should automaticly be visible/unlocked as soon there is an input of > 15 characters. (Prevents also (if possible at all) sending users to the error p... | The easiest way to achieve this is to use jQuery on the client side to handle this validation. There are a number of ways you can achieve this, though one of the easiest would be to use a ready made solution of which one can be found HERE You'll need to download the plugin file and include it within your header.php fil... | Empty comments field or <15 characters | wordpress |
I've got a shared hosting account with 3 separate domains on it. Each site is in its own directory, so via .htaccess there is a rewrite for each domain name to the corresponding folder. When I try to log in to WP, the redirect URL that shows up in the address bar has the domain's folder in it. Ex: www.domain1.com is un... | <code> @define('ADMIN_COOKIE_PATH', '/'); </code> Putting this at the top of <code> wp-config.php </code> allows me to log in. Not sure if this is the proper way to set everything up, but it works... EDIT That only solved half of the problem. Permalinks were then broken. @toscho had the proper suggestion for anyone who... | Shared hosting, multiple sites, can't log in to WP due to .htaccess redirection | wordpress |
I have a specific issue here. I have website using custom post types, and I need to create a specific functionality for these custom post types. From each custom post type the user should be able to "buy" the product the custom post represents. So my idea is to create programatically additional "page" which would be li... | You need to use custom endpoints for it. Read The Rewrite API: Basics article for more information, especially section Add Custom Endpoint . | Creating additional page with own URL for each custom post | wordpress |
Hi I'm trying to convert from a "example" wp_list_table that displays an array of data on the same page, to a "real life" table the pulls data from the database. I have the code setup to where I just need to add the DB query to make it work. I just don't know how to query the database and make it display correctly. Wou... | WordPress adds prefixes to tables names, which was setup on installation. So by default there is <code> wp_ </code> prefix for tables names. It means that by default table name for links will be <code> wp_links </code> . But you shouldn't care about standard tables name, because all of them exists as parameters of <cod... | Query the links Database | wordpress |
I have a plugin which is great but it's kind of aggressive, and it changes a lot more than it should (but there are no settings to fix this). I have a custom page template that calls wp_head('less') ... header-less.php, and i have an equivalent for footer-less.php. I basically want, in this custom header-less.php to DE... | A quick glance at that plugin shows that it loads the filters from an option, <code> trueedit_options </code> . You might be able to add a filter to <code> option_trueedit_options </code> and check the context of when that option is being loaded and return an empty array. It runs on <code> init </code> though, so not s... | How do i 'deactivate' a plugin only on a certain page template? | wordpress |
I register styles in <code> function.php </code> with <code> function my_scripts() { wp_deregister_style( 'header' ); wp_register_style( 'header', get_template_directory_uri() . '/css/header.css' ); wp_enqueue_style( 'header' ); } add_action( 'wp_enqueue_scripts', 'my_style_sheets' ); </code> I'd like to use different ... | Create a primary stylesheet and enqueue as normal. Then, make a series of conditional statements using WP core functions - <code> is_home() </code> , <code> is_404() </code> , <code> is_page_template('template.php') </code> and so on. In each of those conditionals, enqueue the stylesheet you want that overwrites your c... | How do I make header.php use different css for different pages? | wordpress |
WordPress don't show image thumbnail but save them. I have all version of image (eg. image.jpg, image-300x250.jpg) but WordPress don't detect them. Anybody got same problem as here? | I changed my thumbnail size to 300x240. It's odd but now it works! | WordPress save thumbnail but don't show it | wordpress |
I am hosting my own version of Wordpress, and I'd like to do a custom theme for it to suit my website. However, with so many bits and pieces of examples on the Internet, I'm not really sure how many PHP documents I should have, and what names are they given inside a theme. So far, i only understand that there are the f... | The template files list in Codex contains most of the templates. See also the template hierarchy page for dynamic, content-specific templates like <code> single-{post_type}.php </code> . Note that a valid theme only needs to have a <code> style.css </code> and <code> index.php </code> files, all other template files ar... | Default PHP document / names needed for a Wordpress theme? | wordpress |
I have a case where that are a lot of widgets in several custom sidebars. I am wondering if there is a simple way to alter the titles of each widget dynamically. Typically a widget has a title field you can set manually or on the plugin itself. I wish to add something like a meta field value per post to each widget tit... | You can use the <code> widget_display_callback </code> (fired, predictably, just prior to displaying a widget :) ). <code> add_filter('widget_display_callback','wptuts54095_widget_custom_title',10,3); function wptuts54095_widget_custom_title($instance, $widget, $args){ if ( is_single() ){ //On a single post. $title = g... | Is there any way to dynamically alter widget titles? | wordpress |
I'm trying to set the post thumbnail (featured image) with javascript from an existing image in the media gallery. I would consider a php-based option too I suppose (one that would require clicking update before the images show up). Some Background I'm building a site for a music venue with a custom "event" post-type. ... | You need to do an ajax call with action: 'set-post-thumbnail' Check in admin-ajax.php (line 1477 in 3.3.2) for the expected values and nonce, but in general you need to send post_id, attachment_id and nonce. The nonce should come from: wp_create_nonce( "set_post_thumbnail-$post_id" ); The admin does something like: <co... | Set Featured Image programmatically (in admin) with JavaScript? | wordpress |
This article states: If you aren't already using a PHP opcode cache and WordPress caching plugin, nginx will do squat for your WordPress-based website's performance. Could someone elaborate on what the author means. I'm currently running a vanilla install of wordpress on my Apache2 webserver. I'm considering migrating ... | "squat" is synonymous with "nothing" in this case. So, I'd say: Before you consider using nginx, be aware that PHP APC or a similar opcode cache with a WordPress caching plugin is going to offer significant performance improvements over just switching from Apache to nginx. If you aren't already using a PHP opcode cache... | Does running Wordpress on Nginx do "squat" for its performance? | wordpress |
I want to use attachment IDs for shortcodes, but if the image is published with a permalink, it's harder to find the ID. I've found some functions online that can turn the attachment url into its ID, but that's ridiculous if I have to use a function every time I want to use the shortcode in my posts. Trying to do: <cod... | You could hook into <code> 'attachment_fields_to_edit' </code> and just add a row: <code> <?php # -*- coding: utf-8 -*- /** * Plugin Name: T5 Show Attachment ID * Version: 2012.06.04 * Author: Thomas Scholz <info@toscho.de> * Author URI: http://toscho.de * License: MIT * License URI: http://www.opensource.org/... | Is there a way to show attachment IDs on the attachment info screen? | wordpress |
As far I know, the widgets in the dashboard can be removed, but I want to ask if its possible to remove the access to dashboard completely and allow access to only post-new.php page? Thanks. | Removing the dashboard: <code> /* Remove the "Dashboard" from the admin menu for non-admin users */ function wpse54085_remove_dashboard () { global $current_user, $menu, $submenu; get_currentuserinfo(); if( ! in_array( 'administrator', $current_user->roles ) ) { reset( $menu ); $page = key( $menu ); while( ( __( 'Da... | Remove users access to dashboard | wordpress |
On my local machine, I have multiple wordpress versions installed so I can test the themes and plugins I develop. I was wondering if I could somehow create a central wp-content folder and database, which are linked to each version of wordpress, so I don't have to continually copy my projects between the them? Thank you... | For <code> wp-content </code> folder you need to add WP_CONTENT_DIR with path to this folder to each <code> wp-config.php </code> file of each your sites. All of these WP_CONTENT_DIR constants should have the same path to one folder. Read more about it here: http://codex.wordpress.org/Editing_wp-config.php#Moving_wp-co... | Have multiple local wordpress installs share a wp-content folder and database | wordpress |
Is there some way to get the $handle for each script that has been enqueued? Is there some array that holds all the handles so that I can loop through it and do something using each $handle? | the <code> $wp_scripts </code> global holds all the script data: <code> function wpa54064_inspect_scripts() { global $wp_scripts; foreach( $wp_scripts->queue as $handle ) : echo $handle; endforeach; } add_action( 'wp_print_scripts', 'wpa54064_inspect_scripts' ); </code> | How do I get the $handle for all enqueued scripts? | wordpress |
Couple of days I am trying to integrate THAT page in wordpress. I converted it to wordpress theme but can't make the images to loads. All I see is the loading circle. I changed the path in javascript that call the ajax file: <code> $.get('http://localhost/wordpress/wp-content/themes/two/ajax/thumbs.php?album='+album,fu... | ok, i found the answer: In thumbs.php change <code> ../images </code> and <code> ../thumbs </code> to <code> ../wp-content/themes/YOURTHEMENAME/images </code> , <code> ../wp-content/themes/YOURTHEMENAME/thumbs </code> . Same in js. | How to convert that page to a wordpress template? | wordpress |
I have various different extra profile fields which I have set in functions.php however with the upload one if a user uploads an image and saves the form the image is set, however if they go back and edit another field it sets the image field to null. Here is the code I have in my functions.php file. Any help would be ... | The last parameter of <code> update_user_meta() </code> , the previous value, is an optional parameter. If it's set it checks whether the value in the database is indeed the one you fed <code> update_user_meta() </code> . If you set that paramteter by grabbing the value from the database, it is completely redundant. So... | Wordpress User Profile Upload - If page is saved file reset | wordpress |
I was trying this code to get current user info, but showing nothing. My WordPress version is 3.3.1 <code> <?php wp_get_current_user(); /** * @example Safe usage: $current_user = wp_get_current_user(); * if ( !($current_user instanceof WP_User) ) * return; */ echo 'Username: ' . $current_user->user_login . '<b... | Have you tried to go with the "Safe usage" alternative given in the commented section? I honestly don't have any experience with <code> wp_get_current_user() </code> , since I never use it, but anyhow, this ought to work: <code> global $current_user; get_currentuserinfo(); echo 'Username: ' . $current_user->user_log... | get current user not working | wordpress |
I am working on a Wordpress site that has a custom front-end form for submitting posts. I need to add a field in the form to allow users upload a single PDF file along with the post. How can I achieve this? | I have done a simple function for that, but i allow all types of media. So this could be a start: <code> function insert_attachment( $file_handler, $post_id, $settpdf='false' ) { // check to make sure its a successful upload if ( $_FILES[$file_handler]['error'] !== UPLOAD_ERR_OK ) __return_false(); require_once( ABSPAT... | Uploading PDF files from the front-end | wordpress |
How is it possible to upgrade a post to make it sticky directly from code, not by admin area? Is it possible through a code like: <code> update_post_meta($post_id, $meta_key, $meta_value, $prev_value); </code> In this case, the $post_id is known, but the $meta_key? Thank you in advance for your answers | The sticky posts are saved as an array of post IDs in the wp_options table. Hence, <code> $stickies = get_option( 'sticky_posts' ); $stickies[] = $post_id; update_option( 'sticky_posts', $stickies ); </code> will make the post in question sticky. EDIT: Even better, the core provides functions to stick and unstick posts... | Code to make a post sticky | wordpress |
I know that Wordpress is stateless and doesn't use any global session variables, but when a user logs in via Wordpress, it must somehow keep track of who is logged in, right? Does Wordpress keep track of that in cookies? I'm working on a plugin that must keep track of something similar. I can easily store some data in ... | Yes, WordPress uses cookie to keep track of who is logged in in cookies. But you don't have to rely on it. If you want to check if user is logged in, you can just use is_user_logged_in function and you can identify a user by his/her ID which you can get by calling get_current_user_id function. | How does Wordpress handle sessions? | wordpress |
I know how to add a Walker to a custom menu created by the theme (menu named <code> primary </code> in this example), but how can I target a menu thats created in a widget with the default wordpress custom menu widget? <code> if ( has_nav_menu( 'primary' ) ) { $args = array( 'menu' => 'main-menu', 'menu_id' => 'm... | If you look at implementation of <code> WP_Nav_Menu_Widget </code> class you will see the following code: <code> function widget($args, $instance) { // Get menu $nav_menu = ! empty( $instance['nav_menu'] ) ? wp_get_nav_menu_object( $instance['nav_menu'] ) : false; if ( !$nav_menu ) return; $instance['title'] = apply_fi... | Add a custom walkter to a menu created in a widget | wordpress |
HARD NOTE: This question is solely about performance, and NOT search engine optimization. So, please make sure your answers are as such. W.r.t permalinks, "year" is the most obvious numeric of choice, and nothing can be more specific to a post than a post ID (also a numeric). Otto has for so long been suggesting the us... | Answer: as of 3.3 and beyond, a "problem" structure now only adds one single optimized query. I wrote a post about that, in fact. Bottom line: it's no longer an issue. You're welcome. ;) | Post ID At The End Of Permalink URL Effects Performance (Positively)? | wordpress |
I'm setting up my wordpress website on my server now and have the rotating images on the home page and it's beautiful, but now I want to have a conditional tag telling wordpress if it's not the home page use the featured images per each page. This is the code I've placed onto my home page to display my plugin rotating ... | There are multiple issues that I think you want to adjust: You open an extra PHP tag before the second <code> if </code> statement. That shouldn't be there. Make sure that <code> is_home() </code> is what you want. If you have a static front page (set in Settings > Reading), then you actually want <code> is_front_page(... | Using a conditional tag for the home page banner | wordpress |
Every time I call WP_Query() in the function below, Wordpress leaks 8 megs of memory. And since I call this function a lot, things get hairy pretty quickly... :( I've tried unsetting the resulting $queryObject as well as periodically calling wp_cache_flush(), but neither seems to have any effect. Any thoughts? <code> f... | Excellent responses on WP Hackers: http://lists.automattic.com/pipermail/wp-hackers/2012-June/043213.html What you're doing with that query, is loading EVERY matching post into memory, including the full post contents. As you can imagine, this is probably quite a lot of items. You can pass 'fields' => 'ids' into WP_Que... | WP_Query leaking absurd amounts of memory | wordpress |
i have a page who display the latest posts of an author. But when the author has no post i get a display message Warning: rsort() expects parameter 1 to be array, null given in ... Here the script <code> function wpmu_latest_post_auther($authorId,$how_many = 10, $how_many_words = 50, $more_text = "[...]", $remove_html ... | Try wrapping the <code> rsort </code> bit in an if statement like this: <code> if (!empty($post_dates)) { rsort($post_dates); } else { echo 'optional error message here'; } </code> This will check to see if the variable is empty first, and only run <code> rsort() </code> if it is not empty. This check works most of the... | Warning when author has no post | wordpress |
I have 2 custom taxonomies, each with a number of terms: <code> tax1 term1_1 term1_2 tax2 term2_1 term2_2 term2_3 </code> I am trying to have each taxonomy usea different template file for each its single-term archive pages. I.E. <code> term1_1 and term1_2 </code> use one template, while <code> term2_1 - 3 </code> use ... | I would intercept the template loader at <code> template_redirect </code> : <code> function wpse53892_taxonomy_template_redirect() { // code goes here } add_action( 'template_redirect', 'wpse53892_taxonomy_template_redirect' ); </code> Then, you would check to see if the query is a custom taxonomy: <code> if ( is_tax()... | Using a different template per Custom Taxonomies for single term archive pages | wordpress |
I would like to copy all the posts, users, and pages from my main site into a sub site. I've tried exporting and importing, but the main site has thousands of entries and hundreds of users, and the import seems to fail at around 250 posts without an error. Any ideas for the migration would be greatly appreciated. | I was able to use the standard WordPress import and export by raising the maximum memory limit in <code> wp-config.php </code> : <code> define( 'WP_MAX_MEMORY_LIMIT', '1024M' ); </code> | WordPress Network (MU): Copy Main Site to Sub-Site | wordpress |
I have free demo use of my application for 10 days then use automatically disable. Not delete. After he pay us for using that application for 1 year we can extend that time duration. If there is no any plugin, any snippet suggestion ? | The Membership plugin does that pretty much out of the box, if i recall correctly. Not sure if only on the paid version, though. | WordPress plugin for Limited days user | wordpress |
So i know how to combine post types into 1 loop and out put the loop. Below is what i have: <code> <?php $args = array( 'post_type' => array('post','movie','actor'), 'posts_per_page' => '20', ); query_posts( $args ); while ( have_posts() ) : the_post(); the_title(); endwhile; ?> </code> This works as expect... | Could you do something like this? <code> <?php $args = array( 'post_type' => array('post','movie','actor'), 'posts_per_page' => '20', ); query_posts( $args ); while ( have_posts() ) : the_post(); global $post; if (($post_type == 'movie') && (get_post_meta($post->ID, 'meta_key', true) == 'your-value'... | Multiple post type queries (with specific arguments for each) | wordpress |
If I want to save settings for my plugin then it is pretty easy and straight forward. Now I would like to save to the database a bit more. A file name, and 3 other values that only apply to that file. And there are many files with those values. Is it possible to save kind of subarrays using built in database methods? H... | I rarely disagree with otherwise knowledgeable users, but in this case I can't help it. In my opinion calling the usage of non-core database tables bad practice per se is just simply wrong. The choice of whether to go with core tables or add your own depends on several factors. A query's execution time depends on the s... | Is it bad practice to create own table for a plugin? | wordpress |
I'm trying to delete all child posts when the parent is deleted. The parent post deletes just fine, but the child posts are not properly deleting. Here's the code I have in place now: <code> $args = array( 'post_parent' => $parentid, 'post_type' => 'custom-type' ); $posts = get_posts( $args ); if ($posts) { // De... | Try it like this: <code> $args = array( 'post_parent' => $parentid, 'post_type' => 'custom-type' ); $posts = get_posts( $args ); if (is_array($posts) && count($posts) > 0) { // Delete all the Children of the Parent Page foreach($posts as $post){ wp_delete_post($post->ID, true); } } // Delete the Par... | Delete Child Posts | wordpress |
Do you recall when the TimThumb exploit occurred? Which versions of WordPress bundled with this exploit? I need to inform a client that they should be upgrading to at least the version of WP when this exploit was patched. Yes, I'm aware of the separate issue where TimThumb is also used in plugins -- that's a separate i... | TimThumb has never been bundled with WordPress, it is/was entirely a third-party theme/plugin issue. | Which Versions of WordPress Ship with the Patched TimThumb? | wordpress |
I have used this code in header.php <code> ### get the author info global $current_user; get_currentuserinfo(); $authorid = $current_user->ID; ### get the last post id using author id $info=mysql_query("SELECT * FROM wp_posts WHERE post_author = $authorid ORDER BY post_date DESC LIMIT 1"); $array_content = mysql_fet... | You call your header.php file by calling <code> get_header() </code> function in single.php file. It means that your <code> $postid_profile </code> variable exists only in scope of <code> get_header() </code> function. To make it visible in global scope you need to make your variable global. So your code should be modi... | post id not displaying | wordpress |
As an example, let's say I set my "About Us" page (slug: about-us) as my home page static page. Upon doing this, when someone requests mysite.com/about-us, WordPress does a nice redirect to the home page so that I don't end up with duplicate content of having two pages pointing to the same content. I'm trying to find w... | First off, the behavior you describe is not a redirect but a URL rewrite . That being said, there's a WordPress option called <code> page_on_front </code> that is set to the page ID of the static page to be used as a front page. This option's value is only relevant if the option <code> show_on_front </code> is set to <... | Where to find the code that redirects requests on the static page URL to the home page | wordpress |
I'm using the Menubar plugin to place a menu at the top of my website. However, I need to find a way to check if the menu contains items or not. My menu is called 'menubar'. Currently, I'm loading the menu like so: <code> do_action('wp_menubar', "menubar"); </code> It loads fine, but I need to check if there are items ... | Try this: <code> $meniu = count(wp_nav_menu( array('menu' => 'menubar' ))); if($meniu > 0 ){ //here goes your stuff if we have items in menu } </code> | How to check if the Menubar contains no items? | wordpress |
I have a script that needs to know if the site is using a static home page. In other words, at "Settings > Reading > Front Page Displays > a Static Page _ _" Is there a a get_option() or method call that can be used to determine this? | <code> get_option( 'page_on_front' ); </code> If this value is not <code> 0 </code> , there is a static page. Additional note from Johannes Pille: <code> get_option( 'show_on_front' ); </code> … returns <code> post </code> or <code> page </code> . But be aware of stackexchange-url ("custom post types as front page"). A... | How to determine (via php) if site is using a static home page? | wordpress |
i wanted to change the slug of a custom post type so i renamed single-myslug.php to single-mynewslug.php changed <code> $the_query = new WP_Query(array('post_type'=>'myslug','posts_per_page'=>8)); </code> to <code> $the_query = new WP_Query(array('post_type'=>'mynewslug','posts_per_page'=>8)); </code> and c... | I don't know what you used to change the slug in the <code> wp-admin </code> , a plugin perhaps? But I'm not sure if your method will update existing database posts. And if it does the way it did is probably where something went wrong. What exactly did you use to update your slug in the <code> wp-admin </code> ? | changed custom post type now $image_attributes[0]; broken | wordpress |
Why, when I want to use <code> add_filter( 'author_link', 'foo', 10, 3 ); function foo ( $link, $author_id, $author_nicename ) {} </code> I have to use 3 required parametres? Why cant I do this: <code> add_filter( 'author_link', 'foo' ); function foo ( $author_id ) {} </code> If you can, please give me some literature ... | You don't have to specify number of arguments, in which case it will default to one. Essentially this argument gives you control on how many arguments hook will pass to function, which matters in few too many situations to come up with generic explanation. In a nutshell if hook can pass N arguments, your options are: p... | why do I have to use required parametres? | wordpress |
Currently all the below bit of code is doing is showing 3 random posts from the same category that the current page resides in. So if the current page falls in the artists category, for example, show 3 random posts from the artists category down the side of the page. The problem I have is that the current post keeps ap... | First, do not use <code> query_posts() </code> for secondary loops . The <code> query_posts() </code> function is intended only to modify the primary loop query. Use <code> WP_Query() </code> or <code> get_posts() </code> for secondary loop queries. Also, <code> showposts </code> is deprecated . Use <code> posts_per_pa... | Exclude current post ID from loop in sidepbar.php | wordpress |
So I'm working with ThemeTrust's "reveal" theme, and there is an ajaxed in chunk-of-content that I'm really trying to change (grab custom meta fields (images) + insert into a slideshow). As far as I can tell the following piece of code grabs the content from the normal tinymce box and drops it in the <code> #projectHol... | The function that returns the contents of that ajax request will not be in admin-ajax.php. That is the core WordPress file that handles ajax requests, but it is not used for specifying the data returned by ajax functions in themes / plugins. In the theme (somewhere), will be a line that looks like this: <code> add_acti... | making sense of admin-ajax | wordpress |
How can I display a post with a certain category in the page template instead of default category template. For an example, I want to show all posts under category "Scott" with the page template ("page.php"). | I'm pretty sure you could also do what you want by filtering <code> template_include </code> . This is super-untested, but maybe this can get you headed in the right direction: <code> function wpse53871( $template ) { global $post; // check if is a Post and in the 'scott' category if( is_single( $post->ID ) &&am... | Change Page Template Based on Category | wordpress |
I'm making a custom RSS feed where I want the full article to display. The problem is that when I use the_content() to output the article, it will only show the excerpt if there is a 'more' tag in that article. How do I force the_content() to output the full article, or is there another function that will achieve this? | Setting the $more variable to 0 seem to solve the problem for me. I put the following at the top of my function which output the RSS feed: <code> function outputRSS(){ global $more; $more = 0; //Output my RSS below... } </code> | Force the_content() to show full post in RSS feed | wordpress |
I want to upload images in my custom plugin options page. <code> <form action="?page=slideshow_options" method="post"> <input type="file" name="async-upload" id="async-upload"> <input type="submit" name="html-upload" id="html-upload" class="button" value="Upload"> </form> </code> If I try to che... | Wow... this one is not a simple one... it's not a matter of calling the magic function <code> uploadimages() </code> ... I wish it would :) I've learned from a tutorial I cannot seem to find (but this one seems fair) and from analyzing other plugins. The following is just a general orientation, sorry for not making a d... | Upload file inside plugins options page | wordpress |
I have critical problem! My Wordpress Blog has the permalink structure <code> /%category%/%postname%/ </code> . The problem is that very often the permalinks break so I get a lot of 404-Errors. I can fix it refreshing the links by saving the permalinks options again in the admin panel. This seems to be a knows problem.... | I hopefully figured it out. I think the problem were the server configurations. There was an option meaning that the <code> .htaccess </code> file is managed by the server. I set this option to <code> self managed </code> . The last two days it worked fine and without broken links. I hope this will remain in future... ... | Permalinks break every day | wordpress |
Would it be possible to host wp-content on another domain, so that all the uploads and images would go and load from there? If so, how would I go about configuring wordpress to do this, preferably without using a third-party plugin? | In WordPress Dashboard > Settings > Media and fill the field "Full URL path to files" with your other domain . See the screenshot below: EDIT: I thought it would be obvious, but it isn't. Here's what you exactly need to do: You should map your domain to point to: public_html directory, IF it's also your WordPress insta... | Host wp-content on other domain, much like a CDN | wordpress |
I'm going to write a function to return the next/prev post in a specific category. can anyone tell me what the differences would be in using <code> $wpdb </code> as opposed to <code> WP_Query() </code> ; eg <code> new WP_Query(args) </code> ? what determines which of these should be used? cheers, Gregory | The <code> wpdb </code> class is the interface with the database. <code> WP_Query </code> uses <code> wpdb </code> to query the database. You should use <code> WP_Query </code> when dealing with the native WordPress tables, to integrate your code properly with the WordPress environment. Use <code> wpdb </code> directly... | how does $wpdb differ to WP_Query? | wordpress |
Hi I have a page that always gets messed up when opening in Visual mode, can I force this particular page to always open in HTML mode for all users in the dashboard? | Try this Force html edit plug-in . | Force page to open in html mode | wordpress |
Let's say I'm doing a search on my site, and get 50 posts as a result. The pagination is set to 10 posts per page, so I have 5 pages of results. When I'm on the first page of results, if I inspect the global var <code> $posts </code> , it gives me data for the 10 posts of the current results page only. How can I access... | The whole loop mechanism is based around having a filtered $posts array. So looking in The Loop documentation on multiple loops it gives a PHP explanation for the standard loop code you use: <code> <?php if (have_posts()) : ?> <?php while (have_posts()) : the_post(); ?> <!-- do stuff ... --> <?php ... | How can I get all posts data from within a paginated search result? | wordpress |
When solving this issue ( stackexchange-url ("Change admin language based on user (in single-site)") ), I did a function so that the plugin would auto-hide from all users except one (me:). The flaw is that it only auto-hides when active . At first, it was a mu-plugin, but I had to enable/disable it manually. It really ... | Apparently, there's no way to remove one plugin from the Must-Use list... But then, found a filter that does even better: <code> show_advanced_plugins </code> will completely hide the sight of the Must-Use plugins. After all, if you're trying to hide something of this nature, then hide it all... It's inside the class <... | How to use a Must-Use plugin to hide a regular one and to hide itself? | wordpress |
The below code is taken from sidebar.php where it outputs random posts from multiple categories and excludes the current post from showing up. This works great but how do I alter this loop to exclude all posts from the current pages category? So for example if a post is currently on display and its category is artists,... | This one is even more simple. Refer to the <code> WP_Query() </code> category parameters . I think you will want to use <code> 'category__not_in' </code> . <code> foreach ( $random_posts_cat_array as $random_post_cat ) { if ( $post_cat_slug == $random_post_cat ) { // No posts from this category! $random_posts_query_arg... | Alter secondary loop to exclude posts from current page category | wordpress |
Is it possible to manage content on multisite installations centrally? If I have a network of 20 sites, is it possible to change the content on one site and have it update across the network, or will I have to make the change on each site one at a time? More specific case, If I have a Terms and Conditions page that mus... | I've successfully used the ThreeWP Broadcast plugin to do this on a WPMU installation. The basic concept is that you have one 'broadcasting' site from which you can broadcast content to other sites. The content can be posts, pages, custom post types, custom taxonomies, post meta or attachments. If content is updated on... | Basic Multisite Question - Managing Content Centrally | wordpress |
I have the following directory structure: Root Install: /Users/philipdowner/Sites/montanaliving Within the root installation I have the following plugin structure: /wp-content/plugins/manifest-rets/ Then, within the plugin folder I have 2 php files manifest-rets.php phrets.php In the main plugin file, I have the follow... | I'm not sure why this isn't working for you. I usually set the plugin path constant using dirname( FILE ) You could try: <code> define('MR_PLUGIN_PATH', dirname(__FILE__)); //echo MR_PLUGIN_PATH; include_once(MR_PLUGIN_PATH.'/phprets.php'); </code> Also: Are you sure phprets.php exists. You say you have phrets.php (mis... | Using plugin_dir_path() with WordPress on MAMP | wordpress |
The following is supposed to display 10 posts. Sometimes it displays 11, sometimes 12, and sometimes the desired 10 posts. It behaves the same if I swap <code> posts_per_page </code> for <code> showposts </code> or <code> numberposts </code> . Where do I need to search for the problem? <code> <ul> <? wp_reset_... | The expected behavior of <code> posts_per_page </code> is to NOT count sticky posts. This can be resolved with <code> 'ignore_sticky_posts' => 1 </code> , but then the posts don't stick to the top of the menu. (In the trac ticket for sticky posts this issue is discussed.) There are some workarounds like this one , b... | Limiting the number of posts in WP_Query leads to unexpected result | wordpress |
Basically I've setup a custom post type and taxonomy for a set type of posts and I'm creating a child theme from twentyeleven. When I use the default WP Posts and then I tag them and categorize them, get_the_category_list and get_the_tag_list do their work and display below the post. Now I would like to do the same wit... | You can use the generic <code> get_the_term_list() </code> for all taxonomies. | get_the_category_list or get_the_tag_list for custom post types and taxonomies? | wordpress |
On searching for a solution, I found the following codes to add col on media page: <code> add_filter ( "manage_upload_columns", 'upload_columns' ); add_action ( "manage_media_custom_column", 'media_custom_columns' , 0, 2 ); </code> The result is close to what I want, but I need to implement it on thickbox gallery tab--... | While researching I found what stackexchange-url ("may be a duplicate"), but I'm really not sure, as this one deals with sending the value somewhere else... There, I learned that there's a plugin for what I was already coding ( Multiple Galleries ) and it injects the <code> include </code> attribute when inserting the ... | How to Add a Custom Colum on Thickbox Media Gallery Tab? | wordpress |
when show/edit an image/file, on the right side of the image/file, there are some text info-- File name, File Type, Upload date, Demention... How to modify those text? | Add this to functions.php file. <code> function image_attachment_field($form_fields, $post) { if( substr($post->post_mime_type, 0, 5) == 'image' ){ $user = new WP_User( $post->post_author ); $form_fields["author"]["input"] = "html"; $form_fields["author"]["html"] = '<p><strong>Author:</strong> '... | How to modify the attachment info text on gallery tab or media page? | wordpress |
I have an existing WordPress search function, what I'd like to be able to do is extend the search to the tags from my custom taxonomy...how do I do that? <code> <form method="get" id="searchform" action="<?php echo home_url(); ?>"> <input type="text" value="Product Search..." name="s" id="s" /> <in... | One plugin that I've used successfully is Relevanssi: http://wordpress.org/extend/plugins/relevanssi/ Also, you could try to make your custom taxonomy into a search filter, like it's described in this post: http://wordpress.org/support/topic/search-form-with-custom-taxonomy-dropdown . I've used this on my projects and ... | Custom Taxonomy Tag Search | wordpress |
I've installed Wordpress on subdomain.domain.com. I've enabled the Wordpress Network on this installation, choosing a subdomain install. I've created a wildcard subdomain in cpanel, which is *.subdomain(.domain.com), which points to /public_html/subdomain I've created a site: site.subdomain.domain.com, but I cannot vis... | It turns out the ‘wildcard’ DNS entry was not in the zonefile for *.subdomain. Tech Support fixed this for me, and it is up and running, except for the fact that the new website is still not listed under the Sites dropdown menu. | Creating a subdomain network in a subdomain | wordpress |
This may be really obvious, but I can't find other documentation or questions about it. Scenario I have a directory of Businesses (custom post types). Each Business has a "Type" (custom taxonomy). The Business Types are hierarchical, such as Eat > Restaurant > African, Play > Parks, Services > Medical > Dental, etc. Ot... | Use the deepest term only. If you want to rearrange the term relations later you don’t have to go through all posts to fix the post-term relations. Plus, you are more flexible when you want to separate the posts with child terms from post associated with the current term only. | Is there any difference between post in child term and child & parent terms? | wordpress |
I've been writing up some code which enables two post types to share a custom taxonomy. From the admin side, it works fantastically - but for some reason, when I look at the taxonomy archive itself on the site, /country/{country} , despite the fact that there are two posts (one from each type) in the taxonomy, it comes... | As the page is returning with "no posts found", it's possible that whatever template page is generating term archives isn't including your custom post types in its query. If you take a look at the template that should be easy to see. | Sharing a custom taxonomy - No posts? | wordpress |
I wonder if it's possible to add a filter to all images inside <code> the_content() </code> to create the following image pattern for all images … <code> <img class="digest" src="smallest-file.jpg" data-fullsrc="largest-file.jpg" alt="something"/> </code> So I'd like to add a <code> class="digest" </code> to the ... | You will need to take a look at the <code> image_send_to_editor </code> filter. This will not update existing records but it if you get it working it will apply to each newly inserted image. very basic filter: <code> function give_linked_images_class($html, $id, $caption, $title, $align, $url, $size, $alt = '' ){ $html... | add data-attribute to all images inside the_content() | wordpress |
I have WordPress installed in a subfolder called <code> news </code> , but links to comments, posts, categories, etc all link to <code> domain.com/?p=99 </code> instead of <code> domain.com/news/?p=99 </code> . The only link that points to the correct folder is the <code> edit post </code> link. I have set my WP folder... | Usually this is because the "Site URL" field in Settings > General is wrong. It probably says "domain.com" where it should say "domain.com/news". | the_permalink() not working | wordpress |
I am working with a woocommerce install, and we have a product that has 2016 variations (between selections for each of 4 variables - size, color, type, and extra). The problem is that woocommerce out of the box breaks when more than a couple hundred variations are added to the product page. (the admin page will not lo... | OK, I think I have found an answer to my own question. It appears that the broken admin pages with too many items were a result of my hosting provider (Dreamhost) having "extra web security" checked in the setup of the site. This apparently stops Wordpress from updating when the query is too large. Disabling this "feat... | Too many variations in WooCommerce | wordpress |
As the title of this answer say, I want to define a default caption to all uploaded images in my WordPress... Is there a way to do something like this? | There's really no documentation for it yet, but you'll probably be able to do it hooking to the <code> attachment_fields_to_save </code> filter and inserting the default caption there. From the Codex : attachment_fields_to_save applied to fields associated with an attachment prior to saving them in the database. Called... | Is there a way to define a default caption to all uploaded images | wordpress |
I have some shortcodes on pages e.g. [fb_like] [twg_gpo_button] [ratings]. If I visit page they expand correctly but on search engine results page, they do not expand on some pages. I have installed W3 Total Cache plugin. Is this due to it? What should I do to prevent this in future? I want to remove such pages from se... | The easiest way to see if W3 Total Cache is the cause would be to disable the plugin and see if that fixes the issue. But what you're seeing is an unfiltered post. Usually, the content of the post is passed through <code> the_content </code> filter, and those shortcodes are replaced. Something in your search results is... | Unexpanded shortcodes in search engine results | wordpress |
I wonder if there any way to disable/remove the Upload/Insert button on the text editor that created on the custom field? I already has a field that handling the file upload, so I just want the text editor to handle text with basic formatting and lists features. Thanks | You simply set the parameter to false when you create the editor, which you do with a call to the_editor as follows: <code> <?php the_editor($customcontent, $id = 'CustomContent', $prev_id = 'title', $media_buttons = false, $tab_index = 2); ?> </code> The first parameter is the content that should be used to fill... | Disable media upload in rich text editor | wordpress |
i haven't got any experience in wordpress so please sorry me if answers seems too trivial. one upon a time i had a blog. then the hosting service expired and i get a backup in a hurry way: the bad way. i copied all the root directory i dumped the mysql database now i've just paid for reactivate the host and i want to r... | If you are not moving to a different domain name, the file path shouldn't really matter. Try these first: Made a copy of your original backup bd Open the new copy and search/replace example.com/ to example.com/blog/ This should get you going no matter what server setup you have. If it doesn't , and you already have a f... | restore a db after bad backup | wordpress |
By default, it looks like all hyperlinks are stripped out of excerpts. Perhaps this is to prevent link power from diluting. Is there a way to allow hyperlinks to display in excerpt content? | WordPress uses the filter <code> wp_trim_excerpt </code> to strip the tags. You can remove the filter and create your own which will allow the links: <code> <?php function new_wp_trim_excerpt($text) { $raw_excerpt = $text; if ( '' == $text ) { $text = get_the_content(''); $text = strip_shortcodes( $text ); $text = a... | can hyperlinks be displayed in excerpts? | wordpress |
I would like to limit characters in BuddyPress posts to certain limit . Ex: Set it to the limit of 150 ... just like twitter's 140. Googled about it and found nothing. Does any one have Idea on this? Thanks | Simple solution is to add a maxlength attribute to the textarea field. For example <code> <textarea maxlength="140"> </textarea> </code> | Ability to set character limit in BuddyPress? | wordpress |
I'm building a custom jQuery form and I need to specify the siteurl in the url that loads /wp-admin/admin-ajax.php. I place this code in the template that has the form: <code> <script type="text/javascript"> jQuery('#newFeedbackForm').submit(ajaxSubmit); function ajaxSubmit(){ var newFeedbackForm = jQuery(this).s... | If your JavaScript is running in the admin, you don't need to set an explicit path to admin-ajax.php. It's always available as a JS variable called "ajaxurl". You can see an example of this in the Codex , under the heading "AJAX on the Administration Side" Ajaxurl is, unfortunately, not available on the frontend by def... | Specify ABSPATH in jQuery url | wordpress |
I'm building site (dummy site is up at www.teamcoding.ca/corporate) and would like to include in the upper-right hand part of the screen, "Switch to Lifestyle Site" with a link to a different site. My impression is that to do this I need to edit one of my .php files. I tried to edit page.php, full-width-page.php (the t... | You should provide your code when asking this type of question. Here is an example of a header.php file. Look at the code and see how it's done: <code> <!DOCTYPE html> <html <?php language_attributes(); ?>> <head> <meta charset="<?php bloginfo( 'charset' ); ?>" /> <title> <?... | Editing a PHP file to include a small text piece on every page | wordpress |
For example, I'm using wp_list_pages to display the navigation, the child pages (and their children) appearing on hover as is typical. However, I want one of these parents to not display the children. Essentially I want something like exclude_children_of to work in the wp_list_pages arguments; is there a way of doing t... | try -: if your page ID = 999 <code> <?php $child_ids = $wpdb->get_col("SELECT ID FROM $wpdb->posts WHERE $wpdb->posts.post_parent = 999 AND $wpdb->posts.post_type = 'page' AND $wpdb->posts.post_status = 'publish' ORDER BY $wpdb->posts.ID ASC"); $exclude = implode($child_ids,', '); wp_list_pages('ex... | Can you exclude child pages of a specific parent within a navigation? | wordpress |
No idea how to title this so feel free to edit. I set out to create a "hotness" for my posts and to do this I used the <code> $ratings_score </code> which is stored as post_meta as a number +/- and the days ago of the post which I trimmed down to just the days. I divided the ratings_score by the days to get a number wh... | Here are two simple ways to do this: One is to use the <code> the_content </code> -filter to update the post "hotness", or you can schedule an event that will run daily and update the "hotness" once a day. First approach: <code> the_content </code> -filter Turn you code in to a "callable" function: <code> function upda... | Use a function to update post meta based on other post meta | wordpress |
I am working on a small course engine that has a Course custom post type and a list of users. Users should apply for courses. I was thinking about the Posts 2 Posts plugin to create the relationship, but is there any straight forward way to assign many users to a single post type (course) and see only things for that s... | On a total fluke, I saw this stackexchange-url ("WPSE answer") just after reading your question. It's a plugin called "User Specific Content" that seems to do exactly what you want. "Role Scoper" is a good plugin, but it's probably overkill for what you need. Best yet, the "User Specific Content" plugin was the result ... | Assign post type to many users | wordpress |
This snippet for example will email on EVERY post: <code> function email_friends( $post_ID ) { $friends = 'bob@example.org, susie@example.org'; wp_mail( $friends, "sally's blog updated", 'I just put something on my blog: http://blog.example.com' ); return $post_ID; } add_action('publish_post', 'email_friends'); </code>... | Use <code> has_category() </code> to check if a post belongs to a certain category. <code> function email_friends( $post_ID ) { if ( has_category( 'uncategorized', $post_ID ) { $friends = 'bob@example.org, susie@example.org'; wp_mail( $friends, "sally's blog updated", 'I just put something on my blog: ' . get_permalink... | do add_action on condition | wordpress |
I would like to remove the email field in the comment form. It works for <code> url </code> but not for <code> email </code> : the email field is still there. Do you know why? <code> <?php function url_filtered($fields) { if(isset($fields['url'])) { unset($fields['url']); } if(isset($fields['email'])){ unset($fields... | This works fine for me: <code> <?php add_filter('comment_form_default_fields', 'wpse53687_filter_fields'); /** * Unsets the email field from the comment form. */ function wpse53687_filter_fields($fields) { if(isset($fields['email'])) unset($fields['email']); return $fields; } </code> One reason that it could be fail... | Remove field in the form : only works for "url", not for "email"? | wordpress |
So my script is simple right now just to test out the $entry field id's. <code> add_action("gform_after_submission_3", "set_post_content", 10, 2); function set_post_content($entry, $form){ $subject = $entry["28"] . 'Applied as: ' . $entry["2"]; mail( $emailremoved, $subject, $message); } </code> Right now entry 28 is a... | To debug you should print what's in $entry. <code> echo '<pre>' . print_r($entry,true) . '</pre>'; die();//You may need to kill the script to view.. </code> Or email to yourself in your current mail function. <code> $message = '<pre>' . print_r($entry,true) . '</pre>'; </code> | Gravity Forms field ID $entry not working | wordpress |
I'm trying to find out the PHP code that will get the current URL and add a hash ID onto the end of it so a link can be generated and linked to. The end goal is to create a link that returns: http://mydomain.com/news#postID-123 . This should a) take users to the news page and b) jump to the part of the news page where ... | Your answer should return: `` so from there you just do this: <code> $final_url = $URI.'#'.get_the_ID(); </code> Which should echo <code> http://mydomain.com/current/page#372 </code> which is kinda good for linking. But if your looking for a "bookmarks" link it would be best practice to do this (inside the loop): <code... | Get current Wordpress page then add #post ID to the end | wordpress |
I just tried to add a simple help tab, from within a class (example to test below). I wanted to use a helper/callback fn to prepare the content for different help tabs. According to core, the function takes some args: WP 3.3 /wp-admin/includes/screen.php LINE 722 <code> // If it exists, fire tab callback. if ( ! empty(... | Ok. The answer is NOT simple, but after some try and error, reading core, etc. I found out what the problem is: The callback (which should be used instead of the <code> content </code> ) accepts two arguments: <code> $current_screen </code> and <code> $tab </code> . Here's what <code> $tab </code> looks like, when dump... | Help Tabs with: add_help_tab() callback - How does the argument work? | wordpress |
A friend of mine pointed me towards using child elements to style my index page so that I could have one loop and several different visual styles (a featured post, a smaller sub-featured post, and several smaller thumbnails). This is very helpful in that I can add posts and the existing posts will just flow through thi... | Your theme's <code> body_class </code> can be used to target specific pages: <code> body.home /* front and subsequent pages */ body.paged /* any page *except* front page */ </code> | Styling Previous/Next Pages differently from Index | wordpress |
Even if I've been coding (mainly Java and Python) for some years, I'm totally new with web apps and PHP. So please forgive me if this is a novice question. I had a WordPress blog with a friend who was managing all the WordPress hosting. Now my friend has decided to go away and he sent me the blog backup: All the WordPr... | phpMyAdmin is software typically installed by your host and available via your hosting control panel, it is not part of WordPress. A search on web for <code> [your host] phpMyAdmin </code> will probably tell you what you need to do. | Where is phpMyAdmin inside WordPress? | wordpress |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.