question stringlengths 0 34.8k | answer stringlengths 0 28.3k | title stringlengths 7 150 | forum_tag stringclasses 12
values |
|---|---|---|---|
Can someone review my code , I need to know better solutions or any bug. Okey ! , I made a PHP file to get search results by parameters and search by title , content and tag PHP's head look like: <code> include('../../../../wp-config.php'); header('Content-type:text/html;charset=utf-8'); $keyword = $_GET['k']; </code> ... | Search in WordPress is complicated matter because: WP doesn't do it very well out of the box People tend to have varied expectations of how precisely search should work Even light (from human perspective) requirements for search tend to translate in complicated and involved code Building search from scratch is involved... | Custom search page and search by title, content and tag | wordpress |
Is it possible to hide content in Post Preview (that is not hidden when the post is published)? I have customised <code> single.php </code> quite extensively and there are a few elements that I do not want my authors to load up every time they preview their post. | There is the handy <code> is_preview </code> function. So somewhere in your <code> single.php </code> . <code> <?php if (!is_preview()) { // Show stuff that doesn't belong on a preview. } </code> | Hide content from Post Preview | wordpress |
Hi I have this code in my functions.php and its working well when the editor is viewing the Media library: http://example.com/wp-admin/upload.php <code> add_action('pre_get_posts','users_own_attachments'); function users_own_attachments( $wp_query_obj ) { global $current_user, $pagenow; if( !is_a( $current_user, 'WP_Us... | If I correctly understand your question, you may try this <code> function wpse78084_show_media_by_current_author_only($query) { global $pagenow, $user_ID; if( 'upload.php' == $pagenow && !current_user_can('manage_options') ) $query->set('author', $user_ID); return $query; } if ( is_admin() ) add_filter('pre_... | Prevent other editors from viewing images of other editors in Add Media Popup | wordpress |
I am using the Sideshow theme which I received as part of a bundle hence I don't receive any support from Themezilla themselves. I am trying to insert a <code> "Read more" </code> link when I insert a <code> "More" </code> tag. I have tried following instructions from Wordpress Codex using the_content and the_excerpt b... | I found the answer, I searched for <code> <?php the_content(''); ?> </code> and changed it to <code> <?php the_content('Read More'); ?> </code> These were found in each post types php file. eg includes/video.php. | "Read More" link not displaying | wordpress |
Now that WordPress 3.5 is supposed to work with core files in subdirectory, I decided to move my local development setup (subdirectory multisite) to that configuration. Fast forward and what I have is following: <code> wordpress </code> (3.5 core) <code> wp-content </code> (content dir, configured via <code> WP_CONTENT... | Your <code> .htaccess </code> lines need to look like this: <code> RewriteEngine On RewriteBase / RewriteRule ^index\.php$ - [L] # uploaded files RewriteRule ^([_0-9a-zA-Z-]+/)?files/(.+) /wordpress/wp-includes/ms-files.php?file=$2 [L] # add a trailing slash to /wp-admin RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-ad... | Changing subdir multisite install to subdir core directory structure | wordpress |
If I embed a YouTube video into a post, how do I put a play button over the featured image so that the video can be played without having to open the whole post? I.e Flipboard the iOS app has a function which allows you to watch videos from the featured image stage. | It happens that I answered a stackexchange-url ("similar Question"). And adapting it a little bit, some serious magic can happen ;) Notes : the CSS is being printed inline. It should go with the theme's <code> style.css </code> and be adapted accordingly. each Featured Image is encapsulated in a <code> div </code> with... | Video playing from featured image? | wordpress |
So i'm fairly certain this probably has something to do with the fact that I'm using a custom role I've set up in my functions.php file with almost 0 permissions. However, I'm still able to access the dashboard, just I get sent to profile.php on login instead of dashboard. I want my user_role to get sent to the dashboa... | Filter <code> 'login_redirect' </code> . Sample code, not tested: <code> add_filter( 'wp_login', 'wpse_78150_login_redirect' ); function wpse_78150_login_redirect( $url ) { # uncomment the next line for debugging # var_dump( wp_get_current_user() ); exit; if ( ! current_user_can( 'custom_role' ) ) return $url; return a... | How to set where user is redirected to after logging in at wp-login? | wordpress |
I'm looking at the wordpress list of actions and trying to find an action that is called when a post is restored from the trash but cannot find one. Does anyone know if it exists? | There are multiple actions. Listed in order of appearance with their parameters: <code> untrash_post </code> - <code> (int) $post_id </code> // before restoring <code> transition_post_status </code> - <code> (string) $new_status, 'trash', (object) $post </code> <code> trash_to_{$new_status} </code> - <code> (object) $p... | Is there an action that is called when a post is restored from the trash? | wordpress |
Is there a WordPress conditional tag for checking if the user is viewing the add media popup after clicking the Add media button? If none, is there an alternative function that can be used? Thanks for any tips and advice. | There are multiple actions available. Demo: <code> add_action( 'upload_ui_over_quota', 'wpse_78085_callback' ); add_action( 'pre-upload-ui', 'wpse_78085_callback' ); add_action( 'pre-plupload-upload-ui', 'wpse_78085_callback' ); add_action( 'post-plupload-upload-ui', 'wpse_78085_callback' ); add_action( 'post-upload-ui... | Conditional tag to determine if the user is viewing the Add Media (after clicking Add media button) | wordpress |
Is there a way I can wrap a div around wp_nav_menu's ul.sub-menu So for example the markup would go from <code> <ul class="menu"> <li><a href="/">Item 1</a></li> <li> <a href="/">Item 2</a> <ul class="sub-menu"> <li><a href="/">Item 1</a></li>... | stackexchange-url ("Use a custom walker"), extend the methods <code> start_lvl() </code> and <code> end_lvl </code> . Sample code, not tested: <code> class WPSE_78121_Sublevel_Walker extends Walker_Nav_Menu { function start_lvl( &$output, $depth = 0, $args = array() ) { $indent = str_repeat("\t", $depth); $output .... | Add container to nav_menu sub menu | wordpress |
I use gravity forms and wp-favorites plugin (helps users select their favorite posts). I am trying to auto-populate gravity form with the following snippet. It works pretty well but it shows only the first item in the list. How can I get all items in the array? <code> add_filter("gform_field_value_circle", "populate_sq... | If it is a dropdown and you want to populate it with options may be use this filter <code> add_filter("gform_predefined_choices", "add_predefined_choice"); function add_predefined_choice($choices){ $choices["My New Choice"] = array("Choice 1", "Choice 2", "Choice 3"); return $choices; } </code> http://www.gravityhelp.c... | need correction with a snippet in functions.php | wordpress |
I have a script that enables a logged in user (role Author) to delete their own posts using <code> get_delete_post_link() </code> . However, I also want to be able to restrict the author's access to the dashboard. Any attempt to do so using a plugin (Theme my Login, for example) or a simple script like those linked bel... | This is how I ended up solving this issue. Originally I used this code for the link to delete an individual post: <code> <?php if( !(get_post_status() == 'trash') ) : ?> <a class="delete-post" onclick="return confirm('Are you sure you wish to delete post: <?php echo get_the_title() ?>?')"href="<?php e... | Restrict dashboard access for specific user roles to specific actions | wordpress |
I have just installed a fresh version of the latest wordpress locally but the backend admin area looks like this http://grab.by/iGik Not sure what is causing this, I have tried redownloading and reinstalling witha new database but still doesnt work. uggh! DEBUG INFO I get the following error when I go to the updates pa... | Try clearing your browsers cache and reloading the page. That'll fix it. There is an explaination here (see problem number 2) | wordpress admin is broken | wordpress |
I want to display all posts from specific categories on a single page. Therefore I edited the page.php file in my theme folder. I added an 'if-clause' to check which page currently being displayed and load all posts from the following categories. <code> <?php get_header(); ?> <div id="primary"> <div id="... | I'd Advise adding the arg of the category in an array. And don't use <code> query_posts </code> . Also <code> showposts </code> is deprecated use <code> posts_per_page </code> instead. <code> $args = array ( 'cat' => array(2,6,9,13), 'posts_per_page' => -1, //showposts is deprecated 'orderby' => 'date', ); $ca... | Display all posts from specific categories on a page | wordpress |
As the recent changes in WordPress 3.5 removed the "full URL path to files" option from media library I am wondering how to set this option to a custom path now? I need to set my "full URL path to files" for my media files to a custom subdomain. Can you guys help me out with finding a solution for this problem? Regards... | The option name is <code> upload_url_path </code> , and you can still filter it: <code> add_filter( 'pre_option_upload_url_path', 'wpse_77960_upload_url' ); function wpse_77960_upload_url() { return 'http://subdomain.example.com/files'; } </code> | WordPress 3.5: Setting custom "full URL path to files" in the Media Library? | wordpress |
I currently have configured Wordpress so that a post can be copied to other sites within a Wordpress network. However, a post may be broadcast more than once, and I want to check if the image is already published into that site's <code> wp_posts </code> table. As an example, let's say an image has the image path: <code... | Yes, a database query is possible with WordPress: <code> function is_image_in_network( $image_name ) { global $wpdb; $image = "uploads/2012/01/{$image_name}"; $value = '%'.like_escape( $image ).'%'; $blog_id = get_current_blog_id(); $wpdb->set_blog_id( $blog_id ); $image = $wpdb->get_var( $wpdb->prepare( "SELE... | How to check if image is already stored in a site's post database? (network) | wordpress |
I'm relatively new to WordPress theme development, and I had to create a theme with options available. I did a Google search to see what are the possibilities, and I read articles about such, and read about frameworks, and I came across Option Tree, which was recommended as a framework to develop with. What my question... | disadvantage using option tree: Your theme depend on other work as a core You need to always keep an eye for the plugin update ( which is really not good if you're going to use it in premium theme ) If you're going to integrate it in your theme, then when there is update from the plugin you will need to do lot of thing... | What are the advantages and disadvantages of Option Tree over the Customization API? | wordpress |
<code> public function database_name_check($input){ //debug add_settings_error('notice', 'lol', 'lol'); if($this->wpdb->get_var($this->wpdb->prepare('SHOW DATABASES LIKE %s', $input)) == $input) return $input; else{ add_settings_error('notice', 'lol', 'lol'); return FALSE; } } </code> I can not understand w... | Take a look at the <code> add_settings_error </code> prototype. <code> add_settings_error( $setting, $code, $message, $type ); </code> The first argument is your settings name/key -- or if your setting is on another page (eg <code> general </code> ) it should be the page key. The second is whatever you'd like to add to... | How to use add_settings_error in register_setting callback | wordpress |
I would like to write this piece of code in an extendible way. <code> $my_item = array( 'post_title' => $item->get_title(), 'post_content' => '', 'post_status' => 'publish', 'post_excerpt' => $item->get_description(), 'post_type' => 'post' ); </code> If I use this in a plugin I would like to be abl... | Provide a filter: <code> $my_item = apply_filters( 'plugin_name_item_args', array( 'post_title' => $item->get_title(), 'post_content' => '', 'post_status' => 'publish', 'post_excerpt' => $item->get_description(), 'post_type' => 'post' ), $item # pass the $item object to the filter ); </code> A plug... | Extensible code | wordpress |
When you visit <code> wp-admin/nav-menus.php </code> and there is no menu you get a set of metaboxes you cannot use. The only thing they do is drawing attention away from the Create Menu dialog. I want to hide those boxes until there is a menu. How can I do that? | There are two important global variables in <code> wp-admin/nav-menus.php </code> : <code> $nav_menus </code> is an array of all available menus, filled with <code> wp_get_nav_menus() </code> . <code> $wp_meta_boxes['nav-menus'] </code> is an array of all available metaboxes for this screen. We can hook into <code> adm... | Remove unusable metaboxes in nav menu management screen | wordpress |
How can i retrieve a picture, let say ( No picture ) when i don't add a picture in my custom field I use this code to retrive the field... <code> <img class="film" src="/scripts/timthumb.php?src=<?php the_field('img_actor'); ?>&h=251&w=175&zc=1" alt="<?php the_title(); ?>" title="<?php the... | Test the value before you use it: <code> <?php if ( ! $img = get_field('img_actor', get_the_ID() ) ) $img = 'http://www.example.com/wp-content/uploads/default.jpg'; ?> <img class="film" src="/scripts/timthumb.php?src=<?php echo urlencode($img); ?>&h=251&w=175&zc=1" alt="<?php the_title_att... | Function to retrieve a picture if there is no picture is attached | wordpress |
I have a couple functions that are creating an admin table to display on my custom dashboard page. I'm having a little trouble with the function that determines what pages to display because I'm not sure how to restrict my query to not count items that had a post status of 'auto-draft' or 'trash'. Anyone know how to do... | <code> WHERE post_status NOT IN ('auto-draft','trash') </code> Looks like you can add that to your base query. <code> /* -- Preparing your query -- */ $query = "SELECT * FROM $wpdb->posts WHERE post_status NOT IN ('auto-draft','trash') "; </code> This is only barely a WordPress question. Why are you not using core f... | How to limit post query to only return a total count of items with certain post statuses? | wordpress |
When trying to update one Network/MU install, I got the following error. Warning! Problem updating https://subdomain-A.example.com . Your server may not be able to connect to sites running on it. Error message: SSL: certificate subject name 'example.com' does not match target host name 'subdomain-A.example.com' As I kn... | I had to write a little plugin to bypass the check - free to download and use. <code> <?php /** * Plugin Name: Upgrade SSL Bypass * Description: The DB-Upgrade process for networks does not work if there's an error with your SSL certificate. This plugin bypasses the check by disabling the verification in case of an ... | "Upgrade Network" error: stuck with SSL certificate verification | wordpress |
I'm fairly new to WordPress. I'm creating a page with a form. It works, but being so new, I'm wondering if I'm doing it in the best way. I'll use Twenty Twelve as an example theme. copy 'page.php' from Twenty Twelve (we'll use 'xxx.php' as the new template page name); working in xxx.php from here forward, add '// Templ... | As has been mentioned, your way works, but there are some ways you can decouple the form from the template, allowing more flexibility. The Shortcode API allows you to create a shortcode for your form, so you can simply enter something like <code> [my_form] </code> in the page's content, then within the function that ha... | Proper way to create custom static page | wordpress |
For some reason my TinyMCE buttons are completely misaligned and have the wrong <code> background-position </code> (See image below): I have attempted to download a fresh install of Wordpress 3.5 and replaced my files with the following from it: <code> /wp-includes/css/editor.min.css /wp-includes/images/wpicons.png </c... | Solved: It appears chrome had a corrupt cache as I attempted to visit the backend on Firefox and noticed that the issue wasn't there. I had to delete all Chrome browsing data (cache alone wouldn't do it). | TinyMCE buttons broken | wordpress |
I am having issues getting the below code to work. I created an Advanced Custom Field (top_articles) with a checkbox containing three options: top_articles_left, top_middle, top_articles_right. I would it is so that when you are within a post you can check off that you want that post featured and it then shows up in th... | You'll have to look in the database to see how ACF stores the checkbox values. As far as I know, they're not saved as flat meta values under a single key, which makes it not possible to efficiently query on that data. The queries you have now aren't going to work, you're just loading a single post in each of them and c... | Advanced Custom Fields Plugin: how to use a checkbox to allow a post to show up in desired "zone"? | wordpress |
I was having an issue the other day and successfully got a very good answer which helped me alot achive what I wanted. this is the post which I created and have all the correspondence: stackexchange-url ("wordpress.stackexchange.com/questions/63060/display-all-authors-and-their-only-one-latest-post") The answer was kin... | What you need here is to shuffle all the array elements & then display them. But since php's <code> shuffle() </code> function doesn't preserve array key associations, here's a version that does. <code> function shuffle_assoc(&$array) { $keys = array_keys($array); shuffle($keys); foreach($keys as $key) { $new[(... | Display all authors in a theme template | wordpress |
I'm having trouble wrapping my head around the best way to achieve this. I'm trying to load two photos at a time into a which serves as a slideshow wrapper. Currently i'm repeating a lot of code and just manually setting an offset each time. My current code works, but it's just very clunky. Here's what it looks like: <... | Yep - it is pretty inefficient. Here is a rewrite: <code> <div id="engagement"> <?php $images = new WP_Query( array( 'post_parent' => get_the_ID(), 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => 'ASC', 'orderby' => 'menu_order ID', 'offset' =&... | Calling two images at a time? A better way? | wordpress |
I am trying to block the visualization of a custom post, of type 'product', if it is assigned to certain values of the taxonomy 'product_cat'. Strictly speaking, I would like to block the visualization of a product if it falls under certain categories. I can not make this work, even by hardcoding a forbidden name for a... | You are not going to be able to prevent anyone from ever loading that page. Even if there is no link to it, you probably have a sitemap generated that creates links to all items. So wanting to block it is the right thing to do but changing the query to try and do it is not. Probably the best and easiest approach is to ... | Do not show a custom post if it belongs to a certain custom taxonomy | wordpress |
I need the Wordpress menu to include the 'current-menu-ancestor' class to reflect that site is currently in the recipe section. Supposing I have a recipe custom post type. I have the following code in my functions.php but it's not working: <code> function add_active_item_classes($classes = array(), $menu_item = false){... | This is the final working code: <code> <?php function additional_active_item_classes($classes = array(), $menu_item = false){ global $wp_query; if(in_array('current-menu-item', $menu_item->classes)){ $classes[] = 'current-menu-item'; } if ( $menu_item->post_name == 'product' && is_post_type_archive('pr... | How to include the 'current-menu-ancestor' class on a custom post type menu in Wordpress? | wordpress |
My theme shows full posts on the main page and I want it to show only the summary, I tried searching for the_content tag in my theme's index.php file but it is not even there! I don't have a home.php or category.php. I tried searching my whole wordpress installation for the_content and the only places i could find it i... | Decide about <code> the_excerpt() </code> or <code> the_content() </code> with a conditional: <code> is_singular() </code> . You can use a plugin and filter <code> the_content </code> depending on the current page’s type: archive or singular. But you can use it in your theme too. <code> add_filter( 'the_content', 't5_r... | Replace full content with an excerpt | wordpress |
My WP theme got these notice on description menu function my code : http://www49.zippyshare.com/v/89513423/file.html <code> /* Discription Navigation Menu, Credit to Christian Kriesi */ class description_walker extends Walker_Nav_Menu { function start_el(&$output, $item, $depth, $args) { global $wp_query; $indent =... | It looks like the <code> $args </code> passed to the function is not an object for some reason. I can't see the origin of this problem but for a quick solution, you can add <code> $args = (object) $args; </code> before the first time you use <code> $args </code> , here on line 44 Also, as commented by toscho, <code> dr... | Trying to get property of non-object “ wordpress ” | wordpress |
One Wordpress function I happen to use frequently is <code> get_template_directory_uri() </code> . While I tried to minimize or avoid its use where I can, I still happen to have more than one call to this function in certain pages across my theme. Most of the time in a series of href or inside other functions (for whic... | I would stay stick to the function. PHP caches functions for speed and efficiency. In some situations, using a function is faster then using a variable. There are other benefits too - imagine if you changed the name of your variable - you would have to go and update every piece of code where it's used. | Retrieve the template directory URI via global or get_template_directory_uri() every time? | wordpress |
I've just put the site up a couple weeks ago and adding some more things to it for my friend however there's got to be an easier way to lay content out over wordpress. I've having a hard time with it even and I'm codding half of it (or at least adding styles, looking at the CSS, ect) I'm specifically looking at the ser... | I think your question is a perfect example for the stackexchange-url ("XY Problem"). In WordPress you do not create such a menu in a post editor. You use a menu. Once you start thinking about your problem from this point, everything is easy. :) First register a custom navigation menu for this list in your theme’s <code... | Create a formatted table-like menu | wordpress |
I have a form that contains a dropdown menu. This form is on a page <code> form.php </code> and is not part of my theme. It exists outside of my site. This dropdown menu contains my list of values for a custom taxonomy called Formats . My Formats are as follows: <code> Entry Form Facebook - Entry Form - Page Twitter </... | You can use the standard WordPress function, get the dropdown already formatted and solve both problems at once. Like so: <code> define( 'WP_USE_THEMES', false ); require( './wp-load.php' ); wp_dropdown_categories( array( 'child_of' => 0, 'class' => 'postform', 'depth' => 0, 'echo' => 1, 'exclude' => '',... | Recreating the hierarchy of taxonomies for a dropdown form menu? | wordpress |
I was creating a site for testing and i selected an option when setting up wp that essentially disallows my site from being indexed/crawled. I would now like it to be crawled like normal, but i cant find the option within wordpress. I am running wp 3.5WP Thanks in advanced. | To allow crawling of your WP site you need to go to "admin panel > > Settings > > Reading" right before the "Save Changes" button is a checkbox with the label Search Engine Visibility make sure this is unchecked. | Allow spiders to crawl my site (selectable option in wp) | wordpress |
I'm customizing a WooCommerce theme and am going to be moving the title. There is an action in <code> content-single-product.php </code> called <code> do_action( 'woocommerce_single_product_summary' ); </code> in the <code> woocommerce_hooks.php </code> file the title action is <code> add_action( 'woocommerce_single_pr... | That would be: <code> remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_title', 5 ); </code> You can read about it here: http://codex.wordpress.org/Function_Reference/remove_action | Disable WooCommerce action | wordpress |
I'm looking for a way to let people connect with facebook when posting comments, and to use their facebook avatars as the avatar for the comments. How can this be done? Do I need to create a seperate user account for those people, or is their a way to simply store an avatar url for each comment that's posted? | Three simple steps to generate a Facebook Avatar: Create an extra field in your comment form for the user's facebook profile (see e.g. WP Engineer for a code example and how to) If the user filled out this field, get the facebook avatar (stackexchange-url ("see this question")) Replace the WP avatar with your facebook ... | Custom avatars in wordpress comments? | wordpress |
I am using the below code for pagination. However, it is not working. It's showing all of the pages numbers nicely, but when I click on a page number the first page is always displayed. <code> global $wp_query; $total_pages = $wp_query->max_num_pages; if ( $total_pages > 1 ) { $current_page = max( 1, get_query_va... | <code> check below code for pagination. global $paged; $temp = $wp_query; $wp_query = null; $wp_query = new WP_Query( array('post_type' => 'post','posts_per_page' => 2, 'paged' => $paged ) ); while (have_posts()) : the_post(); // Your post content. endwhile; echo paginate_links( $args ); global $wp_query; $big... | Custom pagination code is not working | wordpress |
GIT? SVN? WAMP? XAMP? MERCURIAL? BITNAMI? There are so many options that I am getting a bit cunfused. I just want to work without publishing and a need of an internet connection, and when all is ready, just release it | You can use the XAMP server, I am also using the same for the last 5 years. And also you can consider to use Microsoft Web Matrix as the editor because it provides wordpress syntax highlighting, suggestions etc. | how can I create a WP offline environment before releasing the websites? | wordpress |
WP 3.5/TwentyTwelve/Clean install. I try this when login as admin and editor. I try add reply for first post "Hello World": <code> <script>alert('XSS')</script><script><</script> </code> and get popup window . Is it porential security risk or can no care? Thanks for advance.. | The answer is in your question. I try this when login as admin and editor. The roles have the <code> unfiltered_html </code> capability that allows them to put whatever HTML they choose, including <code> <script> </code> tags, where ever they choose. Is is a security risk? Only if you give folks you don't trust a... | Admin can enter JavaScript - potential security risk? | wordpress |
I can't find a more or less clear example on how to create additional fields, so may be someone can help me here? Here is my code: <code> function __construct(){ add_action('admin_init', array($this, 'plugin_admin_init')); } public function create_fields(){ register_setting('dleToWp_options', 'database_name'); register... | There are a lot of things which you have to understand about Settings API . Instead of duplicating information, I would strongly recommend you to read through bunch of articles called The Complete Guide To The WordPress Settings API , especially pay attention to the second part called Sections, Fields, and Settings . D... | How to add options to the plugin page? | wordpress |
How can i display 4 diferent themes for an archive page When i click on the right in corner i want to display another theme, another Css style (my own) Something like this. <code> http://tvpedia.org/lista-seriale/seriale-noi-2012 </code> Thanks | It appears that the site you linked to is just using a url parameter to specify which view to serve. A simply way to accomplish this is to create four different loop templates, each employing a different layout. Using the example site, you would need the following: <code> loop-complex.php, loop-simple.php, loop-poster.... | How can i display a 4 diferent themplate for the archive page | wordpress |
I would like to let the user login either using username or email. The only way to find the email is by detecting <code> @ symbol </code> using <code> strpos </code> . However WordPress allow <code> @ symbol </code> in username too . Can someone help me to invalidate username if it contains @ symbol in it.. | In a multi-site installation it is <code> 'wpmu_validate_user_signup' </code> : <code> add_filter( 'wpmu_validate_user_signup', 'wpse_77904_mu_no_at_in_username' ); function wpse_77904_mu_no_at_in_username( $user ) { if ( FALSE !== strpos( $user['user_name'], '@' ) ) $user['errors']->add('user_name', __( 'That usern... | Invalidate username if it contains @ symbol | wordpress |
Hello and happy new year Suppose one has a large theme composed of several post types, page templates and a bunch of custom loops and template parts which is best keeping in separate php files. What's the best practice to organise these files? For example, suppose I have 10 page templates. How about putting them in a f... | Page templates are special case and since WP 3.4 can be put in subfolder natively. Other than that WP mostly expects flat file structure for templates. While template hierarchy is easily adjusted (see dynamic filter in <code> get_query_template() </code> , pretty much only thing needed)... From personal experience - ov... | Organize template parts and page templates in folders in regards of template hierarchy | wordpress |
I am trying to display the following posts in descending order beginning with the first created and ending on the last page with the most recently created post. Any help is appreciated. Here is my code: <code> <?php $numofmebers = '-1'; if ( empty($_GET['page_id_all']) ) $_GET['page_id_all'] = 1; $count_post = 0; qu... | Keep in mind that query_posts is best avoided as it has negative effects on the main loop. A better approach would be a new instance of WP_Query or changing the query arguments for the main loop. To get the order you want, try adding the following to your args: <code> array( 'posts_per_page' => '-1', 'post_type' =&g... | How can I display these posts in ascending order? | wordpress |
How guys , i my archive themplate i have 3 tipe of themes: -poster -complex -simple How can i display a certain number of post for arhive themes: Ex: for my poster i want to display 24 posts(only the poster and title), for complex i want to display 12 posts(full with excerpt..), for simple i eant to display 30 ( only t... | Ok. You are toggling your display according to a <code> $_GET </code> parameter that you have added to the URL-- this switch in your <code> archive.php </code> <code> $view = 'poster'; $mode = stripslashes( $_GET["afisare"] ); $modes = array('complex', 'simple', 'poster'); if(in_array($mode, $modes)) $view = $mode; get... | How can i display in themplate file only a few post | wordpress |
I am building a plugin that allows users to PPK encrypt their users' IP/email data. Thus, IP/email data is set to dummy values in the comments table and encrypted values are stored in corresponding meta fields. I'm successfully using the <code> comment_email </code> hook to lookup email addresses in the admin comments ... | You have to filter <code> 'get_comment' </code> . The filter is part of the function with the same name. It is called in <code> wp-admin/comment.php?action=editcomment </code> and the comment is passed to the edit form where you see the email. The parameter is a <code> comment </code> object, you can change the email v... | comment_email hook doesn't seem to work for comment editor field | wordpress |
I am trying to get the categories associated with a post in it's meta section by using the following code: <code> <div>FILED AS: <span class="gf-post-meta-result"><?php the_category(' &bull; ') ?></span></div> </code> WordPress is generating the markup as: <code> <div>FILED AS: &... | Filter <code> the_category </code> , and remove those attributes: <code> add_filter( 'the_category', 't5_remove_cat_rel' ); function t5_remove_cat_rel( $list ) { return str_replace( array ( 'rel="category tag"', 'rel="category"' ), '', $list ); } </code> | Remove 'rel' attributes from the_category() output | wordpress |
I'm wondering if there is any way to change the actual link itself for wp_link_pages. So right now, I have a simple code to display the pagination for a post, it looks like this: <code> <?php wp_link_pages( array( 'before' => '<div class="link-pages">' . __('Pages:', 'muimedia'), 'after' => '</div>... | There is no filter for the URLs, and no filter for the complete output of <code> wp_link_pages() </code> . But you can get the output as string if you pass <code> 'echo' => FALSE </code> as argument. There are four options: Write a modified copy of the function with the URLs you need. You will miss all further impro... | Changing Link Attributes for Wp_Link_Pages | wordpress |
Happy new year everyone. I've been struggling with this one for a while. I need to get the latest comment from a custom post type, but ignore any child comments i.e. only look at comments with a depth of 1. I can get the latest comment from a custom post type using: <code> $args = array( 'post_type' => 'custom-post-... | use the "parent" parameter as 0. <code> $args = array( 'parent'=>0 'post_type' => 'custom-post-type', 'number' => '1', 'orderby' => 'date', 'order' => 'DESC' ); $comments = get_comments($args); foreach($comments as $comment) : echo($comment->comment_author . '<br />' . $comment->comment_conte... | Get the latest comment from a custom post type where depth = 1? | wordpress |
Can anybody fix this incorrect related posts codes snippet? <code> function related_posts() { if (is_single()) { global $post; $current_post = $post->ID; $categories = get_the_category(); foreach ($categories as $category) : ?> <div class="my-related-posts"><h4>Related Posts</h4><ul> <?... | Your first problem: Try to write down what you want to do: You do not want to print posts that are already printed. So you have to remember what posts are already printed. In PHP normally an array is a good solution to remember things that are already done. Let's add an array: <code> $printed_posts = array( $current_po... | Fix incorrect related posts code snippet | wordpress |
In a Multisite, I'm applying the filter <code> get_blogs_of_user </code> to sort the "My Sites" admin bar menu, where the sites are listed by <code> blogname </code> : What happens is that I'd like another order elsewhere, where the sites are listed by <code> domain </code> . For example, the sites that appear in the U... | Much probably, using <code> debug_backtrace </code> in this fashion is wild hackerism... Based on @toscho's tip, the following achieves the same results: <code> add_filter( 'get_blogs_of_user', 'reorder_users_sites' ); function reorder_users_sites( $blogs ) { if( !did_action( 'wp_before_admin_bar_render' ) ) uasort( $b... | Conditional hook based on the core function that is calling it | wordpress |
I have a shortcode called update which is used as follows <code> [update title='' date=''] this is some update, etc. etc. 2 paragraphs or more [/update] </code> This outputs some html that wrap the title, date and content in some html. Along wit this, I would like spit out a single line at the top of the content that o... | A cleaner way than my first suggestion would be this: Run the shortcode handler two times: 1. before the content is parsed, 2. during the regular content parsing. Store the data you want to prepend in a variable. It is important to use <code> 'the_post' </code> as first entry. Otherwise you can get strange side effect ... | How can I return shortcode output to the top of the content? | wordpress |
I am using WooCommerce on one of the site. I need to add one more field at the time of checkout to ask buyer wheteher to issue Invoice on his name or the name of his business? Any advise how to do that? Or something like this is already there in Woo Commerce? Or what could be the simplest way to do that? | As it happens, I just blogged about this yesterday, for how to add a subscribe to mailing list checkbox . The key points are: look at the WooCommerce tutorial woocommerce_checkout_fields is a filter hook that allows you to add or modify what fields appear on the checkout form woocommerce_checkout_update_order_meta is a... | Check out Attribute on WooCommerce | wordpress |
I'm using WooCommerce, and using a BACS Payment method which is actually Bank Trasnfer. The fields account details are fine, but for Indian context.. i need to change following two fields labels to something else. For example: Change IBAN label to MICR Code, and BIC to IFSC. And also need to disable Sort Code. However,... | It gets its label using a localisation call, <code> __('IBAN', 'woocommerce') </code> , so you could always just intercept that and change the text: <code> /** * filter translations, to replace some WooCommerce text with our own * @param string $translation the translated text * @param string $text the text before tran... | Change Label for field used in Woo Commerce | wordpress |
I'm needing a little help getting this figured out. I have a query that's not quite working right now, but I need it to create a custom feed that includes category information and then includes the featured image from the first post in that category. Anyone have thoughts on how to get that running? <code> /** * Custom ... | First define a function to return the first post of a category by a given category ID ex: <code> function get_category_post($cat_id){ $post_args = array( 'numberposts' => 1, 'category' => $cat_id, 'fields' => 'ids' ); $posts = get_posts($post_args); return $posts[0]; } </code> Then, once you have that function... | Creating a custom feed for categories that includes the first post's featured image | wordpress |
I have a WPMU install with a couple of sites on it. I'd like to add some subdirectories that are not wordpress blog pages but do contain working PHP code. They do not use any of wordpress's libraries and are not plugins. The catch is that I'd like these subdirectories to only show up on a particular site. For instance,... | I added the following section to the top of my web.config rewrite rules section: <code> <rule name="Movies Redirect" stopProcessing="false"> <match url="\/?movies\.*" /> <conditions> <add input="{HTTP_HOST}" pattern="^.*dawson\.osmblags\.com.*$" negate="true" /> </conditions> <action ty... | Custom PHP-coding in MU installs | wordpress |
I have been using a lot of Custom Fields to use Wordpress like a CMS, beyond simple posts and post meta. The admin area for adding new posts has little "widgetized" movable areas like the "categories", "publish," and "tags" boxes for instance. With Custom Fields, all are grouped under one "widget" with the same name. I... | You can create and position your own meta boxes via <code> add_meta_box </code> . You can store the data as meta data behind the scenes but it will allow you to customize the UI in the admin screens. | Can you ungroup Custom Fields? | wordpress |
I would like to display the first four images from posts across a WordPress network. In Otto's image gallery tutorial he recommended using the following to get images from recent posts. Query parameters: <code> $images = new WP_Query( array( 'post_parent' => get_the_ID(), 'post_status' => 'inherit', 'post_type' =... | I had nothing to do this lunch, so I put together a little function for this. The main thing is to get all the sites within the network and their id. For that I'm using a simple SQL-Query via the class wpdb : <code> $site_ids = $wpdb->get_results( "SELECT blog_id from $wpdb->blogs" ); </code> It will return a lis... | On Multisite: Loop to Show First Four Images of Recent Posts Across Network | wordpress |
I've created a dashboard widget in my functions.php file. I want to have it be able to update some stuff in the database upon form submittal. According to the codex documentation, I should be handling my post submissions with the 4th argument of wp_add_dashboard_widget(), $control_callback. So I've created my handler f... | Actually the from fields only should be in the <code> control_callback </code> function , both form and handling so try this: <code> <?php /* Plugin Name: custom dashboard widget Plugin URI: http://en.bainternet.info Description: custom dashboard widget with control form Version: 0.1 Author: bainternet Author URI: h... | How to use control_callback when creating a widget via functions.php or plugin? | wordpress |
I have a page template where I first am getting the contents of the page, as input in the admin tool, then a loop of posts of a custom post type. I need to split this loop up into the 2 newest posts ("featured") and then a second loop of all the remaining posts. I am trying to use code from the WP Codex, from this page... | Your second loop is fine because it works - although it is probably more efficient to do it this way: <code> $args = array( 'post_type' => 'onourradar', 'posts_per_page' => -1, 'orderby' => 'menu_order', 'order' => 'ASC', 'offset' => '2'); $my_query = new WP_Query($args); while ($my_query->have_posts(... | Multiple loop for "featured" items returns wrong posts | wordpress |
I'm using Photospace as a gallery slider within my hatch pro wp theme ( you can check here ). The default transition effect between slides is a crossover effect ( like this example ), but the effect in my slider seems to be image fade to white, then white fades to image. Not sure why this is happening. Here is the code... | If the theme was coded using Theme Development Standards , then you can use the function <code> wp_deregister_script </code> to remove conflicting scripts from the page where the slider is being used. [update] The original solution (at the bottom) worked in a specific plugin situation (with WP Touch). I think this is t... | How to solve a conflict between a plugin and a theme? | wordpress |
I am trying to write a guide for using wordperss and can't quiet figure how explain the usage of post formats. I read all the documentation available on the web and then played with twentytwelve and woothemes's skeptical theme (on wordpress.com) and I was far from being impressed with the results. My main misunderstand... | This is stackexchange-url ("almost") not constructive . :) On the other other hand, I understand the problem: The use case is not very clear. The original ticket doesn’t say much about the reasons besides see Tumblr . The main problem is the hybrid nature of post formats: They are meta data. Data handling belongs to co... | Is there a real life use case for post formats except for microbloging? | wordpress |
So is it possible to do something like this with <code> add_action </code> ? <code> class class{} $my_class = new class; add_action('init', 'my_class'); </code> | You can do this: <code> class testclass() { function test() { echo 'howdy'; } } add_action('wp_head',array('testclass','test')); </code> Or this: <code> $t = new testclass(); add_action('wp_head',array($t,'test')); </code> It doesn't work like... <code> $t = new testclass(); add_action('wp_head','t'); // or this either... | Is it possible to use object in add_action? | wordpress |
I've setup my first blog with WordPress and I love the framework. I've created sites from scratch on a LAMP stack so I've even been able to tweak my theme and write a plugin or two. So, here's my question: I installed WordPress with Softaculous because it was easy and it worked the first time. Now, I've been upgrading ... | I had a similar situation with my WordPress install and Softaculous, what I found was that the version it was telling me to install (or upgrade to) was actually a minor version BEHIND the version of WP that was considered to be current at the time. In my situation I simply ignored it and had no issues. | Installed WordPress with Softaculous. Should I upgradeManually or with Softaculous? | wordpress |
A corporate website has a few static pages, each with a specific layout, several independent blocks of text (located in different columns or zones of the page) and images. So far I handled this by designing a unique page template for each unique such page. But what if a client wants the ability to content manage these ... | In this situation, I'll typically add meta boxes with new instances of the editor , but it's not for the faint of heart, that is to say, those not well-versed in php and javascript. If you want a simple solution for multiple editors on a page and don't mind relying on a plugin, you can achieve this very easily with Adv... | Content management for static pages | wordpress |
Is it possible to set up new wp_cron jobs dynamically upon a certain action? I have a form submission (I'm using Gravity Forms, so have several functions set up on several of their hooks already) process which creates a post of a specific post type when a user completes and submits the form. What I'd like to do is set ... | A simple and dynamic way to use WordPress cron would be to set up an action hook for your schedule then only add scheduled events as and when you need them. The events would call a generic function and pass in your specific custom post type details through $args - <code> add_action('my_schedule_event', 'generic_functio... | Create wp_cront events dynamically upon user submission | wordpress |
I'm displaying the content from one wordpress blog page on my server onto a different wordpress blog on the same server. Apparently the only way is through RSS feed. The images don't show up. I var_dumped the RSS object and there are no image paths. How do I get the image paths, or the filename of the image? Or how do ... | Images are in the feed, if the feed is a fullfeed, not a excerpt. Check the xml snytax in atom format for <code> <content:encoded> </code> or in RSS2 for <code> <description> </code> . In this tags you can find the images of the content. | Get image paths from RSS feeds | wordpress |
I allow the author user role to add/edit posts (using a custom post type called "User Posts") as well as add/edit their own media from wp-admin. I currently have it set up so that the only menu items they see are the "User Posts" "New User Post" "Media" and "Upload Media", with these URLs: post-new.php?post_type=tsv_us... | Make sure that the second parameter in the "add_action" function matches the name of your restrict access function. It should look something like this: <code> add_action('admin_head','my_restrict_access'); function my_restrict_access(){ /* code as before */ } </code> Glad I could help. :) | Restrict Author role to only 3 wp-admin pages | wordpress |
I have customised the welcome panel on the dashboard for users with information in. I then hid the "Dismiss" button and added CSS to make the welcome panel always visible. Using the 'welcome_panel' hook. This works fine for Admins but the Welcome Panel is not displayed for other users such as editors and authors. Its n... | As you already discovered, the display conditions for that panel are hard-coded into a core file . It isn't meant to be changed, which means you are probably trying to use the panel for something it is not intended for. That isn't criticism. It just makes it hard. I don't see a way to change that except by editing a co... | Show Welcome Panel on Dashboard for every user | wordpress |
Wordpress has tons of mature code for image editing on the admin side, but I would like to provide a form inside of a custom page template for my visitors to drag and drop, crop and save a thumbnail image as part of a new draft post. I can do the page template, form, and draft post part, but am getting pretty frustrate... | The two key things I was missing was the realization that those javascript libs must be literally enqueued on the user-facing page that I intend to use them, and just experience on the mechanics of sending data between javascript and php by means of ajax and json. | How do I use the WP image functions in a page template? | wordpress |
Can anyone give me a function or an idea of the method I would need to use to hide categories from the selection box in wp-admin? I have a custom post type and I would like my authors to be able to choose ONLY between 5 of those categories while they are editing their posts. I would like this to only be the case with t... | Something like this should do it. Replace <code> wpse_77670_getPermittedCategories() </code> with however you select the array of permitted categories, and <code> 'your_custom_category' </code> with whatever your custom taxonomy is for your custom post type. <code> /** * filter terms checklist args to restrict which ca... | Hide/Show only specific categories in wp-admin new-post.php | wordpress |
I am updating my plugin for Wordpress version 3.5 compatibility. These are my important plugin files: Sort_SearchResult_by_Title.php: <code> <?php if(!class_exists('Class_Sortsearchresults')) { require_once('Class_Sortsearchresults.php'); } if(!isset($Class_Sortsearchresults)) { $Class_Sortsearchresults = new Class_... | register_deactivation_hook() is launched when a plugin is deactivated. For plugin uninstall, there is register_uninstall_hook() . Wordpress plugins can also have a file called <code> uninstall.php </code> that is ran whenever the plugin is uninstalled. To prevent the <code> uninstall.php </code> file from being trigger... | Plugin uninstall function is not working | wordpress |
How can i disable/remove the columns for Media Library? I want for author and comments column. Thanks in advance. | The hook for these columns is <code> manage_media_columns </code> . So just filter the columns here: <code> add_filter( 'manage_media_columns', 'wpse_77687_remove_media_columns' ); function wpse_77687_remove_media_columns( $columns ) { unset( $columns['author'] ); unset( $columns['comments'] ); return $columns; } </cod... | Remove the columns in media library | wordpress |
Is there any way to create "more" link for excerpt only for posts in a specific category? For example only posts in "news" category should have a more link. If there's no option for that, maybe posts in specified WP Query? I am using this code for creating "more" link for excerpts but it works for all posts: <code> fun... | Modify the callback and check the post category: <code> function excerpt_read_more_link( $output ) { global $post; if ( in_category( 'news', $post ) ) return $output . '<a href="'. get_permalink( $post->ID ) . '">more</a>'; return $output; } </code> And you should prefix the function name . In its curren... | Wordpress excerpt for specific posts in category | wordpress |
I have created a custom post type along with custom columns. One of my columns displays a date range such as "12/05/2012 - 11:00 am to 12/15/2012 - 1:00 pm". This is a concatenated string using a combination of four fields: <code> startDate </code> , <code> startTime </code> , <code> endDate </code> , <code> endTime </... | Store the date time as a single key in the format <code> yyyy-mm-dd hh:mm:ss </code> . | How do I sort a custom post type admin column using two meta keys? | wordpress |
I have a loop which displays all the posts of the "events" post type on my site. Each of these posts has a custom date field "event_date", which I sort the display of the loop by. I would like to simplify my post management by only display posts which match the current month; that is, as of today (Dec.30) all the Decem... | You can use the <code> meta_query </code> parameter to display all events for the current month like this: <code> $start_date = date( 'ym01' ); $end_date = date( 'ymt' ); $meta_query = array( 'key' => 'event_date', 'value' => array( $start_date, $end_date ), 'compare' => 'BETWEEN', 'type' => 'NUMERIC' ); $a... | Display posts where date field matches current month? | wordpress |
I would like to add a class to a page template's body if the sidebar is not defined. How can I do that? | if you are using an actual page template (as selected in the dropdown panel in the admin area) then using is_page_template('file-name.php') in the body_class function will do it. then, the CSS would be body.class-name #content would apply to only that template area. | How to add a class when there's no sidebar? | wordpress |
I have simple code: <code> add_action('init', 'categoryTransfer'); function categoryTransfer(){ //some code for($i=0; $i < count($categories); $i++) wp_create_category($categories[$i]->name); } </code> But when it executes i get: <code> Fatal error: Call to undefined function wp_create_category() in /Users/noname... | This function is declared in <code> wp-admin/includes/taxonomy.php </code> . This file will be loaded in <code> wp-admin/includes/admin.php </code> . And that now is called in <code> wp-admin/admin.php </code> . So the solution is: Use the hook <code> 'admin_init' </code> or require all necessary files manually. But do... | Problem with wp_create_category | wordpress |
I've got custom template that I want to display paged blog posts. This is the beginning of my file: <code> $wp_query = new WP_Query($args); if($wp_query->have_posts()){ while($wp_query->have_posts()){ $wp_query->the_post(); //something... <?php next_posts_link('Older Entries'); ?> <?php previous_posts... | <code> next_posts_link </code> and <code> previous_posts_link </code> use the global <code> $wp_query </code> . <code> function get_next_posts_link( $label = null, $max_page = 0 ) { global $paged, $wp_query; </code> http://core.trac.wordpress.org/browser/tags/3.5/wp-includes/link-template.php#L1523 That means you need ... | Next_posts_link() works only with original $wp_query | wordpress |
I regularly have guest authors who post one or more articles on a non specific schedule. So I provide them with permanent contributor accounts to avoid the hassle of making them accounts and deleting them every single time. Now this is my problem: Once they submit an article for review and I publish it, they have the o... | Let us solve this by going with your second option. So you want to restrict users from editing published posts, this can be done by adding this to your theme's <code> functions.php </code> file (please read the comments that is added): <code> function restrict_editing_old_posts( $allcaps, $cap, $args ) { // Restrict us... | Reapproval for edits and deletion after post is published | wordpress |
I have the following code to add a new column to my taxonomy edit screen (edit-tags.php?taxonomy=book_place&post_type=books) <code> function add_book_place_columns($columns){ $columns['foo'] = 'Foo'; return $columns; } add_filter('manage_edit-book_place_columns', 'add_book_place_columns'); function add_book_place_c... | The <code> manage_{TAXONOMY}_custom_column </code> filter hook passes 3 arguments: <code> $content </code> <code> $column_name </code> <code> $term_id </code> So try this: <code> function add_book_place_column_content($content,$column_name,$term_id){ $term= get_term($term_id, 'book_place'); switch ($column_name) { case... | Custom columns for taxonomy list table | wordpress |
My site's archive page is echoing wrong Month name. Though the URL is <code> 2012/11/ </code> , it's echoing the month <code> December 2012 </code> . I found nothing wrong with the code: <code> <?php if ( is_day() ) : printf( __( 'Daywise Posts: %s', 'theme-name' ), '<span id="font">' . "<b><i>". g... | Try adding the following above the first if statement to see what actual day is being useddisplayed: <code> echo get_the_date(); </code> It might also help to add the following lines to help debug exactly what the query is doing: <code> global $wp_query; var_dump($wp_query); </code> The code is correct - so it has to b... | Archive page showing wrong month | wordpress |
I am trying to allow users to filter a custom post type list by multiple taxonomies. For Example lets say my custom post type is clothing and it has two custom taxonomies brand and type associated with it. I would like a visitor to first see all clothing posts, then they could click on a brand link that brings them to ... | Alright well this might not be ideal, but it works and was much simpler than I thought! I ended up just adding a $_GET parameter to the 2nd taxonomy terms' linked url, so I could get the 2nd term from the other taxonomy on the next page through $_GET. On the next template I built a new WP_Query that uses the tax_query ... | How to allow visitors to filter posts by multiple taxonomies | wordpress |
I'm trying to create a general search page. I've created a search page template and a new search page, and set the form's action to the URL of this page. When I access the search page directly it fetches the right template, but when I try to send a form to this URL, be it via $_GET or $_POST, I am directed to the defau... | When a search is performed, the default query is no longer a page query, it becomes a search query. Refer to the template hierarchy to see how WP selects the template in this case. Rename the get var to something unique, or filter <code> search_template </code> to override WP's selection. | Wordpress search page doesn't work with either $_GET or $_POST | wordpress |
I have added some text input fields to metabox in my custom post. Now whenever I put some data in those text fields in admin panel and click 'save', all data vanishes. Here is the code: <code> <?php function swpd_render_info_fields() { ?> <label for="swpd_comany_addr">Company Address</label> <input... | You aren't retrieving the saved data and populating the form. <code> function swpd_render_info_fields() { ?> <label for="swpd_comany_addr">Company Address</label> <input type="text" name="swpd_company_addr" id="swpd_company_addr" /> <?php } </code> There is nothing in that function that would in... | update_post_meta() not working in save_post | wordpress |
I can't find a way to add the log in link to the new theme of WordPress, Twenty Twelve. I did find a lot of answers on the older theme, where they suggest to add some code in the <code> functions.php </code> file . However, this do not work for me. Does anyone have a solution for this? You can see my homepage here: htt... | Filter <code> wp_nav_menu_objects </code> and add the link as item, similar to stackexchange-url ("this answer"). <code> add_filter( 'wp_nav_menu_objects', 't5_menu_log_link', 10, 2 ); /** * Add a link to the nav menu. * * @wp-hook wp_nav_menu_objects * @param array $sorted_menu_items Existing nav menu items * @param o... | Add log in link to menu in Twenty Twelve | wordpress |
I have the following two requirements: I want to allow users with the contributor role to upload media (images mostly) in their posts and preferably they shouldn't be able to delete existing ones before submitting it for review. I want to make sure once an article is published that it can't be edited by the contributor... | You can do all of this using the User Role Editor plugin. I normally tend to avoid answering questions by linking directly to a plugin but in this case, what you need comes in this package. | Allow contributor role to upload images and not edit already published articles | wordpress |
I am in a bit of dilemma here so bare with me. I want to add something like this code just after the content in a post: <code> <p>Please let me know what you think by <a href="#comment">leaving a comment</a>!</p> </code> To do this, I edited <code> single.php </code> and added it after the conte... | There are some global variables available (or not) to detect the current page number: <code> if ( empty ( $GLOBALS['multipage'] ) or $GLOBALS['numpages'] === $GLOBALS['page'] ) echo '<a id="lastPageLink" href="#comment">comment</a>'; </code> The best way to understand what they do is a look at the internals... | Add code just after Post content | wordpress |
I Look long enough to find the solution of my problem. Really, Is there any way to disable the "Remember me" to wp-admin? I want to disable it for safety reasons. Thanks in advance. | You can do it with JavaScript (jQuery) or outputbuffering. A combination of both (outputbuffering and JS) are in the script below. PHP: <code> namespace WPSE77581; add_action( 'plugins_loaded', 'WPSE77581\remove_forgetmenot', 10, 0 ); function remove_forgetmenot() { add_action( 'login_enqueue_scripts', 'WPSE77581\enque... | Disable the "remember me" to wp-admin | wordpress |
I have the WP3.4 and I would like to disable the admin bar. I have tried to do that with many ways, but the admin bar do not display. Is possible to do on this version of WP (3.4) or i make a mistake in the code? Below are the ways that I've tried. Thanks in advance. The 1st : <code> function my_function_admin_bar(){ r... | You need to specify the order or number which signifies when the Hook gets fired. In this case I beleive it's <code> 0 </code> and the filter is: <code> wp_admin_bar_render </code> . The action to remove the function I believe is: <code> remove_action( 'in_admin_header', 'wp_admin_bar_render', 0); </code> The Function ... | Disable the admin bar | wordpress |
I am trying to update wordpress from 3.4.2 to 3.5 . However, when I update, I get my old version 3.4.2 back. What could be causing this? When I click on update it shows all the steps but in the final step it gives back the 3.4.2 screen and the version remains un updated. | It's likely that the files aren't writable by WP for whatever reason. Do a manual upgrade instead. http://codex.wordpress.org/Updating_WordPress#Manual_Update | cannot update wordpress from 3.4.2 to 3.5 | wordpress |
Okay,here's my challenge. My client doesn't like how when you roll over an image in the gallery a tooltip shows up with the image's descritpion, which is taken from it's title tag. But he still wants the image description to show up as the caption when you click on the image and enlarge it. Here is a link to a page in ... | You're in the right file, <code> shutter-reloaded </code> is where you'll want to make the change. It looks like the gallery plugin is parsing the entire document for its links to start. That function is called <code> init </code> on line 34. Inside that function, the plugin is going to loop through all the links on th... | Want image captions to be from img ALT tags not title tags | wordpress |
I'm using a custom query on a page after the initial loop to list some posts from a category I'm associating with that page. Im doing this: <code> query_posts(array( 'category_name' => $name, 'orderby' => 'date', 'order' => 'DESC', 'posts_per_page' => 1, 'paged' => $paged)); </code> I've also tried using... | Though all of the arguments are optional, <code> paginate_links </code> doesn't necessarily do anything if there are no arguments. Take a look at the example at the example in the Codex. <code> global $wp_query; $big = 999999999; // need an unlikely integer echo paginate_links( array( 'base' => str_replace( $big, '%... | Having trouble generating pagination links on custom query | wordpress |
I'm trying to echo the content of a single post by using the_content(); but I get an empty result. However when I directly address the global $post, and specifically the post_content property it does show. What can cause such peculiar behaviour? CODE: the problematic line is near the end <code> <?php get_header(); ?... | After the <code> <ul> </code> part you do reset the query, but you also have to reset the original postdata: <code> wp_reset_postdata(); </code> and in the line <code> <li> <a href="<?php the_permalink(); ?>" <?php if (!isset($_GET['tab'])) {echo "class=com_sel"; $page = "אודות הקבוצה";} ?>&g... | the_content() isn't showing content, but $post-> post_content does | wordpress |
I have created two custom metaboxes using the Meta Box plugin for my cpt called books, and I am confused how to output the values. The values need to be used in sperate places in one of my templates. I tried using <code> get_post_custom() </code> and with <code> get_post_meta() </code> but couldn't get it to work. Here... | I assume you use the plugin 'Meta Box'. It should actually work fine if you try it with this line (Example with the Amazon Affiliate), just substitute <code> $bookID </code> with your ID or get_the_ID(): <code> echo get_post_meta( $bookID, 'rw_amz', true ); </code> Oh, and i just saw that you opened two <code> array </... | Function to return values from metabox | wordpress |
I am trying to use the draft_to_publish hook ( http://codex.wordpress.org/Post_Status_Transitions ) to run a function when a post that is a draft becomes published. This hook does not appear to be working: <code> add_action('draft_to_publish', 'myFunction'); </code> When I use this in my plug-in, myFunction is never fi... | You certainly have the right hook, but keep in mind that you are hooking your functionality specifically to the <code> draft_to_publish </code> action, i.e. to the specific case of a post-object pre-existing in the database with <code> draft </code> status being updated to <code> publish </code> . Note that this action... | Using the 'draft_to_publish' hook (post status transition) | wordpress |
I've dug through every question here on custom post type permalinks, but most seem to be either problems with custom taxonomy rewrites, or the obvious missing of flush_rewrite_rules(). But in my case, I'm only using a custom post type (no taxonomy), set to be hierarchical (so I can assign parent-child relationships), w... | So after confirming that I could get the expected hierarchical page behavior with a completely clean install and just a single CPT declaration, I knew the fault lay somewhere within my own plugin that I use to handle CPT creation (very complex, handles custom metaboxes, taxonomies, etc). Problem was, despite all the ad... | Getting hierarchical custom post type permalinks to work just like pages | wordpress |
I want to be able to post via a git repo. For example I have a repo named "blog" which contains these files: <code> first_post.md second_post.md another_post.md </code> I want all these files to appear in my blog like normal posts. I also want to be able to edit the files from the admin panel too (not only via git). Is... | Like the comments on this question stated, there is far too little detail in your post and it is far too localized of a question for this forum, but here is a general idea of what a project of this nature would require: You would need to utilize the GitHub API to dynamically pull new posts, as well as to enable modifyi... | Post via git repository | wordpress |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.