question stringlengths 0 34.8k | answer stringlengths 0 28.3k | title stringlengths 7 150 | forum_tag stringclasses 12
values |
|---|---|---|---|
I want to filter any HTTP request URI done through the HTTP API. Use cases: The WordPress update check goes to http://api.wordpress.org/core/version-check/1.6/, but https://api.wordpress.org/core/version-check/1.6/ works too, and I want to use this always. The new WordPress file is taken from http://wordpress.org/wordp... | Less than an answer, but just a list of things straight from my experience with it - maybe you've overlooked something. Debugging the request & its results Without diggin' too deep into the update process, but the WP HTTP API uses the <code> WP_HTTP </code> class. It also offers a nice thing: A debug hook. <code> d... | Filter any HTTP request URI? | wordpress |
I wrote this little function to automatically create a post for every user of the blog but it creates an infinite loop (I disabled it to stop it creating new posts). I'm not very skilled in php, I guess the error is in the use of wp_insert_post inside the foreach, but it doesn't work simply putting it outside the brace... | With that function in <code> functions.php </code> it is going to run on every page load and every time it runs it is going to insert a post for every user in your database. It isn't an infinite loop. You are just running it all the time. You need to run that one time and one time only to populate your DB with posts ex... | Insert new post for each user infinite loop error | wordpress |
How to make any plugin icon in wordpress post? The code I want to insert in plugin code and will appear in post bar [wp-admin/post.php]. Like this image: Output: If I click the icon it automatically writes <code> [plugin] </code> to the post content like this: | To add our button to the TinyMCE editor we need to do several things: Add our button to the toolbar Register a TinyMCE plugin Create that TinyMCE plug-in which tells TinyMCE what to do when our button is clicked. Steps #1 and #2 In these steps we register our TinyMCE plug-in which will live inside a javascript file at ... | How to add a shortcode button to the TinyMCE editor? | wordpress |
When on my main site NewMediaNook.wordpress.com, one particular post does not show a title (see image below). When I am on just that one post, the title appears, and all other titles appear when on the main site...but that one does not show up. All browsers look the same, regardless of login status. Can I just add it i... | This happens because you have set the post format of that entry to <code> link </code> , and for that post format TwentyEleven does not show the post title: <code> .format-link .entry-title { display: none; } </code> Solution: Use another post format ( <code> standard </code> for example) or another theme. | Blog post not showing title | wordpress |
after searching I didn't find an answer still confused of how do I hide the -> wp-content --> uploads --> themes --> plugins -> wp-includes in browser. What I want is when viewer browse some like this: http://www.mysite.ext/wp-content they will see an error: You don't have permission to access this page . Other said th... | Use in your .htaccess: <code> Options -Indexes </code> … to disable directory listings. See the Apache manual for details. To restrict the access just to two URLs you might use: <code> RedirectMatch 204 ^/wp-content/$ RedirectMatch 204 ^/wp-content/dir/$ </code> <code> 204 </code> is the No Content response. Very fast.... | How to restrict access to wp-content, wp-includes and all sub-folders | wordpress |
I have a loop that I would like to Offset by 1 so the most recent post is not displayed, and another loop where I only want 1 item which would be the most recent post. These are the loops I tried: for both: Offset Loop: <code> <?php query_posts('offset=1'); if ( have_posts() ) : while ( have_posts() ) : the_post(); ... | Neither of those are complete loops. That is, in both you have the start of an <code> if </code> but not the end of it, and the start of a <code> while </code> loop, but no the end of it. Also, you shouldn't be using <code> query_posts </code> either, as it over writes the main query and is rarely the right function fo... | Offset Loop by 1 , Limit next loop to 1 (Most Recent) Post | wordpress |
I would like to have a methodology for creating a functionality. When the user is connected, he will can access to a new page. In this page he will have the possibility to submit some fields like : a title, a description, an image and some tags. I have thought several things : I have to create a little plugin which wil... | I recommend the Gravity Forms plugin. You can create a form for your user to submit, and include a field for uploads. Less work on your side and a kick-ass plugin. | How to create an upload page (front side) | wordpress |
I have two custom post types, Books and Authors. Now, each book will have its corresponding author(s). I know how to associate books with authors using custom metas. However, over time, there will be a lot of books and corresponding authors. Which would be the best UI control to show a list of authors to select from, h... | I would add a meta box to the books custom post type, containing an input field with autocompletion, to select the author from the existing authors. You can also use a standard dropdown-field, but it gets crowded if you have a lot of authors. On the <code> save_post </code> action, add a meta_data field with the ID of ... | Using custom post type as taxonomy | wordpress |
I get a method not defined error when trying to call a function loaded with <code> wp_enqueue_script </code> from <code> site.js </code> . I'm guessing it's because of scope caused by the jQuery ready wrappers? How do I get around that? site.js (loaded in <code> head </code> ) <code> jQuery(document).ready(function($) ... | You need to put your <code> doSomething </code> in the correct namespace, or at least in a namespace. The simplest way would be to put it in the <code> window </code> namespace: <code> jQuery(document).ready(function($) { window.doSomething = function() { alert("Time for a coffee break!"); }; }); </code> | Can't call Javascript function - scope? | wordpress |
I have 3 custom post formats. One is for image, one for video, and, one for gallery besides the default post and they each have a view comments link on the bottom right corner at the end of the post. Here is the code for that(it's in every formats php file): <code> <div class="post-comments"> <p class="postcom... | Based on your comment: I am not trying to detect when I am on a single page but I want to have custom single.php pages like the wp codex says I can by doing single-post_format.php so that I can be able to have control of what you see on the single page for the different post formats(getting rid of the view commenmts li... | Custom single.php files for different post formats | wordpress |
How to hide customize menu and another submenu on wordpress? I already hide some submenu on wordpress like <code> function hiden() { remove_submenu_page( 'themes.php', 'widgets.php' );//widget remove_submenu_page( 'themes.php', 'theme-editor.php' ); //editor remove_submenu_page( 'themes.php', 'theme_options' );} //them... | If you deal with wp menus you shoudl use admin_menu filter. <code> add_filter('admin_menu', 'admin_menu_filter',500); function admin_menu_filter(){ remove_submenu_page( 'themes.php', 'widgets.php' );//widget remove_submenu_page( 'themes.php', 'theme-editor.php'); //editor remove_submenu_page( 'themes.php', 'theme_optio... | Hide submenu wordpress? | wordpress |
I am building a site in wordpress where at a certain part there is a container that has a list of post items (see it as a menu/sidebar), and an empty space where I will load content. When you click on one of the titles from the list of posts, the content of that clicked title is supposed to load into the empty div. Cli... | If the page & content is short enough & you don't mind some extra initial loading time, you can load all the content tabs on the page at the first time & then just use javascript to show/hide different tabs <code> // the loop to list the titles here $wp_query->rewind_posts(); // reset the loop while ($my... | Loading a post's content, into a div outside the loop, when it's title is selected in a list | wordpress |
Is it possible to create a link that allows site visitors to disable a plugin? I'm using a plugin called "any mobile theme" which automatically detects if the visitor is on a mobile device and automatically switches to a mobile-friendly version of the themes. This works very well, but I would like to give them option t... | According to the code … <code> // Embed Switch Links in Theme Via Shortcode // [show_theme_switch_link] function show_theme_switch_link_func( $atts ){ $desktopSwitchLink = get_option('show_switch_link_for_desktop'); global $shown_theme; global $status; if ($shown_theme){ $return = '<a rel="external" data-ajax="false... | Create a link which allows visitors to disable a plugin? | wordpress |
Is there a way I can not show something to mobile users? I have a floating social bar on my responsive theme, but it get in the middle of the content if I'm on my Android phone. I don't want to use display:none, since the JS will still load. Is there a function I can use to only show the floating bar for desktops users... | There is <code> wp_is_mobile() </code> function to conditionally display (or block) content for mobile users. <code> <?php if (!wp_is_mobile()) : ?> <!-- Stuff to hide from mobile users --> <?php endif; ?> </code> | How can i disable a plugin for a mobile phone? | wordpress |
I'm looking for some thoughts, ideas, and/or direction on what is the best way to accomplish this: Basically I want to have 1 "featured" post in a differently styled div, and then display the next 3 below it. I am using custom post types, so the built-in Sticky Posts feature won't work, and I'd rather not use a plugin.... | One way to achieve this is to establish two queries/loops, one that handles the featured post and the other which handles all other posts (except the featured post). How you distinguish what IS and what is NOT to be a featured post could be handled by a special placeholder category or by the use of a custom field , the... | How can I show 1 featured post in a styled element, and the next few below differently styled | wordpress |
I have created a Wordpress site and titles were working just fine. Then, some time and plugins installed later, I noticed that in SOME pages I get the title repeated 2 times. Example of wrong page title: Contact - NAME | NAME Example of normal title: Our Services | NAME Now, if I go to General Settings and change title... | In order to play nicely with Plugins or other code that attempts to modify the HTML document title content (i.e. <code> wp_title() </code> output), you should always and only output this: <code> <title><?php wp_title( '' ); ?></title> </code> ...and if you want to modify that output yourself, filter <... | Wordpress page title repeated in SOME pages | wordpress |
Update: I've changed the code as following <code> $cats = get_categories(); $output = array('categories' => array()); function collect_posts(){ $args = array( 'numberposts=' => 9999, 'category' => $cat ); $myposts = get_posts( $args ); foreach( $myposts as $post ) { setup_postdata($post); if (get_post_meta($po... | If you are using PHP 5.2+ you're best bet is to just make a PHP array or object and use json_encode() . UPDATED: <code> $cats = get_categories(); $output = array('categories' => array()); foreach ($cats as $cat) { $cat_output = array( 'cat_id' => $cat->term_id, 'cat_name' => $cat->name, 'posts' => arr... | WordPress JSON output | wordpress |
Can someone help me how to generate dynamic tabs with product categories in woocommerce. - product category as tab name, and their subcategories thumbnails as tab content | If you mean 'tabs' as in the way WooCommerce presents the Product Description, Attributes, and Review on the product page then take a look at the template files for WooCommerce. You can find them at ../wp-content/plugins/woocommerce/templates. There's a good article on customizing the templates at http://wcdocs.woothem... | woocommerce product category tabs | wordpress |
We've been looking for a Wordpress plugin or system that lets you scope admin/contributor "roles" down to the field level. We have an immediate need for something like that, but totally coming up empty on options. There's a ton of options that let us scope down to a custom post type, but not necessarily the fields with... | The only thing I've found so far that comes close to what I want is Adminimize . However, while it's doing what I want, it's incredibly time consuming to setup, since we need to target the style definitions in the HTML for each field individually, then apply those to the roles we have setup; rather than handling it fro... | Role scoping for contributors down to the field level | wordpress |
I run a multiple author platform and to improve the moderation, I want to add a couple of assisting editors. I want to add a custom box to the Post page where the assisting editor can confirm which tasks they have completed. So, this box would contain a checklist of options, for example: <code> 1 => ' Proofread ', 2... | <code> add_meta_box </code> should give you the box container like your have pictured. You have a select drop-down because that is what you created here: <code> echo '<select name="rating">'; echo '<option value=""' . ((($value == '') || !isset($ratings[$value])) ? ' selected="selected"' : '') . '> Untouche... | Adding an assisting editor box to Post page | wordpress |
When I'm on the main page, of my site, <code> site.com </code> it shows an excerpt of each post along with a category to the side. it also displays the same thumbnail image but above the content and I'm guessing because its grabbing the first image in the post.. I already tried removing <code> <?php the_post_thumbna... | WordPress will never use <code> single.php </code> to render the site front page. Refer to the Template Hierarchy for Site Front Page : <code> front-page.php </code> Static page hierarchy: <code> $custom-template.php </code> , <code> page-$slug.php </code> , <code> page.php </code> Blog posts index hierarchy: <code> ho... | Featured Image or Post Thumbnail Displaying on index.php? | wordpress |
I would like to have people write on my blog and i am ok with editing their own posts while on draft. However, once their posts are published, I wouldn't like them to be able to edit/delete any published posts, not even the owned that they have written. Is there a way to do that ? | Downgrade tham to Contributors user role. | Disallow authors to edit/delete their own or other published posts | wordpress |
I have this meta box that I have added to my site: <code> // Assistant Editor Box add_action( 'add_meta_boxes', 'assistant_editor_box' ); function assistant_editor_box() { add_meta_box( 'assistant_editor_box', // id, used as the html id att __( 'Assistant Editor' ), // meta box title 'assistant_editor_cb', // callback ... | As @totels says, just apply the condition when you add the box , rather than trying to remove it later (FYI, it's not working because you call the removal on hooks that fire earlier!) <code> add_action( 'add_meta_boxes', 'assistant_editor_box' ); function assistant_editor_box() { if ( current_user_can( 'edit_others_pos... | Trying to limit access to custom meta box without success | wordpress |
I have built a wordpress plugin (wp-content/plugins/MyPlugin) and I would to check some folders permission inside the MyPlugin directory. My problem is that I don't what Wordpress constant or what PHP function I should use to target on of these directories. <code> if( !is_writable(WP_PLUGIN_URL.'MyFolder') ) { echo 'NO... | Perhaps <code> WP_PLUGIN_DIR </code> ? <code> WP_PLUGIN_URL </code> is responsible for URLs. | How to get plugin's folders permission | wordpress |
While creating our portfolio i'd like to make a dynamic header with the latest 5/6 featured images in a row. All these posts come out of the 'apps' custom post type. <code> <div id="header"> <div class="latest_post"> <img src="featured image" class="class-name" /></div> <div class="second_pos... | First setup a WP_Query to fetch the latest 5 posts from your custom post type "apps". You also need to update a "counter" for each post in the loop. Then simply echo the count in the class for the div. <code> <?php //Query posts $query = new WP_Query(array( 'post_type' => 'apps', 'posts_per_page' => 5 )); //Re... | Latest 5 posts (custom post type), each post different CSS | wordpress |
I have been struggling for days to figure this one out. I have successfully implemented a form to submit posts from the front end of my site. ButI can't figure out how to make the image uploads work. I want whatever image the user uploads to automatically attach to the post and become its featured image. Can someone pl... | you can do that by running the function <code> set_post_thumbnail( $my_post_id, $thumbnail_id ); </code> remember, you have to process and insert the image into the library first: <code> $uploaddir = wp_upload_dir(); $file = $_FILES[ ... whatever you have in your POST data ... ]; $uploadfile = $uploaddir['path'] . '/' ... | Set Featured Image Front Frontend Form | wordpress |
Every time a page view occurs, wordpress is sending a complex non-indexed query below. The exact same query is sent over and over and it seems that it is being passed through some "caching" code. But why doesn't the cache actually prevent re-executing the query over and over? The query being caught, which is asked repe... | The Codex page for the Object Cache class holds the answer to this: By default, the object cache is non-persistent. This means that data stored in the cache resides in memory only and only for the duration of the request. Cached data will not be stored persistently across page loads unless you install a persistent cach... | Repeated nav bar queries failing to be cached | wordpress |
i am using onioneye, Ying yang theme and for pagination, i am using wordpress visual pagination plugin but where i am pasting the pagination code, it shows nothing :( template is: <code> <?php /* Template Name: Home */ ?> <?php get_header(); ?> <?php //function wp_paginate($args = false) { //global $wp_p... | Try the following; <code> global $wp_query; global $paged; $temp = $wp_query; $wp_query = null; $args = array( 'post_type' => 'portfolio', 'paged' => $paged, 'posts_per_page' => -1, ); $wp_query = new WP_Query( $args ); while ($wp_query->have_posts()) : $wp_query->the_post(); //do your output here... end... | Wordpress Pagination is not shown | wordpress |
I'm getting prompted to enter my FTP information (in this case, SFTP) for installing plugins/themes in Wordpress. Problem is, I keep getting denied with valid SFTP credentials. I have root access to my server as well. RedHat 6.3, MySQL 5.1, PHP 5.3.3 For troubleshooting sake, all of Wordpress's directories are currentl... | What if you try http://wordpress.org/extend/plugins/ssh-sftp-updater-support/ ? If that doesn't work you can do a quick code change to get the logs with which the developer of that plugin can use do more diagnostics. | Valid Connection Information is Getting Denied | wordpress |
I need to log fail and successful login actions. What hook is better to use for this? | There are a few different hooks you can use (from <code> wp_signon </code> ): <code> wp_authenticate </code> (action) <code> authenticate </code> (filter) <code> wp_login </code> (action) But you may do best to override the pluggable <code> wp_authenticate </code> (from <code> wp-includes/pluggable.php </code> ): <code... | Hook for fail and successful login actions | wordpress |
I've been banging my head against my iMac trying to figure out what's wrong. I've also trolled these archives and have tried the following things to fix: flush permalinks remove possibly conflicting categories/slugs <code> flush_rewrite_rules( false ); </code> <code> 'has_archive' => true </code> , <code> 'has_archi... | There aren't any golden answers to this problem, but for the sake of closing this thing out, I did get it fixed. For anyone else having this problem. I would highly suggest making a wordpress sandbox and building it out in a fresh install. I did that and it worked perfectly. The frustrating thing is, after adding back ... | Custom post types not using archive structure | wordpress |
I'm customizing a Woocommerce Wordpress site. In the Woocommerce product class ( <code> class-wc-product.php </code> ) the <code> get_price </code> function applies a filter as follows: <code> function get_price() { return apply_filters('woocommerce_get_price', $this->price, $this); } </code> In my functions.php I w... | It's missing the second argument because you didn't tell WordPress you wanted it with your <code> add_filter </code> call. By default, actions and filters only get one argument. Try this: <code> <?php add_filter('woocommerce_get_price', 'custom_price', 10, 2); function custom_price($price, $product) { ... } </code> | Wordpress apply_filters() Arguments Missing | wordpress |
This plugin only works as widget. I need call this plugin with php function. How to modify this code ? <code> <?php /* Plugin Name: AJAX Calendar Plugin URI: http://urbangiraffe.com/plugins/ajax-calendar/ Description: A version of the WordPress calendar that uses AJAX to allow the user to step through the months wit... | Depending on what you want you'll need to use the <code> the_widget </code> function, I believe there are few examples of using it in the WordPress <code> twentyeleven </code> theme as well. | Call plugin with php function | wordpress |
Looking for a way to redirect the user from the dashboard straight to <code> edit.php </code> if <code> wp_is_mobile() </code> is true. This is what I've tried: <code> function redirect_if_mobile() { $screen = get_current_screen(); if($screen->base == 'dashboard') { if ( wp_is_mobile() ) { $url = admin_url( 'edit.ph... | The action you're looking for is auth_redirect, which is before the headers but still recognizes $pagenow to tell which page you're on: <code> add_action('auth_redirect', 'the_mobile_boot'); function the_mobile_boot() { global $pagenow; if ( $pagenow == 'index.php' && wp_is_mobile() ) { header( 'Location: ' . g... | Redirect from the dashboard to edit.php if wp_is_mobile() is true | wordpress |
I'm customizing the admin edit.php screen and I have a column that displays a meta key <code> $gear </code> . But it only lists the first value instead of returning a list of all the values. Here's the bit that matters: <code> add_action( 'manage_artists_posts_custom_column', 'manage_artists_columns', 10, 2 ); function... | <code> $gear = get_post_meta( $post_id, 'gear', true ); </code> … will return the last value only, because you told it do that with the last parameter. Drop it, and you will get an array of all values: <code> $gear = get_post_meta( $post_id, 'gear' ); </code> Then print it with: <code> print join( $gear, ', ' ); </code... | function to return comma separated list of meta values | wordpress |
I have tried refreshing my permalinks but I still cant get this to work correctly. I have the categories <code> movies </code> , <code> gaming </code> , <code> blu-ray </code> , and <code> tv </code> already created, so my URLs are <code> site.com/movies/ </code> for example. I would like for a post for movies to be at... | If I understand what you are doing... If you have categories set to load at "/category-name/" and a category named "/movies/" and a custom post type set to load at "/movies/" you've got conflicting elements. The rewrite rules are competing. That is going to be problematic. If you set <code> has_archive </code> to false... | Custom Post Types and 404 Pages | wordpress |
If I call get_user_meta() to retrieve a value, does WordPress cache the value? If I call get_user_meta() to retrieve the same value, does WordPress have to query the database again or is it stored in PHP memory? | Yes, it does. That function is a wrapper for <code> get_metadata() </code> . Inside of that you can find: <code> $meta_cache = wp_cache_get($object_id, $meta_type . '_meta'); if ( !$meta_cache ) { $meta_cache = update_meta_cache( $meta_type, array( $object_id ) ); $meta_cache = $meta_cache[$object_id]; } </code> | Does WordPress cache get_user_meta() results? | wordpress |
How can i display 5 posts from current category (exclude current post). Order by post time. Example: To day news to reading 3 (12/11/2012 - 8:10 PM) To day news to reading 2 (12/11/2012 - 6:07 AM) To day news to reading 1 (12/11/2012 - 6:05 AM) Yesterday news to reading 2 (11/11/2012 - 9:10 PM) Yesterday news to readin... | <code> function filter_where_older( $where = '' ) { $date = get_the_time('Y-m-d H:i:s'); $where .= " AND post_date < '$date'"; return $where; } function filter_where_newer( $where = '' ) { $date = get_the_time('Y-m-d H:i:s'); $where .= " AND post_date > '$date'"; return $where; } $category = get_the_category(); i... | Get posts from current category? | wordpress |
I would like to use <code> $allowedposttags </code> to allow extra HTML tags during entry submission. Can I allow all attributes for a specific tag using <code> $allowedposttags </code> ? For example, the code below will allow iFrame tags and the src, height, and width attributes in the iFrame tags: <code> $allowedpost... | I'm pretty sure you have to explicitly name all allowed attributes - just use: <code> $allowedposttags['iframe'] = array ( 'align' => true, 'frameborder' => true, 'height' => true, 'width' => true, 'sandbox' => true, 'seamless' => true, 'scrolling' => true, 'srcdoc' => true, 'src' => true, 'c... | Allow all attributes in $allowedposttags tags | wordpress |
I am simply trying to print the value of a custom field. I have read all the documentation, tried out other people's suggestions, and nothing works. I can get it to print the ID #, but not the actual value I have in the field. I am using the Types plugin to create the field. this prints the ID: <code> <?php echo get... | The Types plugin is making this about 10x harder than it needs to be, you'll have to look through their documentation on the issue, but from what I can tell they don't store items in the <code> postmeta </code> table in a straightforward way. I created a simple field with the plugin in a sandbox env and the <code> meta... | Display value of custom field not working | wordpress |
I'm trying to create a list of parent IDs for a custom post type for use within a "must use" plugin I'm developing on a project. Here's the code I'm using to generate the query: <code> $cpt_parents = new WP_Query( array ( 'post_type' => 'cpt', 'posts_per_page' => -1, // Get them all 'post_parent' => 0, // Retu... | I figured it out. I moved the reference to WP Alchemy within a function that fires after init. Everything now works great and I can use WP_Query within the setup files. Here's a code reference: <code> // WP Alchemy Setup function jd_setup_wp_alchemy() { include_once WPMU_PLUGIN_DIR . '/jonathanwold/metaboxes/setup.php'... | Using WP_Query within an mu-plugin | wordpress |
I'm working on a site that uses the WP e-commerce plugin (Gold version) and I need to display a list of products that match a list of SKUs. Users fill in a form, and a list of product SKUs is generated depending on their answers. I need to create a page that fetches these products and displays them, preferably in the d... | WP E-commerce uses WordPress post objects to store products, so you don't need any special functions or callbacks. <code> query_posts </code> will support everything you need, you can learn about the details of how everything is set up by reading about their database schema . Specifically, the SKU is in the <code> wp_p... | WP e-commerce: getting products by SKU | wordpress |
I'd like to put something like this in searchform.php: <code> <?php if($widget){ ?> //load serach form for sidebar... <?php }else{ ?> //load different search form for page content (404 page) <?php } ?> </code> How can I prepare <code> $widget </code> variable? Or maybe I should use another method? Lik... | Check if searchform is included? The <code> get_search_form() </code> function (that should be used) uses <code> locate_template('searchform.php'); </code> to display the search form. The later returns (as you can see from its source) the template filename if one is located So if you're just wanting to catch the defaul... | How to check if searchform.php is being included as widget? | wordpress |
I'm trying to get with <code> get_user_meta </code> the meta_key where the meta_value is <code> 'ive-read-this' </code> But I do not get the value. What should I do? | I agree with @Simon Blackbourn, but for arguments sake, here's one technique: <code> $data = get_user_meta( $user_id ); $data = wp_list_filter( $data, array( 'ive-read-this' ) ); $keys = array_keys( $data ); </code> | list or get meta_key where meta_value is 'something' | wordpress |
I have a shortcode that outputs null (""). What I'm trying to accomplish is to output a default message if the shortcode outputs null. I don't want to extend my shortcode because there may be multiple instances of the shortcode and I don't want to output the message multiple times. So my function is as follows: <code> ... | if you want to keep the current setup, try to hook in early and use <code> do_shortcode() </code> : <code> function av_standalone_doc_404($content) { remove_filter( current_filter(), __FUNCTION__ ); if ( has_term( 'standalone-document', 'formats' ) ) { $filtered_content = do_shortcode( $content ); // … </code> If you w... | add_filter to the_content after apply_filters | wordpress |
I want to embed a social sharing button in the theme. Following is the standard code to embed the twitter button. <code> <a href="https://twitter.com/share" class="twitter-share-button">Tweet</a> <script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createEle... | Put everything between <code> <script> </code> & <code> </script> </code> in a separate file. Then use <code> wp_enqueue_script </code> with the correct path of the file & dependencies to false. After that you can use only <code> <a href="https://twitter.com/share" class="twitter-share-button">... | Using wp_enqueue_script with social media buttons? | wordpress |
When I'm getting custom post types with WP_Query-> query(), it isn't really necessary to execute the the_post() function, because you can iterate over the query result array. Is it considered good behaviour to do this, or is it truly just a convience method? | It is necessary to execute that function if you want to use the template functions such as <code> the_title() </code> & <code> the_permalink() </code> . You should not use it if you aren't using those kind of functions but for the themes it's generally recommended to use these functions since they automatically ens... | Why execute the_post()? | wordpress |
I'm creating a theme for a client and one of their requests is to allow users to upload images for their own use, but there may be an option to share the images. Here are some of the caveats: Each user has the ability to upload their own images to their own Media Library. These images must be capable of being 'tagged' ... | Built in features The Media Library has major updates with the upcoming version. You can see the changes in the slides by Daryl Koopersmith here . You can read the announcement and discussion on "Make" . Your request for "tags/categories" is already built into 3.5. Note The difference between themes and plugins is pret... | Separate Media Library for each user | wordpress |
Im trying to get a load more function to work with a custom post type on an archive page. I use this plugin and customized it a bit so it works with a custom post type. http://www.problogdesign.com/wordpress/load-next-wordpress-posts-with-ajax/ Currently pagination doesn't work so that the plugin can't load more items.... | The problem with pagination was fixed by removing the wp_query loop and using the normal loop. <code> <?php if (have_posts()) : while (have_posts()) : the_post(); ?> <?php endwhile; endif; ?> </code> The problem with the "load more" plugin was fixed by using the right classname to load the items. And change... | Pagination does not work on Custom Post Type archive while trying to get load more function working | wordpress |
I've googling for a solution for this issue and found nothing: I have some posts from a Custom Post Type (Restaurants) and its taxonomies ('city' and 'cuisine'). Whenever I create a restaurant post, I can set many 'cuisine' terms as I want, but 'city' is single selected. I've also made a custom search using a html drop... | Here's part of the answer... how to query for the terms you're looking for. But it sounds like you'll need some ajax to re-query for each selection. City and cuisine would be dynamic, but essentially the when the user selects the city populate that data into the <code> $city </code> variable, and so on. Someone else wi... | Dropdown: Display terms from B only if has relationship with a term A selected | wordpress |
I am building a sports chat website and I cannot seem to find a good method to add multiple chat rooms. What I mean, for example - I want to create a chat room for each NFL team, but each chat room should be on its own page. | Finally found a plugin that seems to work - Chat Room - http://wordpress.org/extend/plugins/chat-room | How to add multiple chat rooms in a WordPress website | wordpress |
I am trying to create a layout with two different divs alternating vertically. For example the even has to be: picture + content; and the odd has to be: content + picture. Here is my code, at the moment it prints every post doubled, once per div: <code> <div id="content"> <?php if (have_posts()) : while(have_p... | minimal necessary correction - move <code> the_post(); </code> to before the <code> if(($i%2 == 0) : </code> for instance: <code> <?php if (have_posts()) : while(have_posts()) : the_post(); $i++; if(($i % 2) == 0) : ?> </code> | Alternating post layout | wordpress |
I'm trying to get a value from a PHP function through Ajax and save it in a variable in jquery. The PHP; <code> add_action( 'wp_ajax_mark_as_read', array( &$this, 'readen_color' ) ); public function readen_color() { if( isset( $_POST['post_id'] ) && is_numeric( $_POST['post_id'] ) ) { echo 'hello'; } } </co... | You are passing 'readen_color' as the action parameter, but you've defined the ajax action as 'mark_as_read'. Try this: <code> $.post(ajaxurl, { action:'mark_as_read', post_id: iPostId }, function (response) { console.log(response); }); </code> And as for your PHP: <code> add_action( 'wp_ajax_mark_as_read', array( &... | How to get a value from PHP in Jquery through Ajax | wordpress |
I'm trying not to show comments from a certain custom post type int the comments list on the admin interface. I went to the "wp-admin/includes/class-wp-comments-list-table.php" and tried to play with the $args array which is passed into the "get_comments" function in order to feed the comments list table. If I add a po... | You'll need to filter <code> comments_clauses </code> , since <code> WP_Comment_Query </code> only supports a limited <code> post type == X </code> argument. <code> /** * Exclude comments of the "foobar" post type. * * @param array $clauses * @param object $wp_comment_query * @return array */ function wpse_72210_commen... | Exclude post_type from admin comments_list | wordpress |
I want to pass <code> bloginfo( 'template_directory' ) </code> in an array I tried this but not working. How to write it correctly? <code> <?php get_the_image( array( 'size' => 'full', 'default_image' => bloginfo( "template_directory" ) .'/img/dflt.png', 'image_scan' => true, 'link_to_post' => false ) );... | <code> bloginfo() </code> is using <code> echo </code> , you need a function that returns its value: <code> get_bloginfo() </code> . In this case you could also use just the function <code> get_bloginfo() </code> is using: <code> get_template_directory_uri() </code> . | How to use bloginfo( 'template_directory' ) in array | wordpress |
I'm looking for a way to conditionally load different scripts if the user is accessing the admin area from a mobile device. In my case I'm looking to restrict the user to just be able to make new posts, so if you log in to the admin area from a mobile device you're redirected to the post listing and the admin menu isn'... | <code> wp_is_mobile </code> should be the switch you need, but you may be talking about a lot of edits to a lot of components to do what you describe. I don't know enough about the rest of your code to guess at what kinds of things you would need. | Conditionally load CSS/JS/PHP in wp-admin if using a mobile device | wordpress |
I like to have folders in my theme folder for scripts and styles, but I can't access these folders in the "Edit Themes" interface. This is problematic for clients that don't give me FTP access. Is there a way to see these folders and the files in them from the Wordpress admin section? | There is not a way to do this without modifying the core. You should see <code> .php </code> files that are in subdirectories, but you won't see anything above the root theme directory for <code> .css </code> files, and you won't see any JavaScript files. If you take a look at <code> wp-admin/theme-editor.php </code> ,... | How to see files in directories in "Edit Themes" screen | wordpress |
I have a custom function which allows users to choose between next/previous links and pagination and I'm attempting to add CSS classes to the next/previous links. I've tried this multiple ways and keep crashing my theme. How do I insert CSS classes into the previous and next link? <code> // Pagination function my_theme... | You could do this with jQuery. Like so ... <code> $("a:contains('Newer')").addClass('YourNewerClassHere'); $("a:contains('Older')").addClass('YourOlderClassHere'); </code> | How do I insert CSS into a function? | wordpress |
I am new to wordpress (installed yesterday for first time). In order to add syntax highlighting i installed the WP-Syntax plugin and i copied pasted the following snippet in the edit post window. Its copied from the usage examples. <code> <pre lang="php"> <div id="foo"> <?php function foo() { echo "Hello... | Have you looked to see if the correct style sheet is being loaded to change the highlighting? It appears to be a white background with some font styling for the different language. If you want something more than that, you will need to customize the css for it. | WP-Syntax plugin not working | wordpress |
I'm trying to list the terms of a custom taxonomy ('genre') in the overview table in the admin area for a custom post type ('station'). To get this, I tried the following code in my theme's functions.php file: <code> register_taxonomy('genre', 'station', array( 'labels' => array( 'name' => _x('Genres', 'taxonomy ... | Always check the codex - <code> get_terms( $taxonomies, $args ) </code> - your code should read: <code> $genre = get_terms( 'genre', array( 'include' => get_post_meta( $post->ID, 'maingenre', true ), )); </code> | Displaying custom taxonomy in the admin list of a custom post type | wordpress |
I have categories like <code> gaming </code> and <code> movies </code> on my website and when a user visits any of these categories the content in the sidebar is displayed depending on the category they are in. So gaming content for the gaming category, movie related content for movies. When a user selects a post in ei... | You can combine conditions: <code> if ( ! empty ( $GLOBALS['post'] ) && is_single() && in_category( 'gaming', $GLOBALS['post'] ) ) { // do something } </code> See PHP manual: Logical Operators and stackexchange-url ("Exclude custom function content from certain pages"). | Conditional for a Single Post That Belongs to a Category? | wordpress |
I have a Wordpress site that uses several plugins, namely 8. Most of these plugins include a lot of their own JS and CSS files, some even include so much as 3 separate CSS files. One can imagine that this does a number on the amount of HTTP requests and thus the load time. Many of these plugins also only get used on ce... | Previous versions of WordPress didn't really provide a good means to conditionally enqueue stylesheets and JavaScript within a plugin (i.e. only when needed). So most plugin authors enqueued both on every WordPress init/load, even if the plugin wasn't being used on a given page. Current versions of WordPress allow for ... | How can I reduce the amount of files loaded/included per plugin? | wordpress |
I used the following query to have only 1 post published on the homepage from a particular category: <code> <?php if ( have_posts() ) : ?> <?php query_posts('posts_per_page=1&orderby=date&order=DESC&cat=6'); ?> <?php while ( have_posts() ) : the_post(); ?> <?php wpe_excerpt('wpe_excerpt... | Assuming, as per the above comment, the format of the dates is <code> YYYY/MM/DD </code> : <code> $args = array( 'posts_per_page' => 1, 'cat' => 6, 'meta_key' => 'begin_date', // adjust to actual key 'meta_value' => date( 'Y/m/d' ), 'meta_compare' => '>=', 'order' => 'ASC', 'orderby' => 'meta_va... | Show 1 post and after a specific date show the next one | wordpress |
I'm trying to make a page with multiple loops, I need every loop to display a predefined number of posts from the same category (every loop displays X number of posts from Category CATS). But I also need the second loop, the third loop and so on to display the posts from where the last loop stopped, without duplicating... | it is important to read this Codex chapter all the way to the end, as the essential suggestions are after this heading 'Note for Multiple Posts in the First Category' ; repetitive, tedious code: <code> <?php $do_not_duplicate = array(); ?> <?php $mosaics = new WP_Query('category_name=mosaics&posts_per_page... | Multiple loops in same page, without duplicate content | wordpress |
i have tried <code> %tag% </code> in permalinks but it dont showing tag name in the permalinks... What i wanna do is to use the first tag name in the permalinks. So, how to do it? Thanks | Use <code> add_rewrite_tag() </code> to register the placeholder, and filter <code> post_link </code> to insert the correct tag. Use <code> get_the_tags() </code> to get the tags for a post. Sample plugin I have used in a project: <code> <?php /** * Plugin Name: T5 Tag as rewrite tag * Description: Use <code>%... | How to use first tag in permalinks | wordpress |
Related to this question (stackexchange-url ("Use wp init hook to call other hooks?")) but not the same. Sometimes, I found that the hook will failed to run when I place inside the init hook, e.g. Not Work: <code> add_action('init','my_init'); function my_init() { add_filter('locale', ... } </code> Work: <code> add_act... | The <code> locale </code> hook happens long before <code> init </code> . To see when which hook, variable, constant, function, class or file is available install my plugin T5 WP Load Order . You get a looong file with a very detailed log. Search for <code> Hook: locale </code> , then for <code> Hook: init </code> . You... | Failed to invoke other hook from the init hook | wordpress |
I want to have custom post type that have only title and archive page, but no detail page. Here is what custom post type code: <code> add_action( 'init', 'register_cpt_trivia' ); function register_cpt_trivia() { $labels = array( 'name' => _x( 'Trivia', 'trivia' ), 'singular_name' => _x( 'Trivia', 'trivia' ), 'add... | You can't just disable single pages, you can however make it appear as if they do not exist. I suggest 1) ensure that there are no links on the site pointing to the single page 2) Create a file "single-trivia.php" in your theme with the content as <code> <?php include '404.php';?> </code> 3) use <code> template_r... | Custom Post Type with archive page but no detail page | wordpress |
My Thumbnails seem squished for some reason even though I copied the code from some thumbnails I have that seem to be working fine. The code that works: in index.php <code> <a href="<?php the_permalink(); ?>"> <?php the_post_thumbnail( 'category-thumb',array('title' => "")); ?> </a> </code> i... | Had to regenerate all thumbnails. The name of the plugin is "regenerate thumbnails" for those that may run into a similar issue | Sidebar Thumbs Squished? | wordpress |
After much headache in the last week I feel like my problem is almost solved. I have been attempting to customize the admin edit.php page of custom post types to display and sort/filter custom taxonomies. I've frankensteined a collection of actions and filters from things found on the web but fear I may be using deprec... | <code> taxonomy </code> & <code> term </code> won't be set (in this case), since query vars are mapped from GET/POST. In other words, <code> $qv['large_feature'] = 291 </code> (see <code> wp_edit_posts_query() </code> and <code> WP_Query::get_posts() </code> for the big picture). <code> add_filter( 'parse_query','c... | Get parse_query filter to return slug instead of id | wordpress |
I'm using <code> the_excerpt(); </code> in blog.php file (post listing page) and it doesn't recognize <code> <!--more--> </code> if "Excerpt" field is empty and it grabs the beginning of the content as excerpt. This issue is described here: http://codex.wordpress.org/Template_Tags/the_excerpt but I don't know why... | I do not know why the WordPress powers that be decided to do it the way they did but they don't consider the part before the <code> <--more--> </code> to be the same as the excerpt . Whether that makes sense or not is probably an irresolvable matter of perspective. I'd accept it and make do. The distinction actua... | The_excerpt() doesn't parse - how to change that? | wordpress |
I was interested to read the answer to this question on how to paginate posts correctly that are random ordered. stackexchange-url ("Is it possible to paginate posts correctly that are random ordered?") My goal is to randomly order posts that appear in a certain category on my site, in this case artists. Here is the co... | You can use the <code> add_filter </code> line inside the template itself & no filter in the "functions.php" file. Then just after retrieving the posts remove that filter with a call to <code> remove_filter </code> . The actual function may still reside in the functions.php file <code> add_filter('posts_orderby', '... | How to paginate posts correctly that belong to a particular category and are random ordered | wordpress |
Given the user ID, how can I display all the blogs where this user is administrator? I tried: <code> <?php $user_id = 2; $user_blogs = get_blogs_of_user( $user_id ); echo '<ul>'; foreach ($user_blogs AS $user_blog) { echo '<li>'.$user_blog->blogname.'</li>'; } echo '</ul>'; ?> </code> H... | The capabilities are stored as user meta data in a serialized array for each site. The key as a regular expression would look like that: <code> '~' . $GLOBALS['wpdb']->base_prefix . '(\d+)_capabilities~' </code> So … get the user meta data, find the capability strings (they hold the roles), and compare the unseriali... | How can I display all Multisite blogs where this user is administrator? | wordpress |
To get a the path to a plugin you can use <code> plugin_dir_path(__FILE__) </code> - but this obviously has to be called from within the plug-in. How can you reliably get the path to plugin B ( <code> pluginb/pluginb.php </code> ) from within plug-in A? Edit: Its assumed you know the slug of the plug-in you're after (a... | My best guess would be: <code> if ( ! is_file( $dir = WPMU_PLUGIN_DIR . '/pluginb/pluginb.php' ) ) { if ( ! is_file( $dir = WP_PLUGIN_DIR . '/pluginb/pluginb.php' ) ) $dir = null; } return $dir; </code> However, the danger here is still the assumption of the plugin's "basename" - a well written plugin will still functi... | Get a path to a different plug-in | wordpress |
I'm trying to improve a bookmarks manager/theme I've built ( http://bookmarkie.waterstreetgm.org ). Right now, each post is simply a link: <code> <a href="http://tumblr.everlane.com/page/4">Everlane Tumblr</a>. </code> ie: that one single link is the entire content of <code> the_content() </code> . Easy eno... | You're just looking in the wrong place: <code> php > $txt = '<a href="http://tumblr.everlane.com/page/4">Everlane Tumblr</a>'; php > $matches = array(); php > echo preg_match_all('#\bhttps?://[^\s()<>]+(?:\([\w\d]+\)|([^[:punct:]\s]|/))#', $txt, $matches); 1 php > print_r($matches); Array ... | Extract a link in the_content() | wordpress |
I am using this custom function to add a publish/unpublish button to the front end of my site for the users: <code> if ('draft' == get_post_status ($post_id)) { $post = get_post($post_id,ARRAY_A); $post['post_status'] ='publish'; wp_insert_post($post); } else if ('publish' == get_post_status ($post_id)) { $post = get_p... | I figured it out! Apparently categories are no longer part of the database table for posts and are instead stored elsewhere. Therefore using the wp_insert_post has no way of setting a category. I had to use wp_set_post_terms in order to set the categories which worked to automatically set both the parent and the child ... | wp_update_post is not updating category | wordpress |
Is it possible to limit the Excerpt field on the post page in words? Note that I am aware that it's possible to echo the excerpt and limit it in words, but I want the field itself to limit the amount of words, similar to how character limits on text-areas work. Is such thing possible ? Maybe a Javascript solution? Mayb... | You can use something like jQuery Simply Countable plugin and attach it to excerpt input. <code> Limit_Excerpt_Words::on_load(); class Limit_Excerpt_Words { static function on_load() { add_action( 'admin_enqueue_scripts', array( __CLASS__, 'admin_enqueue_scripts' ) ); } static function admin_enqueue_scripts() { global ... | Limit the Excerpt field in WP-Admin in words | wordpress |
My lovely colleagues have once again designed something that gives me a hard time getting it in Wordpress. Surprisingly it's something that I have done multiple times before; having recent posts and page content on one page. The homepage is a page. Just above the page's content there are three recent posts. For the pos... | never, ever use the variable <code> posts </code> in Wordpress for custom loops. After changing the variable name to <code> items </code> in <code> news.php </code> everything worked excellent. When I changed the variable <code> post </code> to <code> item </code> , it stopped working again... <code> <?php foreach($... | Multiple loops are not reset | wordpress |
I'm currently trying to layer a post title on top of the posts featured image but all I see at the moment is " );"> " instead of the image. The code I'm using is as follows: <code> <div style="width:609px;height:364px;background-image:url(<?php the_post_thumbnail(); ?>);"><h2><a href="<?php the_... | <code> the_post_thumbnail() </code> does not return the path of your image. Instead, it returns the complete HTML markup for that image. You can use this instead: <code> $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ) ); echo $image[0]; </code> If you want a specific size you can pass an add... | Layer post title on top of image Wordpress featured thumbnail image | wordpress |
I've got a few custom post types with different taxonomies and I have a function that adds certain categories to post list view in edit.php admin screen. Everything good there. I've also added a function that will allow the user to sort by those categories. This is where things go wrong. When you sort by name or date, ... | The problem is <code> 'meta_key' => 'large_feature', </code> in your last function, here the "large_feature" is a taxonomy, not a "meta_key". Infact there is no post in wordpress which has "large_feature" as a "meta_key". That's the reason wordpress didn't display any posts. About ordering by taxonomy terms, wordpre... | Sorting custom post types in edit.php : Post disappear | wordpress |
I have a blog network (Multisite), with domain mapping plugin installed, and some of my sites are under development, so I want to lock them from not registered users. I tested a few plugins designed for this purpose ( Private Only , Private WP suite , Private WP , Members Only , Registered Users Only , Absolute Privacy... | I don’t have the domain mapping on a test installation at hand currently, but what should work is: <code> add_action( 'template_redirect', 'auth_redirect' ); </code> As a plugin here: T5 Force Log In . <code> auth_redirect() </code> is WordPress’ native handler for authentication, if it doesn’t work, something is broke... | Lock one of WP Network sites for not registered users | wordpress |
I'm making a travel site and for each page/post I want to display a google map and an image of the place referenced in the post/page the image is kind of banner-size so I dont think that the post thumbnail would do (unless I can get the high-res image of which the thumbnail comes from) I thought of getting the first im... | You can use the featured image (or featured thumbnail) for this type of functionality. You can control which size of the image you use... it doesn't have to be the "thumbnail" size. From the codex : <code> get_the_post_thumbnail(get_the_ID(), 'thumbnail'); // Thumbnail get_the_post_thumbnail(get_the_ID(), 'medium'); //... | How can I get the featured image or the first image for a post/page and display it as a banner? | wordpress |
I modified my category.php file to pull posts from all the categories that are posted to a main category parent. It's working perfectly. Now I need to get it so that when you click on the child category permalink, it will take you to that category and list all the posts from that category. That's not working perfectly.... | I found a solution by changing my categories.php to category-slug.php and then putting the standard loop back into the the category.php file. All seems good now. | stuck with template hierarchy | wordpress |
I am setting up a big blog for a client and we're looking to replace the wp.me shortlinks in the header and in everything with our custom domain on bit.ly. I have working code to build the Shortlinks, im just wondering if there is any way to replace the functions so pressing "Get Shortlink" and tweeting links, would us... | Totally possible, here is a great walkthough: http://bavotasan.com/2010/create-bit-ly-short-urls-for-your-posts-in-wordpress/ Bullet points: -Write a function that gets the bitly link upon publish -Remove the default action and add your own -Call wp_get_shortlink() like normal and bitly will be used | Replacing the WP.me URL shortener with Bit.ly | wordpress |
I am wondering if anyone knows the best method for splitting 1 custom menu widget (located in my sites footer) in to 2 columns. There are a total of 8 links, so I would like it to be split in to 2 columns of 4 links. Not sure if there is a function for this or is there some CSS to achieve this? The HTML markup from the... | Purely with CSS you could set a width for menu items, float them and then set the UL to twice that: <code> footer ul { width: 200px; } footer .menu-item { float: left; width: 100px } </code> (I don't know what elements you are using to designate your footer, you'll need to update that to match your structure.) | Wordpress Custom Menu Widget Style | wordpress |
I have two custom taxonomies; "name" and band". The first represents the name of the song, the second represents the band that made the song. I want to automatically save a combination of those two custom taxonomies in the post title upon saving. So in the following example: name = "Little Lion Man" band = "Mumford and... | Updated Answer: You're trying to mix a lot of things that you don't understand, by using the <code> $args </code> in <code> wp_get_post_terms </code> you don't need to run the <code> foreach </code> to hunt for child terms (is your custom taxonomy even hierarchical anyway?). As a catch-all you can just <code> implode <... | saving custom taxonomy as post title | wordpress |
I am using the latest version of wp-ecommerce (3.89) and a new filter has been introduced to enable role based access to certain dashboard features such as the sales page or upgrade capability. However, the default role in the core file is currently set to "administrator". What I would like to do is take the original f... | The filter exists to avoid the need for replacements in the plugin code. What you probably need is: <code> add_filter( 'wpsc_purchase_logs_cap', 'wpse_72095_admin_to_editor' ); function wpse_72095_admin_to_editor() { return 'edit_others_posts'; } </code> This will change the capability/role to <code> editor </code> . | modify a function filter | wordpress |
Is there a good reason why the wp media upload button is not placed within the main edit toolbar, and can we put it there instead of floating above?? | There is an action <code> 'media_buttons' </code> where these buttons are inserted. Some plugins are using that action to add more buttons, dropdown lists or links. If they had to use the TinyMCE toolbar, they had less room and more restrictions regarding style and JavaScript access. In short: the current placement is ... | Why is the media upload button not in the main toolbar & can it be placed there instead? | wordpress |
Situation I've just setup a new installation of WordPress (running on XAMPP/Win7). As I had a port conflict on <code> :80/:443 </code> , I switched to <code> :187/4430 </code> . Error When I'm now trying to access <code> http://vanilla-mu.dev:187/index.php </code> (or any other request), then I run into the following W... | As mentioned in the question itself, this is a problem a non-solvable due to the internals of WP core. What I did was getting rid of the interfering/colliding process - I simply turned it off (as changing the port wasn't possible). | Custom port problem with local MU installation | wordpress |
I recently saw an admin panel that had options to set background images for a page. The option was found on from clicking pages and then a "main page". Under the description was a form that allowed you to upload up to 5 different images. You could reorder them etc. This in turn uses those images to rotate through backg... | i would try the plugin " attachments " for the images. use it all the time for making page-specific galeries, downloads, etc. afterwards, you can use the script " supersized " Enqueue the Javascript from the Plugin, and place the following Code into the <code> <head> </code> : <code> <script type="text/javascr... | Rotating background images with admin options | wordpress |
I'm building a CRM-Theme for Wordpress. So i post, edit and delete posts from the Frontend. I'm on a good way to resolve all problems, i think. But there is one failure. At the index there is a "edit" and "delete" button. If i click on "edit" I'm getting to a form. I can change the post_tags there. Changes will be save... | Ok, found a solution by myself. In the past i saved post_tags with <code> wp_set_post_terms($pid, array($_POST['post_tags']),'post_tag',false); </code> Now i save the post_tags with <code> wp_set_post_tags($pid, $_POST['post_tags']); </code> and it works. This way is the same method, i use to publish a new post from th... | Edit a post from frontend. post_tags get saved, but not separated | wordpress |
I'm working on Single Page WordPress Theme where I want to get_pages() as per custom menu order. I have gone through the reference for get_pages() which only allows for default menu : <code> get_pages('sort_order=asc&sort_column=menu_order'); </code> Is there any way to get_pages() as per custom menu order ? | I Have Found My Own Solution. I Tried To Get Page ID Of Each Custom Menu Item & Rendered Page Based On That ID. Reference : wp get nav menu items Like This... <code> $menu_name = 'primary-menu'; if ( ( $locations = get_nav_menu_locations() ) && isset( $locations[ $menu_name ] ) ) { $menu = wp_get_nav_menu_o... | get_pages() as per custom menu order | wordpress |
Wordpress has a feature whereby it will automatically redirect your URLs if it percieves them to be written wrongly. Here is an example: I have a page called <code> my-page </code> If I go to: <code> www.mysite.com/something/my-page/ </code> it will immediately redirect me to <code> www.mysite.com/my-page/ </code> as n... | This worked for me: <code> remove_action('template_redirect', 'redirect_canonical'); </code> | How to prevent automatic redirection? | wordpress |
I am trying to transfer a blog from wordpress.com to my own server. The site on wordpress.com uses the Origin theme, with a custom header image set. I have installed that theme on Wordpress on my own server, but I don't seem to have the option to select a header image. If I look at the options under Appearance, on my o... | Many times, the same theme for self-hosted will be different that the same for .com because of the way .com works and the choices theme authors and .com make for their offered themes. If you want, you can download the theme from https://wpcom-themes.svn.automattic.com/ and match the code or adapt that theme to work on ... | Theme seems to have different options on wordpress.com and own-server install | wordpress |
I have a site that has changed its pagination structure, resulting in a huge amount of 404 errors (more posts are being shown per page than previously, so there are lots of pages that were once indexed in search engines that are now 404'ing). What I want to do is create a function that will check whether a page number ... | If the rest of your function works you just need to add a call to wp_safe_redirect and hook the whole thing into WordPress . I think that the first hook that will have a populated <code> $wp_query </code> is <code> wp </code> . So alter the last part of your function... <code> if($max_page < $paged){ wp_safe_redirec... | redirect pages with no content, instead of 404 error, using max_num_posts? | wordpress |
I want to add a check option to the wordpress admin sidebar when I am writing a post or a page to display a specific widget. I tried display-widgets plugin but I want to be able to show a widget directly while writing the post. Or is there is another way to do this it will be OK. | Barring the discovery of a plugin that does this already (I'm not aware of any that specifically do what you want) you'll need to create your own. <code> add_meta_box </code> and <code> add_filter('widget_display_callback', $instance, $widget, $args) </code> should be the bulk of what you need | Show or hide a widget from pages | wordpress |
Has anyone used the "WooCommerce Layered Nav" widget. I wonder if the attributes could be visible on the single product page? | Finally i solve this problem: <code> <?php if (is_singular() ) : ?> <?php foreach ($attributes as $attribute) : ?> <h3><?php echo $woocommerce->attribute_label( $attribute['name'] ); ?></h3> <ul> <li><?php $values = woocommerce_get_product_terms( $product->id, $attribu... | WooCommerce Layered Nav Widget | wordpress |
I have used the code below to add frontend editing to my posts/pages. How would I go about saving the post content when an update/save button is pressed? <code> $post_id = get_the_ID(); $settings = array( 'wpautop' => true, 'media_buttons' => true, 'wpautop' => true, 'tinymce' => true, 'quicktags' => tru... | You should use the <code> wp_update_post </code> function. | Updating post content on the front end | wordpress |
Currently my site has a lot of 301 redirects we are managing in our .htaccess file (several hundreds 301 redirects); however, I am wondering would it be better and more optimal I use a plugin such as Redirection to accomplish this? | This is not really a clear question, and plugin suggestions are usually closed, as per the FAQ stackexchange-url ("stackexchange-url It all depends on what kind of work you want to do: either edit .htaccess or work with a plugin GUI. Redirection works well and will allow entry of rules via CSV file and logging of all r... | What's the best way to manage a lot of 301 redirects in WordPress? | wordpress |
So this PHP code works for me: <code> $ch = curl_init( TCS_CPDF_REMOTE_ZIP ); curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true ); $data = curl_exec( $ch ); curl_close( $ch ); file_put_contents( TCS_CPDF_LOCAL_ZIP, $data ); </code> but when trying to use the WordPress HTTP API: <code> $the_body = wp_remote_retrieve_body( ... | Check out <code> download_url() </code> - it's only loaded in the admin, so you'll have to include it (or write your own) if needed on the front-end. From <code> download_url() </code> you can use: <code> $response = wp_remote_get( TCS_CPDF_REMOTE_ZIP, array( 'timeout' => 300, 'stream' => true, 'filename' => T... | How to use WordPress HTTP API to download file from remote location | wordpress |
I'm just starting to wrap my head around custom post types and for some reason can't get any of the custom post types to display in the loop. I've found some queries online but none of them are in closed php statements and I'm not sure how to integrate them. Here's what I have: <code> // add custom post type add_action... | After much searching and edumication on custom post types I figured it out. I've also added things to make the specifications more granular. <code> // Add custom post type Artists function register_artists_post_type() { register_post_type('artists',array( 'labels' => array( 'name' => __( 'Artists' ), 'singular_na... | Listing custom post types on archive page with array | wordpress |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.