question
stringlengths
0
34.8k
answer
stringlengths
0
28.3k
title
stringlengths
7
150
forum_tag
stringclasses
12 values
I'm not trying to navigate to the next post within a category, but to put previous category and next category under the category description on its archive page and navigate between archive pages. I've searched, but I'm not sure this is even possible without hardcoding categories, and I don't want to do that. I'd like ...
Not sure if this is what you want, gets all the categories and outputs a link to the next and previous in the order returned from <code> get_categories() </code> : <code> $this_category = get_queried_object(); $categories = get_categories(); foreach( $categories as $position =&gt; $cat ) : if( $this_category-&gt;term_i...
Is it possible to put next and previous category links?
wordpress
My parent theme (Starkers) adds a CSS file that I'm trying to remove (I want to use @import instead so I can override styles more easily). Starkers has the following in its functions.php: <code> add_action( 'wp_enqueue_scripts', 'script_enqueuer' ); function script_enqueuer() { wp_register_script( 'site', get_template_...
I want to use @import instead so I can override styles more easily Simply. Don't. Do. That. You simply jump into the same hook and then deregister/dequeue the styles/scripts and throw in your custom ones. <code> function PREFIX_remove_scripts() { wp_dequeue_style( 'screen' ); wp_deregister_style( 'screen' ); wp_dequeue...
How do I dequeue a parent theme css file?
wordpress
I'm not sure if this question belongs in the CSS forum or the WordPress forum... At this link to my wordpress site: http://richardclunan.com/ in the sidebar, there's a title for a widget "GET FREE CHAPTERS PLUS MORE HELPFUL COPYWRITING IDEAS" - I'd like to change the font of widget titles, so it's not all-caps. So it's...
It definitely belongs to CSS forum, but any way: Open: your style.css located in wp-content/themes/twentyeleven-child/ Go to: line 1736 where it says .widget-title Remove: <code> text-transform: uppercase; </code>
How to change font in title of sidebar widget
wordpress
When working with a worpress site with lots of custom post types and lots of page templates, my theme folder is looking messy. What are the accepted best practices to organise code files in WordPress? a couple of the limitations i'm coming up against are that templates are chosen by name, so i can't group files by pref...
Not a full answer, but I can at least answer this question: Also custom post template files can not be in sub directories. Everything, that you can load via <code> get_template_part() </code> , can reside in a subfolder: <code> get_template_part( 'subdir/part', 'suffix' ); </code> It's as easy as that. Now you've your ...
How do i structure my theme folder to avoid one huge list of files
wordpress
I'm trying to read the custom fields set by the user when publishing a new post: <code> function doSomething($post) { $meta = get_post_meta($post-&gt;ID); error_log("post meta: ".print_r($meta, true)); } add_action("new_to_publish", "doSomething", 999); add_action("draft_to_publish", "doSomething", 999); add_action("pe...
That's because the fields weren't set then. Note: The »Autosave« process/request also doesn't save them. Use the values from <code> $_POST </code> instead for your <code> "new_to_publish" </code> action.
Using get_post_meta with new_to_publish
wordpress
I am using ajax on my template to load a file called counter.php. When I click a button, it is supposed to increase the counter. But when I click the button I get this error "Fatal error: Call to undefined function get_option()". This is what I have on counter.php <code> $post_ID = $_POST['ID']; $opn_name = 'fb_counter...
Basically, if you're going to be making calls to WordPress functions, then you should be in the WordPress environment, which means that you should not be calling your own files to begin with, but should implement your AJAX call within a WordPress hook. Read up on this: http://codex.wordpress.org/AJAX_in_Plugins That ar...
using Ajax: call to undefined function get_option
wordpress
In a custom post type, is there a way to include the "order" field that is available for pages? Is there any built-in logic that prevents duplicate values in the "order" field? The idea is to be able to sort a custom post type by a user-specified order, then alphabetically by a string-based custom field.
When declaring your custom post type using the register_post_type function, you have to add 'page-attributes' to the support field, like in the following example: <code> register_post_type('myposttype', array('supports' =&gt; array('title', 'editor', 'page-attributes'))); </code> You'll need to add any other supported ...
Custom post type - order field
wordpress
I'm using a "static" front page with the posts on a page called News. Is it possible to make the categories use that as the base? Like this: /news/[category_name]/ And is it also possible to do the same with posts? /news/2012/09/17/post-title
Yes update permalink to something like this
Category page when using static front page
wordpress
I guess I need to know how to call meta data into metaboxes for beginners. I'm using <code> $posts = get_posts(array( 'post_type' =&gt; 'slidertype', 'post_status' =&gt; 'publish', 'posts_per_page' =&gt; -1, 'fields' =&gt; 'ids' ) ); //loop over each post foreach($posts as $p){ //get the meta you need form each post $t...
You can get the image from your $thumb integer with the following additional code: <code> $thumb = get_post_meta($p,"_thumbnail_id",true); $image = wp_get_attachment_image_src($thumb); echo $image[0]; </code> This will return the URL of the image, just put that in an img tag to display it.
Getting thumbnails of a custom posts featured images in a page-templates metabox
wordpress
I am created a theme with custom posts which outputs to a Google Map with place markers. Users will create a custom post users and include street addresses which will be geocoded using Google's Map API v3 and a marker is placed on a Google Map. I am relatively new to coding and designing custom Wordpress themes, so I a...
Well, this is kind of easy.. The google-map API needs a format like <code> Your Street 123, 54321 Your City </code> Assuming you have your data like this: <code> &lt;div id="street"&gt;Your Street 123&lt;/div&gt; &lt;div id="zip"&gt;54321&lt;/div&gt; &lt;div id="city"&gt;Your City&lt;/div&gt; </code> Assuming you are u...
Extracting Address from Custom Post via Javascript for Google Maps API
wordpress
I want to extend both body classes for the front-end as well as for the admin area. I have seen some snippets floating around, which led me to the following <code> add_filter('body_class','add_custom_body_classes'); add_filter('admin_body_class', 'add_custom_body_classes'); </code> Now it seems to me, that I do have to...
Your snippet adds the following classes to the body tag on the front end, <code> someText someText </code> Your snippet adds the following classes to the body tag on the back end, <code> someClassA someClassB </code> If that is you intended result, then yes that works and is correct. You could also do, <code> function ...
Extending body classes in front- and backend
wordpress
With regards the menu item id's WP generates such as <code> menu-item-814 </code> , are these 100% unique in nature? I know they are unique at the time, but are they always unique? Meaning that if I was to delete something that had the id of 814, is it possible that some other menu item could now be assigned this ID? ....
Yes it is always unique. id 814 cant be applied again unless you update it manually on your DB. Its because of auto increment .. DB automatically increment id so everytime next id will be +1 814 815 816 and so on.. Even if you delete an id in between. It wont affect auto incrementation. Read MY SQL AUTO_INCREMENT for d...
Menu items id's - are they 100% unique?
wordpress
I have a custom post type called "portfolio" with 2 registered taxonomies : portfolio_category and portfolio_tag . I'm using a custom theme that use a lot of javascript/jquery. So this is how the categories taxonomy is defined in template-portfolio.php (it's just some relevant code used to define categories taxonomy) :...
If you're trying to create a output template, then yes essentially just replace the word cat or category everywhere in that code with the word tag. Something is still missing from this question though because template_portfolio.php isn't a standard template name and it's not clear how it's being called by your custom t...
get tags from custom post type
wordpress
I am getting started with plugin development. I wrote the following program to display text on screen but nothing happened. Please help. Thanks. <code> &lt;?php /* Plugin Name: Fahad Plugin URI: Description: Declares a plugin that will be visible in the WordPress admin interface Version: 1.0 Author: Yannick Lefebvre Au...
A subtle difference between your syntax <code> wp-footer </code> should be <code> wp_footer </code> , underscore <code> _ </code> and not hypthen <code> - </code> <code> add_filter('wp-footer', fahad); // wrong... add_filter('wp_footer', 'fahad'); // right.. </code> Follow the naming convention of functions: (Codex) Pl...
Echo simple string in Plugin
wordpress
Is it possible to have a must-use directory within the multisite system that is specific to each individual site?
Define the constants <code> WPMU_PLUGIN_DIR </code> and <code> WPMU_PLUGIN_URL </code> depending on the host or path in you <code> wp-config.php </code> .
Multisite mu-plugins site-specific directory
wordpress
After I imported content from another wordpress site using the WXR export/import tools, my admins can't edit each other's posts. This is really aggravating because I can't figure out how to change this. And it doesn't just related to imported content. I can create two brand new admins, each one creates an entry, but ne...
Ok, I got it figured out. For some reason, current_user_can was returning false when an admin went to edit other user's posts... I have no idea how admins lost the ability to do this, but putting this into functions.php is a workable bandaid that restores admin edit capabilities; <code> $administrator = get_role('admin...
Admins can't edit each other's posts
wordpress
Is it possible to run an array to not show the first 6 posts, but then to show posts labeled 7-15 say? So that way I can display the first 6 posts elsewhere and then the rest somewhere else? More Information: I have a site here: http://universitycompare.com/student-info and I would like the site to display the first 6 ...
You don't need to make them separate queries. Query for all 12 posts, when you output them in the first section only output them if <code> $wp_query-&gt;current_post &lt; 6 </code> , then <code> rewind_posts() </code> and run the loop again, only outputting them in the second section if <code> $wp_query-&gt;current_pos...
Missing the first 6 Posts and displaying posts that are after the latest 6
wordpress
I bought a theme from Themeforest and now I would like to convert it to a custom made theme. I was creating the theme with the Underscores theme: http://underscores.me/ but how do I keep the same custom post types in the next theme? Is this less time consuming than recoding the purchased theme?
Move the custom post types to a plugin. They should never be part of a theme for exactly the reason you asked here. :) In your theme add just the needed template files, but not the code for post type registration.
Purchased Theme to Custom Made Theme?
wordpress
I am making a custom wordpress theme and when I add a comment to a post and retrieve the number of comments using <code> get_comments_number() </code> the number does not change. I do know the function works because for the first comment that gets preinstalled with wordpress it returns 1. but somehow the number does no...
Approving them in the admin console solved my problem.
Comment number does not increment
wordpress
How do I create pretty permalinks for a query page that includes results from both categories and tags. For instance, if the category is Country (America) and the tag name is city (New York), can I have a permalink like wordpressblog.com/america/new-york for a page that shows all posts belonging to Amercia category and...
You could do it manually in your .htaccess although I'm not sure how. In the past I have been able to use partially pretty urls by doing <code> http://www.mydomain.com/country/america/?city=new_york </code> I would imagine it would easy enough to use mod_rewrite to prettify that even further. UPDATE: Check this out it ...
Pretty URLs with Categories and Tags
wordpress
Curently if we use the insert link dialog to insert a link to another post, WordPress always use the permalink of that post. The problem is when we change permalink structure, that link will be broken. I'd like to ask if there is a way to change the link from permalink to shortlink like <code> ?p=123 </code> to make it...
The links in that dialog are made by <code> wp_ajax_wp_link_ajax() </code> (see <code> wp-admin/includes/ajax-actions.php </code> , there is no page on Codex or queryposts.com for that function). To change the links filter <code> 'page_link' </code> , <code> 'post_type_link' </code> , <code> 'post_link' </code> and may...
Change link to other post to shortlink in the editor
wordpress
I want to allow users to upload custom files to specific plugin directory. The problem is, obviously, that WP removes everything upon plugin version update. I think that the <code> upgrader_pre_install </code> and <code> upgrader_post_install </code> hooks may be useful, but unfortunately so far I wasn't able to find a...
To answer my own question here is what I've found for the sake of keeping questions answered. What this does is copying the important directory before upgrade and recovering it after upgrade: <code> function my_dir_copy($source, $dest) { if (is_link($source)) { return symlink(readlink($source), $dest); } if (is_file($s...
Prevent plugin from deleting important directories
wordpress
I am trying to exclude categories from my blog page. I have the code all set up and according to the codex, this should work <code> $string = '-' . implode( ',-', explode( ' ', $data['exclude_categories'] ) ); </code> The above line will print this to the screen upon testing -homepage,-recent-news Those are the two tes...
<code> cat </code> accepts category IDs, not slugs or names. a better method here is to use the <code> pre_get_posts </code> action, the Codex page has an example that does exactly what you're trying to do.
trouble with my loop
wordpress
I have made a class file in my plugin folder. Then I wrote, <code> class Sample{ function footer_content(){ echo "show any data"; } } </code> Then I added the function footer_content to wordpress footer by using add_action command. But it didn't show anything. maybe I am missing something in this, as it is not working....
Here's reference from Codex To use the add_action hook when your plugin or theme is built up using classes, add $this to your add_action call together with the function name within that class, like so: <code> class MyPluginClass { public function __construct() { //add your actions to the constructor! add_action( 'save_...
How to call bind function in wordpress actions or hooks
wordpress
<code> small </code> size thumbs are shown on the homepage which is fine, but I'd like to show large thumbs on <code> single-page </code> . This is a function in my <code> functions.php </code> : <code> function fix_my_gallery($output, $attr) { global $post; static $instance = 0; $instance++; /** * will remove this sin...
You can change variable <code> $size </code> value depending on what page is viewed. <code> $size = is_single() ? 'large' : 'thumbnail'; </code> Code above will set <code> $size </code> to large, if is_single is true, else it would be thumbnail (or small as you said). Place it somewhere below shortcode attribute extrac...
Different size thumbnails on home and single pages
wordpress
I've got a problem. I don't want duplicate posts. Any way to check if a post already exists and if it does just set the new one to draft? I am using IFTTT to update my blog and sometimes it posts multiple times.
I have no idea what IFTTT is but you can use the <code> save_post </code> action hook to do a check for duplicate posts. This hook runs whenever a post is created or updated you would then be able to right your own code to check against existing posts. http://codex.wordpress.org/Plugin_API/Action_Reference/save_post
Don't post or draft if post already exists
wordpress
I want to make a force redirect for single.php to index so that it is never reachable by direct access (the site is built in a way that you retrieve all the content on the index page, still need to have this page available though because of an ajax function). I assume this is done in .htaccess? Edit: I need to be able ...
put this code in functions.php file <code> add_action('wp', 'myfun'); function myfun(){ if(is_single()){ wp_redirect( home_url() ); exit; } } </code> hope this trick solve your problem. all the best ;)
Force redirect single.php to index
wordpress
I currently have a store running on Bigcommerce, but unfortunately it doesn't offer the functionality that I require. I am debating whether to use a magento/wordpress install or wordpress/woocommerce. Does anybody out there know if it is possible with woocommerce (or additional plugins) to perform the following: Set an...
Just to help you out ... Wordpress and Magento are comparable as they are both PHP content management systems. However Magento doesn't compare to WooCommerce in the way you mention it above. For example: you may not need WordPress if you installed Magento. But you have to install WordPress to use WooCommerce. What you ...
Is it possible to set individual shipping prices in Woocommerce?
wordpress
I am trying to find a solution to a problem that Wordpress seems to lack. Here is a scenario: I have uploaded images to a post using the native gallery to display the images. These images then appear under the gallery tab within the upload/insert and they will appear on the post. Works perfectly. Further down the line ...
Attachments are a type of post, and a post can only have a single parent, that's why it's not natively possible to have an attachment associated with multiple posts- there is no mechanism for many-to-many associations. There are several ways to solve this, but how simple it is depends on your skill level or willingness...
Inserting images in multiple posts native gallery
wordpress
I'm trying to fetch a (date) meta field from a custom post type in a sidebar widget here: http://www.oransje.com/utvikling/ngnf/kurs/ Somehow the date doesn't show correctly inside the widget (everywhere else I put it, also manually in the sidebar the code works fine). Anyone a clue? The code looks like this: <code> &l...
I fixed this by adding: <code> global $post; </code> More specific: I can't explain why this works, that's beyond my WordPress skills, but I added it right after the start of the query, so the code looks like this: <code> &lt;?php global $post; $loop = new WP_Query( array( 'post_type' =&gt; 'kurs', 'posts_per_page' =&g...
fetch meta fields inside a widget
wordpress
I am currently using add_submenu_page to add pages for my plugin. However, I wish to create a page that don't appear in the admin menu, is that possible?
Set the <code> parent_slug </code> property to <code> null </code> , example; <code> add_submenu_page( null // -&gt; Set to null - will hide menu link , 'Page Title' // -&gt; Page Title , 'Menu Title' // -&gt; Title that would otherwise appear in the menu , 'administrator' // -&gt; Capability level , 'menu_handle' // -...
Plugin - create a page without it appearing in the side menu
wordpress
I've been looking for function about post views count. I found this simple functions using update and get post meta. <code> function setPostViews($postID) { $count_key = 'views'; $count = get_post_meta($postID, $count_key, true); if($count==''){ $count = 0; delete_post_meta($postID, $count_key); add_post_meta($postID, ...
A very basic solution would be to use the Transients API, an example... <code> function setPostViews($postID) { $user_ip = $_SERVER['REMOTE_ADDR']; //retrieve the current IP address of the visitor $key = $user_ip . 'x' . $postID; //combine post ID &amp; IP to form unique key $value = array($user_ip, $postID); // store ...
Views count with time limit per IP
wordpress
I can't quite seem to figure out how it works. By default i have a sidebar in sidebar.php that i load using <code> get_sidebar(); </code> . That works great (no need to register it), but i have a custom page template for another page where i want to load another sidebar. I know i can use include('filename') to load it ...
http://codex.wordpress.org/Function_Reference/get_sidebar <code> &lt;?php get_sidebar('other'); ?&gt; </code> for instance will call the template sidebar-other.php you would add the <code> dynamic_sidebar() </code> code in that sidebar-other.php template; see also http://codex.wordpress.org/Widgetizing_Themes
Register/Get sidebar?
wordpress
Whenever a user posts a comment, I'd like to basically have a copy of the post sent to another database for a separate site. The database part is simple, but I can't seem to find the right action hook for this. (I did my testing with a simple echo statement, a failure being it not displaying at all) 'comment_save_pre' ...
You can use <code> wp_insert_comment </code> action, which is triggered on every comment insertion.
Custom action on comment post
wordpress
I use the Editor Quicktag Buttons to store special things like this example below is used to store the DIV's to make Columns on my theme. I need help, I want to modify the snippet below so that it will insert the HTML onto multiple lines, so instead of adding <code> &lt;div class="one-half first"&gt;1st&lt;/div&gt;n/&l...
This is the format you need to follow, <code> //double quotes require escaping var your_html = "&lt;div class=\"one-half first\"&gt;1st&lt;/div&gt;\n&lt;div class=\"one-half\"&gt;2nd&lt;/div&gt;\n&lt;div class=\"clear-line\"&gt;&lt;/div&gt;"; //single quotes do not require escpaing var your_html = '&lt;div class="one-h...
Quicktag insert multiple lines
wordpress
I have a custom meta box with two different radio buttons that can be selected. One is for displaying the content in a "large' format, the other is for displaying content in a "small" format on the front end. I already know how to retrieve a meta box's data and output it, but not how to "check" what specific data has b...
Is this what you need? <code> $size = get_post_meta( $post-&gt;ID,'meta_box_musicreleases_featrelease',true ); if ($size == "display_lrg_release") { //do your large thing here } elseif ($size == "display_sm_release") { //do your small thing here } else { //do something when no radio is checked } </code> ...I think so.
How to check for specific meta box value on front end and output accordingly
wordpress
I am trying to redirect all non-www to www URLs in my WordPress MultiSite install. I am using a simple <code> .htaccess </code> rule like this: <code> # Redirect non-www to www: RewriteCond %{HTTP_HOST} !^www\. [NC] RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L] </code> Normally this would work, however WordPr...
Answer: Don't disable it, use it to do the redirection you want. If you have a subdomain install, then you cannot do this at all, the www is a subdomain. If you have a sub-directory install and want all the sites to be www, then edit your wp-config.php and change the DOMAIN_CURRENT_SITE to be your www domain. If you ar...
How to disable the default WordPress redirect to non-www URLs?
wordpress
What is the best way to add/remove items for the <code> wp_nav_menu() </code> based on user roles? For instance a custom menu that looks like: Some Page Some Other Page Special Admin Page Where the <code> Special Admin Page </code> should only be visible for admin users. Is this best done with <code> wp_nav_menu_items ...
Create a stackexchange-url ("custom walker"). Redefine the method <code> start_el() </code> only: <code> function start_el( &amp;$output, $item, $depth, $args ) { if ( 'Your secret item title' !== $item-&gt;title or current_user_can( 'administrator' ) ) { parent::start_el( &amp;$output, $item, $depth, $args ); } } </co...
Hide Menu items base on capability
wordpress
I haven't ever seen a tag such as <code> do_action('something_10') </code> . Is it invalid if I use numbers? If the method is valid, how can I write different numbers in the tag string conditionally? For example, is the following code correct($grade is the number)? <code> do_action("new_grade_$grade") </code>
When you "hook"/ <code> add_action/*_filter('whatever'); </code> a callback function to <code> do_action('whatever'); </code> , then you basically add the function (or object-method) name to the <code> global $wp_filters </code> -array. Doing so, you add the function/method name to an array that is built like the follo...
Valid characters for actions, hooks and filters
wordpress
I currently have this query_posts that i have done, (I am new to PHP!) And would like to know how I would go about limiting it to latest 4 posts and 4 posts only.. <code> &lt;?php query_posts('post_type=page&amp;post_parent=2&amp;posts_per_page=-1&amp;orderby=title&amp;order=ASC'); ?&gt; &lt;?php if ( have_posts() ) wh...
You have posts_per_page = -1, which means show unlimited posts. Change the -1 to the number of posts you want to appear. Also you have output that skips if your "next_open_day" meta value is null, but the query will only run 3 times, so you need to move that logic into the query itself by using these arguments in the q...
Limiting the amount of posts this displays
wordpress
I am trying to set thumbnails for my post. I have <code> post_id = 285 </code> and I want to add manually a thumbnail (using code) but I'm not succeeding. <code> update_post_meta( $post-&gt;ID, '_thumbnail_id', $attachment_id ); </code> I got this function reference but I do not understand what is the <code> $attachmen...
First you'll need to upload the image, stackexchange-url ("like this"). This will upload the image and add a row to <code> wp_posts </code> where your attachment is. How dynamic do you need this to be? Can you upload the image with the user interface or does that have to be done programatically as well? In your case, t...
How can i add thumbnails images to particular post (using code not admin pannel) in wordpress
wordpress
Is there a way to force users to write a page title before publishing? I have found example of requiring post titles, but not page titles.
Start with downloading the plugin called Force Post Title . Here's the plugin with one row (2 with the comment line) added to the bottom, based on our comments. What happens is that a small jQuery script is added to the page Create Post/Page . The script will check if the title field is empty when the user clicks the s...
Require title for pages
wordpress
I'm trying to add a column to plugin table screen using "manage_plugins_custom_column", but without success. This extra column will show a custom value that was placed inside the plugin file. I hope someone could help! Thanks! Daniel ---------------- edit ---------------- This is the working code that creates the colum...
First, you have to add the custom column to the plugin column names: <code> function wpa65189_add_plugins_column( $columns ) { $columns['wpa65189_column'] = 'wpa65189 Custom Column'; return $columns; } add_filter( 'manage_plugins_columns', 'wpa65189_add_plugins_column' ); </code> Then output your column data for your p...
Add column to plugins table screen
wordpress
I'm trying to create a home page, in which there is a top posts section that displays the three most recent posts (for all categories), and category subsections that display the most recent posts for that category only. I know how to get that far, but I'm not sure how to make sure there isn't any overlap (I don't want ...
Well, you're going to have a lot of loops and a lot of custom <code> WP_Query </code> objects. To start, create an <code> $all_posts </code> variable before you start the main loop on your home page. You should likely put all this in your <code> front-page.php </code> template. <code> &lt;?php $all_posts = array(); whi...
Get most recent posts by category that aren't first overall
wordpress
How can I exclude one specific post from a WP_Query query? (For example, show all posts apart from a post with the ID 278) I've tried the post__not_in argument but it just removes all posts.. Any help would be great. Here is my current query <code> &lt;?php $temp = $wp_query; $wp_query= null; $wp_query = new WP_Query(a...
I just tested the below code, and it works: <code> &lt;?php $q1 = new WP_query(array('category_name' =&gt; 'test-cat-1', 'order' =&gt; 'ASC')); if($q1-&gt;have_posts()) : $firstPosts = array(); while($q1-&gt;have_posts()) : $q1-&gt;the_post(); $firstPosts[] = $post-&gt;ID; ?&gt; &lt;div class="item"&gt; &lt;h2&gt;&lt;?...
Exclude post ID from wp_query
wordpress
When looking at header.php, I see the following line: <code> &lt;?php wp_nav_menu( array( 'theme_location' =&gt; 'primary' ) ); ?&gt; </code> That function is defined in nav-menu-template.php and generates the 'menu-custom-menu-container' div. Let's I want to add a div after the navigation list inside the 'menu-custom-...
<code> wp_nav_menu( array( 'theme_location' =&gt; 'primary' ,'items_wrap' =&gt; '&lt;ul id="%1$s"&gt;%3$s&lt;/ul&gt;&lt;div&gt;&lt;p&gt;content&lt;/p&gt;&lt;/div&gt;' ) ); </code> stackexchange-url ("See @toscho's detailed explanation") of the items_wrap parameter for more information.
Where do I add html code to the menu div?
wordpress
<code> http://69.89.31.200/~horologi/shop/ </code> I'm working on the site above and the client has requested that on the shop page, all the product information is displayed on that page, including all product thumbnails. I have copied the WooCommerce template files into my theme directory so I can modify them, and hav...
The second parameter on get_the_post_thumbnail takes the size of the image you want. You're currently passing in: <code> apply_filters( 'single_product_large_thumbnail_size', 'shop_single' ) </code> but change that to <code> apply_filters( 'single_product_small_thumbnail_size', 'shop_thumbnail' ) </code> And you'll hav...
WooCommerce Product Page Loop - Output All Product Thumbnails
wordpress
I have a multsite installation with canonical setup like <code> site1.domain.com </code> and <code> site2.domain.com </code> etc. How do I change the default root site from site <code> 1 </code> to site <code> 2 </code> ? I tried to change these two values in <code> wp-config </code> to <code> 5 </code> instead of <cod...
Current site Id defines the primary network id. You can have more than one network if you use a multi-network plugin . Current blog id defines the primary blog within the primary network. To change the main blog to '2' (if you only have one network) you want your defines like this: <code> define( 'SITE_ID_CURRENT_SITE'...
Change wordpress Multisite default site from side id 1 to side id 2
wordpress
Imagine i have a URL structure like this: www.domain.com/category/subcategory/ This is my code: <code> &lt;?php $args=array( 'child_of' =&gt; $cat-id, 'hide_empty' =&gt; 0, 'orderby' =&gt; 'name', 'order' =&gt; 'ASC' ); $categories=get_categories($args); foreach($categories as $category) { echo '&lt;a href="' . get_cat...
Ok, try this. It should capture the current category object and then go up the chain until it finds the current categories top-most ancestor. <code> // get the category object for the current category $thisCat = get_category( get_query_var( 'cat' ) ); // if not top-level, track it up the chain to find its ancestor whil...
Show children of top level category only
wordpress
I need to search for posts that belong to multiple categories, but they must match all categories listed, as in if I list category names 'japanese' and 'dessert' the matching posts need to be in both the 'japanese' and 'dessert categories. Is there something like <code> category__and </code> for category names? I am us...
Well... you could grab category names ID using <code> get_the_category </code> function( Wordpress Codex ). <code> $names = {"japanese", "dessert"}; $categories = get_the_category(); if($categories){ foreach($categories as $category){ if( in_array($category-&gt;cat_name, $names) ) array_push($ids, $category-&gt;term_id...
Select posts that match multiple category names, must match all categories listed
wordpress
In my theme, I'd like to display the publish date and (only) if the post was updated after the publish date, also display the updated date. The code in my theme now looks like this: <code> */ stuff above here to display publish date, then do this stuff to see if updated */ if ( get_the_date() != get_the_modified_date()...
get_the_date() and get_modified_date() don't return time values: so, if you change your conditional statement to the below, it should work: <code> if ( get_the_modified_date() &gt; get_the_date() ) { ... } </code> Now if the updated date is greater than the original publish date(by one day), the if statement is true.
How can I compare publish and update dates for a single post?
wordpress
I am trying to check for a php variable in each of my template in order to assign it a different styling but the value seems to disappear, can you please help, I already spent hours trying to figure this out. I know there is something small I'm missing. So here is everything: I have a page a which links to b and pass a...
I think you could simplify much of what you are doing just by using the global <code> $_SESSION </code> variable. try something like this: <code> add_action('wp_head', 'your_session_variable' ); function your_session_variable(){ session_start(); $gender = isset($_GET['gender']) ? $_GET['gender'] : $_SESSION['gender']; ...
Change global values from templates
wordpress
There are lots of situations where a theme or plugin registers a post type and you want to modify it. There is of course <code> add_post_type_support() </code> and <code> remove_post_type_support() </code> , but those don't give access to the full list of arguments that <code> register_post_type() </code> takes. In par...
Is this function really for modifying post types Yes. and if so, can you simply redeclare a couple arguments and leave the rest alone? No. If you want to modify arguments to a post type, you need to use <code> get_post_type_object </code> to get the post type object, modify what you want in it, then re-register it usin...
Use register_post_type() to modify an existing post type
wordpress
I'm working on a site where we're introducing drop down panels from the menu which will display thumbnails from various tags on the site. Each panel has a left column displaying a featured post, and a right column displaying 6 thumbnails; on each tab then I'm doing two wp_query loops, the first to display the featured ...
Rather than querying for a single item and then querying again for 6 more excluding the first, you can just do a single query for 7 items and selectively output markup by checking which post you're currently outputting in the loop via <code> $your_query_object-&gt;current_post </code> . You can also combine that with <...
reducing the amount of wp_query calls
wordpress
I'm working on a plugin that changes the password requirements to be a bit stricter, however wherever there is a password field to create a password, WordPress' hints are now no longer accurate (e.g. Password must consists of seven characters). How can I replace those hints? Is there a filter/function that can help wit...
You can filter <code> 'gettext' </code> . Sample code, not tested: <code> add_filter( 'gettext', 'wpse_65085_change_error_messages', 10, 3 ); function wpse_65085_change_error_messages( $translated, $text, domain ) { if ( 'default' !== $domain ) { return $translated; } switch( $text ) { case 'Hint: The password should b...
Overwrite default WordPress wording
wordpress
I am use eCommerce plugins for the eCommerce support in wordpress I am export my all product using <code> Tools-&gt;export </code> from my <code> http://localhost/first </code> wordpress site and i am try to import in my wordpress another site like <code> http://localhost/second </code> and it is not give any error but...
When you're exporting from a localhost installation, the other installation cannot import images because it technically needs to be 'online' for the new installation to download the images off the older one. The easiest thing to do would be to migrate the old site to an online installation. You can read about how to mo...
product export and import using xml
wordpress
I use the following code in functions.php in order to obtain all the images attached to a post so I can retrieve them via AJAX. <code> &lt;?php function get_all_images($post_id=0, $size='bigger', $attributes='') { $post_id = $_POST['post_id']; if ($post_id&lt;1) $postid = get_the_ID(); if ($images = get_children(array(...
You want to add the title to the response, not replace the response with the title. Like this: <code> &lt;?php function get_all_images($post_id=0, $size='bigger', $attributes='') { $post_id = $_POST['post_id']; if ($post_id&lt;1) $postid = get_the_ID(); if ($images = get_children(array( 'post_parent' =&gt; $post_id, 'p...
Syntax for a function in order to get post's title in JSON encoded response
wordpress
I copied my WP content to a new install on a different server, so now my uploaded PDF documents have the old URL. Is there a simple way to fix that in all my posts at once, perhaps with SQL or some plugin ?
Use the script found here: http://interconnectit.com/124/search-and-replace-for-wordpress-databases/ Because WordPress serializes some urls in option and meta tables a simple replace won't do. A siple replace will break your data. This script will preserve your data and replace it with a new url. I use it al least twic...
Updating URLs in many posts
wordpress
I'm running wordpress on my own host and would like to install the Ideation and Intent theme. I couldn't, however, find a place to download it from, nor can I search for it on my Wordpress dashboard under Appearance -> Themes. The best I could find was this svn url: https://wpcom-themes.svn.automattic.com/ideation-and-...
To get a theme or plugin for which you have just the SVN URL you need three steps: Install a SVN client. For Windows you might take TortoiseSVN . Create an empty directory where you need the code. Right click in that directory and use the Checkout command to download the code. After you have clicked OK all the files ar...
How to get themes from wordpress.com per SVN?
wordpress
When new passwords are generated for new users, some users are reporting that the passwords include spaces at the beginning and end of the passwords. Has anyone ran into this before or have any idea why this would be happening? What are the potential problems with this, and how can they be avoided?
If <code> wp_generate_password() </code> was called with the third parameter <code> $extra_special_chars = true </code> a space might be part of the password: <code> function wp_generate_password( $length = 12, $special_chars = true, $extra_special_chars = false ) { $chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQ...
Why do generated passwords start/end with spaces?
wordpress
This is kind of a weird one. I'm in the process of building a widget that goes through posts of type <code> product </code> and displays a list of checkboxes in the admin panel to display/show the products in the widgets. Everything seems to be working fine, except the <code> checked() </code> function is not only addi...
By default, <code> checked </code> echoes. If you set the (currently empty) third parameter to <code> false </code> , it should work as expected. Change the line to: <code> $$sku = isset( $instance[$sku] ) ? checked( (bool) $instance[$sku], true, false ) : false; </code> More info: http://codex.wordpress.org/Function_R...
Issue with checked() echoing on to page
wordpress
WP recently_edited option can be very useful - it tracks last 5 files that you've made changes to. Only problem is - well, that's all, 5 files. What if I've been made numerous changes to Wordpress theme files by using default WP admin editor? It would be helpfull if I had list of, say last 20 files edited and time when...
The function is <code> update_recently_edited </code> in <code> wp-admin/includes/misc.php </code> . unfortunately it is fixed at 5: <code> function update_recently_edited( $file ) { $oldfiles = (array) get_option( 'recently_edited' ); if ( $oldfiles ) { $oldfiles = array_reverse( $oldfiles ); $oldfiles[] = $file; $old...
How to change option recently_edited?
wordpress
I am working on a plugin that requires on-the-fly manipulation of content output. This is solely dependent on the current <code> $_GET </code> variable or <code> $_REQUEST </code> variable. Depending on what the variable is set to, it will call a certain class method to handle the user's request and display the proper ...
WordPress doesn't provide any specific data validation functions for SUPERGLOBALS. I use the PHP filter_input function then escape it as I would any untrusted variable. <code> $url = filter_input( INPUT_GET, 'some_query_string', FILTER_VALIDATE_URL ); echo '&lt;a href="'. esc_url( $url ). '"&gt;Click Me&lt;/a&gt;'; </c...
How to properly validate data from $_GET or $_REQUEST using WordPress functions?
wordpress
When I use the settings API in a multisite installation and the options page sits at the network level, posting the options to <code> options.php </code> does not work, because the administration page sits at <code> wp-admin/network </code> and WP expects the page to be at <code> wp-admin </code> . I added a function t...
For network option pages the correct form action URL is: <code> wp-admin/network/edit.php?action=your_option_name </code> Then you have to register a callback: <code> add_action( 'network_admin_edit_your_option_name', 'your_save_network_options_function' ); </code> In that callback function inspect the <code> $_POST </...
Settings API in Multisite - Missing update message
wordpress
I have following code: <code> $posts = get_posts(array( "meta_key" =&gt; "special", "meta_value" =&gt; "surprise", // "has_post_thumbnail" =&gt; true, // how to do that? )); </code> What should I do to select posts having post thumbnails ?
The thumbnail is stored as a meta with a key of <code> _thumbnail_id </code> , so that could be used to find posts that have thumbnails. Something like this: <code> $query = new WP_Query(array( 'meta_query' =&gt; array( array( 'key' =&gt; '_thumbnail_id', 'value' =&gt; '0', 'compare' =&gt; '&gt;=', ) ) )); </code>
How to get_posts having post thumbnail?
wordpress
The question says it all, I think. I'd like to create a new submenu page using edit.php which will only display pages which use a certain template file (or files). Possible?
Try this: <code> &lt;?php // add submenu page add_action('admin_menu', 'add_template_submenu'); function add_template_submenu() { add_pages_page( 'My Template', 'My Template', 'edit_pages', 'edit.php?post_type=page&amp;template=your-template-file.php'); } // check for the template name passed in $_GET and add it to the...
Customize edit.php Pages listing in dashboard to show only pages with a particular template applied?
wordpress
I'm trying to allow a user to have multiple email addresses associated with their account. <code> update_user_meta() </code> will not work because it will overwrite the current email. <code> add_user_meta() </code> wouldn't work either because it would duplicate the entry, even if it is the same email address.. Any ide...
You can use <code> update_user_meta() </code> and <code> add_user_meta() </code> , just store all the email addresses in an array in a new field. If you have a requirement, such as preventing duplicates, run a validation function that checks for that before updating the database.
Multiple Email Addresses, One User
wordpress
I've customized my comment form with a new field (city, but that doesn't really matter). I've hooked and filtered and added my comment metadata with add_comment_metadata. I want to show that metadata in the Comments admin panel (wp-admin/edit-comments.php). Google searches prove fruitless. Is this possible? If it is, h...
To show the content on individual edit pages you need to add custom meta boxes to the comment edit page. You'll use the key <code> comment </code> for the <code> $page </code> argument of <code> add_meta_box </code> . <code> &lt;?php add_action( 'add_meta_boxes_comment', 'pmg_comment_tut_add_meta_box' ); function pmg_c...
Is it possible to show custom comment metadata in the admin panel?
wordpress
This one has me stumped I'm sure it is something really small that I am overlooking but I think I've been looking at it too long to see what the problem is. Wordpress is telling me: "Upload folder is not writable. Export and file upload features will not be functional." Well...specifically it is Gravity Forms that is p...
That's a server permission problem. According to the WP docs: Any file that needs write access from WordPress should be owned or group-owned by the user account used by the WordPress (which may be different than the server account). For example, you may have a user account that lets you FTP files back and forth to your...
Wordpress Uploads Folder can't be Written to
wordpress
Can anyone lend a hand and suggest the best way to get a textarea in a meta box to stop mangling HTML? I've been digging around here online ... stackexchange-url ("and here")...stackexchange-url ("and also here")...looking for answers, but I don't know how to piece them together properly to fit with what I've already d...
I'v re-worked your code. I'll try to explain some of the changes after the code block <code> add_action("admin_menu", "tf_book_deets_create"); function tf_book_deets_create(){ add_meta_box('tf_book_details', 'Book Details', 'tf_book_details', 'books'); } function tf_book_details () { global $post; $tf_book_media = get_...
How to stop wordpress from mangling HTML in a metabox textarea
wordpress
I am getting an error when the function below posts the form (from the second time, the first time it is blocked). When I click the submit button after this, the form submits without problem. The error is TypeError: e[h] is not a function. I already have changed the id of the submit button to something else than "submi...
I found the solution to my problem. When I searched for the answer I first encountered a solution which stated that it was a problem with the id of the form. I changed that by changing the id to something else: <code> comment_form(array('id_submit' =&gt; 'submitform')); </code> But that still didn't work. In the end it...
Error when posting comment form: The error is TypeError: e[h] is not a function
wordpress
The loop below works fine, apart from the fact that the pagination will always stop on page 6. No matter what arguments i specify, it will never show more than 6 pages. Does anyone know why? <code> &lt;?php $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; $idxargs = array( 'posts_per_page' =&gt; '1', 'pa...
Trying to use pagination from a different query is always fraught with potential disaster. <code> next_posts_link </code> accepts a second argument, <code> $max_pages </code> , which may solve your issue if you pass it properly: <code> next_posts_link( __( 'Next'), $idxloop-&gt;max_num_pages ); </code> However, the rea...
Pagination stops at page 6
wordpress
I need to count the number of new post since the last visit of the user on my blog, is it possible? Thanks to all for your help!
i think it is possible to get what you want by Store the last date time a user login as a user meta Use the usermeta to get posts published after the date - time uring $wpdb
Numbers of new post since the last visit of user
wordpress
Due to recent spam, I wanted to stop registration on my website for a while. But doing so meant the registration page would redirect to the homepage, which was bad for SEO. So I left the registration page there, removed the 'register' submit button and put in a little message telling people to contact me if they wanted...
One could easily submit the form on the page by adding a submit button to the DOM through javascript. I would suggest a redirect from the registration page to some other page without a form submission.
Users managed to register on website with no register button?
wordpress
I'm hooking <code> auth_redirect </code> to <code> wp_head </code> , but it's returning cannot modify header information. Do I have to hook it to a different action? Something that loads before wp_head? I tried hooking it to get_headers and send_headers, but then it didn't even work. Any ideas? Thanks! <code> add_actio...
It works fine on my localhost as well. The reason it probably doesn't work on your server is that it's not using output buffering . Hooking into <code> wp_head </code> means that the page has already started printing to the client's screen. Meaning <code> auth_redirect </code> 's use of <code> wp_redirect </code> will ...
Using auth_redirect returns cannot modify header information
wordpress
I'm using a plugin, NextGEN gallery, to display photos. Each gallery from this plugin corresponds to a different sub-page, so I'm using conditional shortcodes to assign the right gallery to it's corresponding sub-page. Problem is, it's not working. I've used this exact setup before without issue, which leads me to beli...
As a test in the first conditional statement replace your <code> //php comment </code> in the <code> else {} </code> portion of your conditional with an actual <code> echo </code> statement to see whether the conditional is actually working properly, <code> &lt;?php if( is_page( 39 ) ) { // make your stuff here echo do...
conditional shortcode not working
wordpress
Is there any way to add your own button next to "insert into post" button on the "add media" pop-up? I would like the button to add my own shortcode tags around the inserted image. The desired result: <code> [myshortcode]&lt;a href="link"&gt;&lt;img scr="img.jpg" /&gt;&lt;/a&gt;[/myshortcode] </code> instead of just: <...
There's no easy way to add a new button at present, however the "image_send_to_editor" filter will let you modify the HTML that is returned for the post insertion.
How to manipulate "add media" pop-up
wordpress
In a plugin, I want to provide a function for users to set the default query in their templates, so they can use some custom loops. What would be the best way of doing it? I imagine something like this: <code> my_plugin_set_query(); if ( have_posts() ) { while ( have_posts() ) { the_post(); ... iteration through a pred...
I did this, and it's working, but I'm not sure if it's the best way of doing it: <code> function get_override_query() { $posts = get_posts_from_some_custom_method(); $query = new WP_Query(); $query-&gt;current_post = -1; $query-&gt;post_count = count( $posts ); $query-&gt;posts = $posts; return $query; } function overr...
Providing a function to override the default query
wordpress
Below is how the URL layout is for my site using a Custom Post type called <code> book </code> and a custom tag taxonomy called <code> book_tag </code> I am un-happy with the way Wordpress is writing the URL for my custom tag taxonomy. Below is an example of how my new post type and taxonomy are currently writing the U...
After reading through about 20+ post on here, this is what I have come up with... In this example <code> http://test.com/{custom-post-type}/tag/{custom_taxonomy_name}/ </code> or <code> http://test.com/book/tag/css/ </code> Would do the trick I am after. <code> //http://test.com/book/tag/css/ function custom_taxonomies...
Change the Custom Taxonomy URL Slug pattern
wordpress
I am using this big theme that is almost entirely relying on widgets and sliders. Now I trying to avoid looking for <code> post_thumbnail </code> output code in all the included files in order to achieve fallback which should then grab first image in post or at last display default image. Is there a way of controlling ...
you can use the <code> post_thumbnail_html </code> filter hook which passes 5 variables to your hooked function : <code> $html </code> - the Output html of the post thumbnail <code> $post_id </code> - the post ID. <code> $post_thumbnail_id </code> - the attachment id of the image <code> $size </code> - the size request...
the_post_thumbnail fallback using hooks
wordpress
I'm working on a site wherein the owner wants people(potential real estate clients) to be able to write their home-owning hopes, dreams, desires, etc. I'm thinking something similar to the functionality of comments, like a live-feed testimonials page? My question is how do I facilitate this? I'm not too concerned with ...
This plugin allows posts from the front end: http://wordpress.org/extend/plugins/user-submitted-posts/ I have tested it and it worked fine, however, it is basic in that you can get the post title, content, category, tags using this, but if you want to add custom fields or anything more complex you may find a hand made ...
unregistered user can write in blog page - possible? how to?
wordpress
I'm using an if/else control structure to add class attributes to tags. Could I use a switch control structure instead and if so, how? If not, is there a better way to do this than what I'm doing? <code> &lt;div &lt;?php if (is_page( 'project' )) { echo 'class="project"'; } elseif (is_page('home')) {echo 'class="home"'...
While Ben's answer is basically correct, is_page also checks to make sure that the query is indeed a Page and not something else with the same post_name. So to be 100% accurate, you could do something like this: <code> if ( is_page() ) { // only do this for actual pages $page_obj = get_queried_object(); switch ( $page_...
Can is_page() be combined with a switch control structure?
wordpress
I am using this code in my functions.php file to display breadcrumbs on my web site.. <code> function the_breadcrumb() { if (!is_home()) { echo '&lt;a href="'; echo get_option('home'); echo '"&gt;'; echo 'Home'; echo "&lt;/a&gt; » "; if (is_category() || is_single()) { the_category('title_li='); if (is_single()) { ech...
Here's a suggestion: Yoast's SEO plugin is practically a must for a WordPress site, and has a breadcrumb implementation baked in.
Breadcrumbs - Exclude Child Categories
wordpress
I was wondering to know if it's possible to use global posts with custom_types. I was working with this function: <code> global $post; $myposts = get_posts('numberposts=4&amp;offset=1&amp; category=3,4'); foreach($myposts as $post) : setup_postdata($post); ?&gt; &lt;a href="&lt;?php the_permalink() ?&gt;" rel="bookmark...
By default <code> get_posts() </code> uses a default post type of <code> post </code> . If you want to select from a CPT then you need this: <code> $myposts = get_posts('numberposts=4&amp;offset=1&amp;category=3,4&amp;post_type=YOUr_CPT_HERE'); </code>
How to make global post work with custom post type?
wordpress
I have a site using a static homepage, and a posts page called Press( <code> press.php </code> ). The template is being pulled up correctly, however no posts are shown. Any ideas why? Thanks in advance. Live site. press.php <code> &lt;?php /* Template Name: Press */ ?&gt; &lt;?php get_header(); ?&gt; &lt;div id="logo"&...
Make a copy of <code> press.php </code> and rename it to <code> home.php </code> . The page you selected "Press" to be the designated page for your posts in the dashboard under, Settings > Reading > Posts Page: <code> [Press] </code> ...now falls under the control of the template hierarchy as listed by Milo. First Word...
loop not displaying posts on custom template page
wordpress
I've exported data from my dev server and imported it to my prod server. One template is listing child pages and uses <code> $page-&gt;guid </code> to get link to page. The problem is that this link still points to my internal dev server. Has anyone else had similar problems? And if yes, how do I solve it without havin...
The GUID is not an URL. Use <code> get_permalink() </code> to get the correct URLs. Just ignore the GUID. It is – as the name says – an identifier.
GUID not updated on import
wordpress
We're working on this site: http://granthammond.staging.wpengine.com/ which will no longer be using tags, i need a way to strip / remove all the tag links in the post content, for example: any hyperlinks containing <code> /tag/ </code> need to go, in their entirety, <code> &lt;a href="http://www.granthammond.com/tag/na...
1) For existing post content, you can add a filter to <code> the_content </code> to remove them from the output before they are seen by a user: <code> function remove_tag_links( $content ) { return preg_replace( '#&lt;a [^&gt;]*\bhref=\\\?"[^"]+(?=/tag/)[^"]+\\\?"[^&gt;]*&gt;(.+?)&lt;/a&gt;#si', '$1', $content ); } add...
Delete all Tag Links from Posts
wordpress
Is it possible to load site comments on-demand instead of having them always display at the bottom of the post? Like by clicking on Load Comments... . You can check labnol.org . They are using Disqus comment system which loads by clicking. How could I achieve that?
You could try an easy jQuery approach of hiding the comments div and inserting a button to make it appear. Instructions: In your functions.php file of your theme, place this line of code to ensure that jQuery has been included to run the code: <code> wp_enqueue_script('jquery'); </code> Then you could add this function...
Loading post comments after clicking a button
wordpress
I have the code below for a multisite install. It works fine, but I need to merge each WP_Query loop object from each multisite together for use in another template with the WordPress loop. Is this possible. I've tried merging the objects with: <code> $obj_merged = (object) array_merge((array) $obj1, (array) $obj2); </...
If you just need the posts of each WP_Query object, you can do do something like this: <code> &lt;?php // fetch blogs here $all_posts = array() foreach($blogs as $b) { switch_to_blog($b-&gt;blog_id); $query = new WP_Query(/* your args here */); if($query-&gt;have_posts()) $all_posts = array_merge($all_posts, $query-&gt...
Merging multiple wp_query objects
wordpress
I'm creating a Wordpress site with a Superfish CSS3 / Jquery dropdown menu, complete with hoverIntent as displayed here: http://users.tpg.com.au/j_birch/plugins/superfish/#examples As far as I can see, this menu works well on mobile devices, because the link values refer to the same page, like <code> #a </code> , so th...
In my experience, Superfish actually does not rely on in-page links in order to show the submenus on touch devices (although admittedly I'm basing this solely on iOS devices). Simply tap once on a top-level menu item and its submenu should show. A subsequent tap on the same top-level menu item would cause the browser t...
Replace the slug of parent pages with #
wordpress
I have a parent page called "About". This page has three child pages "Members", "Information", "Contact". I want to list all the child-pages on all four pages, also the parent-page. So right now I have this which lists all the child-pages only on the parent-page. <code> &lt;?php if ( !$post-&gt;post_parent ) { echo '&l...
This function will do the trick, it displays the child pages of the current page, but if there are no child pages, it displays the child pages of the parent page, and a link back to the parent page. <code> /** * @brief: Shows the subpages of the current page, or * the adjacent sibling pages. **/ function show_subpages(...
Listing all child-pages of a parent-page on the parent-page and each child-page?
wordpress
I have a Wordpress installation with MySQL encoded as utf8_general_ci. I'm trying to export it using wordpress' export tool, but the result XML breaks some special characters such as "é", "ê", etc turning them into "é" for example. The XML file is being downloaded into a Windows machine and scp'ed into a Linux. In bot...
The file is likely correct, but the program that you're viewing it in is probably interpreting it with ISO-8859-1 / latin1 encoding. The <code> é </code> pairing is something I have often seen when viewing a UTF-8 encoded <code> é </code> in latin1. Be sure that the program you are viewing the file in is set to view i...
UTF8 Encoding problems when exporting posts
wordpress
In my wordpress site I have a hack that looks at the uri and does a redirect to a subdomain. The problem is wp_redirect calls wp_sanitize_redirect which will strip out @ signs, so when a user tries to load something like oursite.com?email=foo@bar.com The page that gets loaded should be prefix.oursite.com?email=foo@bar....
Question why does <code> wp_sanitize_redirect </code> strip out <code> @ </code> signs, exactly? Anybody could anyway try to load a url with an <code> @ </code> sign in it - is there some security issue I'm not thinking about? Just take a look at the source: <code> function wp_sanitize_redirect($location) { $location =...
wp_sanitize_redirect strips out @ signs (even from parameters) -- why?
wordpress
Do I need to call <code> do_action </code> function every time I <code> add_action </code> something?
Usually, you use existing action in your plugins. WordPress will call <code> do_action() </code> when needed. If your plugin is rather complex, like a shopping plugin, you may want to offer additional actions for other plugin developers or for the pro-version of your plugin. In these cases you add <code> do_action() </...
Do I need to call do_action in my plugin?
wordpress
I'm looking add-in a bit more speficity to the WP Cron intervals. To add a "weekly" interval, I've done the following: <code> function re_not_add_weekly( $schedules ) { $schedules['weekly'] = array( 'interval' =&gt; 604800, //that's how many seconds in a week, for the unix timestamp 'display' =&gt; __('weekly') ); retu...
WP-Cron is not intended to be that precise, and should not be used if you have to have things scheduled at specific times. WP-Cron is a "best effort" scheduling mechanism, and it cannot guarantee run timing like a real cron system can. If you need precision of this nature, the only real answer is to not use WP-Cron for...
Run WP Cron Weekly (but on a certain day)
wordpress
I've created a form in a wordpress page (it's hardcoded in it's template.) This form redirects on the same page as it's on. This form also verifies the data right there, in the template file. If I put this form on any page, it works. But on the front page, when I submit it, I get a page, with the default template, with...
Seems my form was using some value from the namespace of wordpress. If this problem happens to you, check what id/names you give to your inputs. If it's too general, it might conflict.
Custom form on front page redirects on error page
wordpress
I have a task scheduled to run daily using wp-cron. The task takes over a minute to run (between downloading and parsing a very large file with cURL). According to the WP documentation, "The action will trigger when someone visits your WordPress site, if the scheduled time has passed." Could this "someone" have to wait...
No, the WP-Cron tasks run asynchronously from the viewing user. They should not see any delay. Although if your task takes more than a minute, it may never finish since most hosts are setup to kill PHP processes after 30 seconds.
Do wp-cron scheduled tasks run asynchronously?
wordpress
I have installed qtranslate in my local, it does not show the translated content, so there are two question if anybody have used this plugin. do i need to put the translated text by my self or it[plugin] does automatically? do i need to make changes in php file of the plugin to get the all automatic transnational. the ...
1) The plugin doesn't automatically provide translation - you have to fill it in yourself. However, there is a service you can use to get your translations: With qTranslate 2.3, a new feature called "qTranslate Services" have been added. So what does it do? Well, with qTranslate Services, qTranslate can finally do what...
qtranslate is not working properly
wordpress
I want to use a couple of custom image sizes for a site that I'm developing. When I output the images I sometimes do not get the correct width size because it is mixed up with the height size. It guess it has something to do with how I declare the image sizes in the functions file. functions.php <code> add_image_size( ...
The "medium" and "large" are not custom image sizes - they are already part of the core WordPress media sizes and they should be handled via the "settings" -> "media" options page in wp-admin. Give your custom image sizes a different and more unique name (reserved are thumbnail, medium, large, full)
Custom image size mixes width and height in output
wordpress
I would like to know how I can set up a form (separate from the normal search form), that will allow me to search through a particular custom post type. Within my defined custom post type I have 2 fields. In the search the user should be able to fill in any of them, in order to narrow down his search. Any examples of c...
Updated this answer in response to first comment below: <code> if(!empty($_GET['city']) AND !empty($_GET['state'])) { // if both fields are filled out, find houses that match both $relation = "AND"; } elseif(empty($_GET['city']) OR empty($_GET['state'])) { // if either of the fields are empty, find houses that match ei...
Searching Custom Fields
wordpress