question
stringlengths
0
34.8k
answer
stringlengths
0
28.3k
title
stringlengths
7
150
forum_tag
stringclasses
12 values
I am trying to figure out how to add my custom taxonomy for tags to the post class css when I already have added the custom taxonomy for categories. The code Im currently using to add the category taxonomy is - <code> &lt;?php $terms = get_the_terms( $post-&gt;ID, 'videoscategory' ); ?&gt; &lt;div class="box&lt;?php fo...
Ok I figured out how to add the terms to div's class - In the code I have first the category, then the post type, then a custom taxonomy tag term assigned to it - <code> &lt;?php $terms = get_the_terms( $post-&gt;ID, 'YOUR CUSTOM TAXONOMY CAT' ); ?&gt; &lt;?php $post_type = get_post_type($post-&gt;ID); ?&gt; &lt;div cl...
How to add tags (custom taxonomy) to post class css?
wordpress
I'm setting up the categories for my website and I have them like so: That's it, I have children of the same name but they are not interchangeable. If that bugs you just think that they have different names. Then I go to a post and I want to add categories to it and now the tree is completely gone and the categories or...
Category-list uses the function wp_terms_checklist() in wp-admin/includes/template.ph p on row 90. The parameter "checked_ontop" is set to true. So the checked checkboxes will be on top. This is only happening when editing a post, when I add a new one everything is fine and dandy Thats because when you create a post, n...
Category checkbox list tree changes when editing a post
wordpress
I have multiple media files in my WordPress Media Library. Icons, Images, PDF's and the like. I would like to have a stat counter, that gives me a statistic of the downloads/hits of those files, individually. I already use WP SlimStat to track page view, and I am quite happy with it. However, I have not found a possibi...
You could use Google Analytics for WordPress . Here's an excerpt from their FAQ on how you could set it to track certain file types: How can I track downloads? Check the box for "Track outbound clicks &amp; downloads", after that, make sure the file types you want to track are listed in the box of extensions to track a...
How to track hits of a single media file?
wordpress
As we all know, a design pattern that is used frequently in Wordpress' DB code is the idea of persisting data for a particular object (blog/post/comment), indexed with a particular name or key. We see this pattern used in the following standard tables: wp_options wp_commentmeta wp_postmeta As far as I can tell, the mot...
The ability to store abstract key-value pairs without modifying the database structure is the reason. Without that, WordPress loses much of its flexibility. I can't speak for others, but the single largest reason why I develop atop WordPress is its flexible nature. To quote one of your links above, Usually the reasonin...
What is the advantage of the wp_options design pattern?
wordpress
I'm using Advanced Custom Fields plugin and microkid Related Posts. I would like to display my custom fields inside Related post This is what I got so far? <code> &lt;?php //related artworks $related = MRP_get_related_posts( $post-&gt;ID, true, false, 'quote_list' ); //for testing related array //print_r ($related); if...
According to advenced custom fields you get the value with <code> get_field </code> http://www.advancedcustomfields.com/docs/functions/get_field/ Just change "text_field" to your field-key. <code> &lt;?php $related = MRP_get_related_posts( $post-&gt;ID, true, false, 'quote_list' ); if( !empty( $related ) ) { foreach( $...
Pull out Advanced Custom Fields in Related post plugin
wordpress
I have a lot of uploaded image files and image sizes. So it would be better to organize media files into folders based on post type. I have just read this tutorial, but as I can see it works with plugins. How to change this to use in a theme? Thanks. <code> function custom_upload_directory( $args ) { $id = $_REQUEST['p...
If i understand your question right you want a function within your theme that adds directories for the current post_type? like: uploads/post_type_name. if so here is a function for that: <code> function wpse_16722_type_upload_dir( $args ) { // Get the current post_id $id = ( isset( $_REQUEST['post_id'] ) ? $_REQUEST['...
Different upload directory based on post type in a theme
wordpress
I need a feature in wordpress, using which a new post automatically posted to Facebook Page &amp; Twitter. Do I need some plugin to do that.. Do you know any plugin that provides for this kind of feature? And may be support more social networks.
Download facebook auto post plugin from following link; Plugin Download URL here Follow author notes in installation and also see screenshot before installation. download twitter auto post plugin from following link plugin download link here
Publish post facebook page & twitter automatically
wordpress
I am trying to create a website at the following link: http://www.knowthelaw.in/ The website was created with wordpress using the twentyeleven theme. The problem I am facing is as follows: As soon as you agree to the disclaimer and hit the "Proceed to .. " button, you are served with a 404 error. The page it redirects ...
The welcome page "exists" since I can access it when I search for it , though trying to go to its link directly give me a 404 as well. As an experiment, try changing that page's slug to <code> welcome2 </code> ; if it works now, check if you have any custom rewrite rules set up that are overriding the welcome page. I s...
Problem with wordpress links on a live site
wordpress
Usually I hook all my custom plugins code with the <code> template_redirect </code> hook but one of the issue I encountered is it does not work for the ajax call. So if I want to target both standard calls and ajax call what hook should I use? Is <code> wp_loaded </code> a good choice?
For AJAX you need to hook into the wp_ajax_{action} hook Specifically, <code> add_action('wp_ajax_my_action', 'my_action_callback'); add_action('wp_ajax_nopriv_my_action', 'my_action_callback'); </code> See http://codex.wordpress.org/AJAX_in_Plugins
template_redirect not being called when using ajax
wordpress
I have the following function: <code> function remove_images( $content ) { if( ( is_category() || is_archive() || is_home() ) &amp;&amp; has_term( 'MyCat', 'category', $postID ) ) { $postOutput = preg_replace("/\&lt; *[img][^\&gt;]*[.]*\&gt;/i","",$content,1); return $postOutput; } } add_filter( 'the_content', 'remove_...
What it is doing, instead, is removing the first image from the_content() on all posts for the index page... That's because that's what your callback is telling the filter to do. It returns true for all posts in your specified contexts (archive index, category index, blog posts index), not just for the first post in th...
Conditional function for excluding first image from content, not working
wordpress
Sorry i'm pretty new on wp, i would like to add new menu links and site pages, to the main top menu bar. I'm using a third parties template, and i see the top.php file which contains the top menu looks like: <code> &lt;div id='mainmenu-container'&gt; &lt;div id='mainmenu'&gt; &lt;?php $nav_menu_params=array( 'depth'=&g...
Templates can all have unique code, and your template may or may not support Custom Menus . I would find out if you can add custom menus through your Appearance > Menus tab in the admin area. If you can't, all new pages you add from the Pages tab will most likely end up in that main menu by default. If you can add cust...
Main menu navigation links and new pages
wordpress
I'm developing a plugin to replace a character for some user agents in titles, posts and comments but the filter doesn't work. Here is the plugin: <code> &lt;?php /* Plugin Name: WP-HalfSpace Description: نمایش فاصله به‌جای نیم‌فاصله برای گوگل برای خراب‌نشدن نوشته در نتایج جست‌وجوی گوگل Version: 1.0.0 Author: ahmadalli...
<code> register_activation_hook </code> and <code> register_deactivation_hook </code> refer to when the plugin is activated and deactivated, respectively, and only fire in those two instances. They're to be used, for example, when you need to add a database table (and take it back down). You don't need to remove your f...
add_filter doesn't work
wordpress
Currently using the code below for SEO. When the Code Below if added to the header works perfectly but then you have to manually create the fields that are queried. Most Clients hardly get around the WordPress UI let alone create a field. I trying to write a plugin that can make the fields visible on every page edit by...
Typically what plugin authors will do is use <code> add_meta_box </code> to add an area on the post edit screen for users to enter extra data. Within the functions that save and retrieve the data to generate your meta box, use the post meta functions to store it. Remember that prefixing a meta key with an underscore wi...
Custom Fields for Page Edits
wordpress
When i publish new posts, i notice the new posts do not appear in the feed <code> http://mysite.com/feed </code> instantaneously, there is always lag time, one or several hours. When i change something in <code> wp-includes/feed-rss2.php </code> file (just <code> echo 'test' </code> ), it also takes one or 2 hour to se...
Just like the pages WordPress makes normally, feeds are generated on-demand, they're not "rebuilt" or "updated" or any sort of thing like that. So posts will appear in the feed at the exact instant that they are published. If you're seeing a lag time, then you may be using a caching plugin, such as WP-Super-Cache, or s...
Update feed more frequently
wordpress
I'm using the New User Approve plugin. After installing the plugin the top of the registration page says: Welcome to XXX site. This site is accessible to approved users only. To be approved, you must first register. How can I erase this message? I'm am using this code: <code> $message = apply_filters('login_message', '...
The second argument should be a function callback, not the actual message. You can remove the message completely by pasting this code into your theme's <code> functions.php </code> file: <code> add_filter( 'new_user_approve_welcome_message', 'wpse_76823_login_message' ); function wpse_76823_welcome_message( $message ) ...
How can I remove the welcome message generated by the New User Approve plugin?
wordpress
I am trying to make it so that WP will create another size image for me, but only when the image is uploaded via the Thickbox, and only when it will be attached to a certain ID. Does anybody know how to do this? The following works, but will create an image of that size for every upload, which is just inefficient. <cod...
There is no solution for this as of WP 3.5. There are a couple of core tickets about introducing the ability defer the generation of specific images sizes on the fly rather than at upload time to prevent the generation of multiple images that will never be used. However, they are far from being included in core at this...
Only make custom image size if uploaded via Thickbox and attached to certain page
wordpress
I'm trying to figure out how to find the actual function that's assigned to hooks and filters. I've been looking at other questions asked here and found a couple plugins that are helpful for findings the add_actions and add_filters that show me the callback function name... but I'm having a hard time finding that actua...
This is more of PHP programming question, rather than WordPress one. :) If you are interested in exploring function of WordPress core alone, there is number of ways dedicated to that: Codex has function reference that is human maintained - so it's not comprehensive but can include additional information for important f...
Finding actual functions added to hooks and filters
wordpress
I'm looking for a clean way of filtering the_content to add a piece of code before each H1 tag present in it. In fact, I have a long privacy policy text and I want to add a back to the top link before each paragraph. Of course, I could easily add these in the content editor but I don't want my customer to be able to re...
Just filter <code> 'the_content' </code> , test if you are on the stackexchange-url ("correct page"), then run <code> str_ireplace() </code> : <code> add_filter( 'the_content', 'wpse_76808_filter_h1' ); function wpse_76808_filter_h1( $content ) { // page slug if ( ! is_page( 'privacy-policy' ) ) return $content; return...
Filter the_content to add something before each element?
wordpress
I have a problem with the loop running on two instances with thecartpress plugin. Im not great with php by any standards but can usually get things done, however with wordpress im fairly new. Is there a way to have my plugin control the loop for just my catalog page and have wordpress ignore it? i hope im not being to ...
The problem was in my the loop.php file, i was executing a new loop using the wordpress parameters for the main loop, which caused a duplication with the plugin being used (thecartpress) which executes its own loop. I was using: <code> global $post, $query_string, $discTheme; query_posts($query_string); </code> in a se...
the loop - how to control whether wp or plug-in runs it
wordpress
I need to redirect a whole WordPress site to a single WordPress page. A sort of maintenance mode, but the redirect has to go to a published WordPress page. Unfortunately, the maintenance page I need to show has to use other WordPress plugins. I am not aware of any Maintenance Mode plugin which lets you do this. At most...
You don't need .htaccess to do this at all. A .htaccess fix would be bloated and overloaded. Instead, we can hook into the <code> template_redirect </code> filter, which only fires on the front-end (not in wp-admin). We then use the <code> is_page() </code> function to check if we're viewing a page with the ID of 813. ...
Redirect entire website to a single page
wordpress
I have this code which runs perfectly on jsFiddle. When I try to run that code on my self-hosted WordPress site, however, it will not run. (The code is exactly the same on my page, except that I added <code> &lt;script type="text/javascript" src="/files/jquery-1.8.3.min.js"&gt;&lt;/script&gt; </code> before the Javascr...
As for me, in WP I always use jQuery instead noConflict mode, Try to run this code: http://jsfiddle.net/GKmvA/1/
Javascript will not run properly
wordpress
I'm a <code> C programmer </code> , konw little about <code> PHP </code> . I built a Blog with wordpress. Yestoday, I try to create the page <code> www.abc.com/server </code> , this page would list all posts which belong to <code> server </code> category. I found some useful information in wordpress document and Google...
There are two issues here: The use of <code> query_posts() </code> Undefined <code> $pagename </code> variable I assume that you want to use the page slug as the string passed for the category parameter in the query arguments array? You can get that via <code> $post-&gt;post_name </code> , like so: <code> global $post;...
List all posts in a category with query_post() function
wordpress
I'm developing a plugin to replace a character that google doesn't show it with an accepted character. I want to get all the texts that wordpress returns (content, comments, title, names, etc.) but I don't know what hook should I use to do it. Can anybody help me?
There's a lot of filter hooks available, and your question is rather board. However, generally WordPress-generated content is handled by three hooks: <code> the_title </code> : applied to the post title retrieved from the database, prior to printing on the screen (also used in some other operations, such as trackbacks)...
What's the hook for filtering every texts of site?
wordpress
I have a custom page on my blog that doesn't display RSS feed . You can see the code here for the custom page. I am not sure what I need to do to make rss feed for each individual post on that page. I am not much in php myself so any help is appreciated.
You can create your own feeds in wordpress. Add this to functions.php: <code> function my_customfeed() { load_template( TEMPLATEPATH . 'your-customfeed.php'); } add_action('do_feed_customfeed', 'my_customfeed', 10, 1); </code> This will enable a new feed called customfeed. Now you can create your-customfeed.php in your...
How can I get RSS feed for a custom page?
wordpress
how to get results of a row with NULL element? I have to update the row which contains only the post_id and the repeat value, 'start' and 'end' should be NULL mysql table screenshot: http://i.imgur.com/l27is.png <code> $wpdb-&gt;update( $schedule_table, array( 'rpt' =&gt; $event_tag ), array( 'post_id' =&gt; $post_ID, ...
My simple and quick solution is the use of a normal $wpdb-> query() function: <code> $wpdb-&gt;query( $wpdb-&gt;prepare("UPDATE $schedule_table SET rpt = %s WHERE post_id = %d AND start IS NULL AND end IS NULL", $event_tag, $post_ID ) ); </code>
How to pass NULL in where array for $wpdb-> update
wordpress
WordPress 3.5 changed the media management and now the Media Library edit screen uses the default post type UI. Taxonomies are very useful for WP installs with different users and attachments, giving more possibilities to find the attachment and/or add classification. I have seen stackexchange-url ("Can I add a Categor...
To add the taxonmies from post type post, the default, then it is easy to add taxonmies 'category' and 'tags' with a small plugin liek the source below. <code> &lt;?php /** * Plugin Name: Attachment Taxonomies * Plugin URI: * Text Domain: attachment_taxonomies * Domain Path: /languages * Description: * Version: 1.0.0 *...
How to use taxonomies on attachments with the new Media Library?
wordpress
Here's what I have so far.. <code> class emailer { function notifyHeart($post_ID) { $interests = get_user_meta( get_current_user_id(), 'interests', TRUE ); $to = the_author_meta( 'user_email', get_current_user_id() ); if(has_tag($interests[0])) { $email = $to; mail($email, "An article about Heart", 'A new post has been...
<code> class emailer { static function notifyHeart($post_ID) { $interests = get_user_meta(get_current_user_id(), 'interests'); $to = get_the_author_meta( 'user_email', get_current_user_id() ); $post = get_post($post_ID); foreach($interests as $interest) { if(has_tag($interest, $post)) { $email = $to; mail($email, "An a...
User meta and author meta
wordpress
I'm trying to take existing images and shrink the file size down by resizing to photos to a smaller resolution. I've tried a few methods so far: Simply editing the photo in photoshop and reuploaded, replacing the existing (and larger) file. I tried the Imsanity plugin and set the options to be less than 1024x1024 and t...
You can perform a combination of things to accomplish a smaller file size. Let me guide you through it. Firstly, you could add custom image sizes and adjust the dimensions to the very smallest for their purpose. Put the following in your functions file: <code> function my_insert_custom_image_sizes( $sizes ) { // get th...
Resizing Images to lower Disk Space Using Plugins
wordpress
I have Ajax setup and I'm trying to toggle a function from being loaded into wp_head. It works on the first toggle function, but the second function doesn't register. <code> function av_maintenance_mode_turn_on() { if( !wp_verify_nonce( $_GET['nonce'], 'av-maintenance-mode-nonce' )) die( 'Go away!'); if( add_action( 'g...
I ended up not adding/removing the action at all, but rather writing an option to the database and having a second plugin check if the option is set: <code> function av_maintenance_mode_check() { if( !wp_verify_nonce( $_GET['nonce'], 'av-maintenance-mode-nonce' )) die( 'Go away!'); if( get_option( 'av_maintenance_mode'...
Add/remove action on jQuery toggle
wordpress
I'm limiting the number of characters in the title with <code> substr </code> . But even if the title is less than 50 characters, being shown the ellipsis (...). I would not display the ellipsis if the title does not exceed the limit of 50 characters. <code> $title = substr( $title, 0, 50 ) . "..."; </code> Title of my...
In the form you have posted this is more of PHP question - you could use <code> strlen() </code> functions to determine length of original title and apply ellipsis conditionally. However in WP context you should consider using <code> wp_trim_words() </code> since trimming based on words looks tidier and it will take ca...
Show ellipsis (...) only if the number of characters exceeds limit defined in substr
wordpress
I have a meta box checkbox, you click to turn on/show the blow info basically... These conditionals dont seem to be working for some reason, the first if works, but when i add in any other else if it breaks.. <code> &lt;ul&gt; &lt;?php if (get_post_meta($post-&gt;ID, 'hm_check_image1', true)) { ?&gt; &lt;li&gt; stufff ...
This is not really a WordPress Question, as you made a basic PHP mistake, but I'll help you anyway ;) you forgot to close the conditional with an <code> } </code> before the <code> elseif </code> statements. This should work: <code> &lt;ul&gt; &lt;?php if (get_post_meta($post-&gt;ID, 'hm_check_image1', true)) { ?&gt; &...
Quick Conditional Tag Question if elseif
wordpress
I am building a theme and I need to call theme options But I do get errors like white screen and 500 internal server error when I call theme options here In WP query (newbie in PHP) <code> &lt;?query_posts ('meta_key=post_views_count&amp;orderby=meta_value_num&amp;order=DESC&amp;meta_value=get_option(mytheme_value);');...
First, change your code into the following: <code> $value = get_option( 'mytheme_value' ); query_posts ( "meta_key=post_views_count&amp;orderby=meta_value_num&amp;order=DESC&amp;meta_value={$value}"); </code> When you use single quotation marks, php isn't parsed in the string, and functions (like <code> get_option </co...
WordPress theme options error
wordpress
Is it possible to use get_post() to retrieve which tags were selected in the post? I would like a way to store a single post's tags into a variable.
<code> &lt;?php $tags = get_the_tags($post_id); ?&gt; </code> Here <code> $post_id </code> is the ID of the post of which you want to get tags. This is same parameter as passed to <code> get_post() </code> . When used inside the loop $post_id is optional &amp; default to the current post.
Retrieve current post's tags
wordpress
I'm using the FitVids.js script to make YouTube video embeds work with a responsive layout. The script is &lt; 3kb, but only about half of my pages actually have YouTube embeds. In terms of total load-time for a page that doesn't contain a YouTube video, is it more costly to do a <code> strpos() </code> on the content ...
What happens on the user’s side is off topic as @bungeshea said already. Once the user has loaded the file it will stay in the browser cache for a while, so you don’t have to worry about double loaded files anyway. But let’s look at the server side and how WordPress handles this. If you want to load a script on every p...
Performance-wise, is it better to enqueue a (small) script on every page or test to see if it's needed?
wordpress
I'm using <code> pre_get_posts </code> to adjust the number of posts displayed on my homepage. <code> function lifelounge_query_adjust( $query ) { if ( is_home() ) { set_query_var( 'posts_per_page', 12 ); return; } } add_filter( 'pre_get_posts', 'lifelounge_query_adjust' ); </code> But I am running into a problem with ...
Here is an approach to account for sticky posts by getting the number of sticky posts (if any) and include that in the calculation <code> posts_per_page </code> parameter: <code> add_action('pre_get_posts', 'ad_custom_query'); function ad_custom_query($query) { if ($query-&gt;is_main_query() &amp;&amp; is_home()) { // ...
Sticky Posts exceed posts per page limit
wordpress
Hello I'm wondering if anyone can help me figure this out. Essentially when I click on my custom post type 'Portfolio' in admin, I see a list of 'Services' next to posts, but when I click on one to filter (e.g. <code> http://localhost:8888/wp-admin/edit.php?post_type=portfolio&amp;Service=web-design </code> ) nothing h...
Basically you are doing every thing right except the taxonomy slug in the url should be lowercase so you can simply place this line: <code> esc_url( add_query_arg( array( 'post_type' =&gt; $post-&gt;post_type, 'Service' =&gt; $term-&gt;slug ), 'edit.php' ) ), </code> with this: <code> esc_url( add_query_arg( array( 'po...
Filter custom post types in admin not working
wordpress
I started to use Bones HTML5 Wordpress Starter Theme, but a little confuse with some built-in function in bones, There is <code> function bones_comments() </code> in functions.php but I cannot find anywhere on the files where this function is used or called. And I take a look at the code in the function it just looks l...
It is a function created to be used as a hook. Inside the comments.php file is <code> &lt;?php wp_list_comments('type=comment&amp;callback=bones_comments'); ?&gt; </code> So you can add whatever you want to the bones_comments() function and have it added to the comment output.
What is the Difference in bones_comments() and comments.php
wordpress
When I try to search in my (Greek) website it always returns a single result despite searching for article titles I know should return multiple results. More specifically if i search for Μουσείo (Museum) it only returns a single result, despite the fact that I have at least a dozen articles about museums whose titles a...
You may want to put the following code <code> global $wp_query; var_dump($wp_query-&gt;request); </code> before the <code> &lt;?php if ( have_posts() ) : ?&gt; </code> line to check the exact SQL statement. Maybe running it did return only one result.
Search in non-English language returns only one result
wordpress
In my (page-only, no posts) Wordpress site I have a number of static blobs in need to put in a sidebar. We could call/tream thoses 'blobs' as widgets. At least they'll have a fixed html content, like 'teaser1', 'teaser2', 'disclaimer', 'foo policy'... What I need, is to arrange them differently for every page. So this ...
You can do it using Widget Context plugin or Widget Logic plugin. They work fine. I prefer Widget Context because it has more flexibility.
Individual Widgets per Page
wordpress
I'm currently looking to modify Wordpress so that it always uses the primary site for images. I am achieving this using: <code> function use_main_blog_library() { echo "&lt;script&gt;alert('is happenin');&lt;/script&gt;"; switch_to_blog(1); } add_action('load-media-new.php', 'use_main_blog_library'); add_action('load-m...
Unless you use the primary site to host all of your content, including pages and posts, this isn't going to be possible, and the nearest you can get requires a lot of kludges. Your existing 'kludge' invokes a lot of serious problems, and was a ticking timebomb of maintenance performance and security issues. This would ...
Using one media library for a multisite network with Wordpress 3.5 media library
wordpress
I have the following blog template with the the_content outputted. I have placed <code> &lt;!--more--&gt; </code> However it does not appear to be functioning, http://www.milknhny.co.uk/DVine/?page_id=19 Is there anything that needs to be included within functions for this to function? Code Of my Blog Template <code> &...
I see several things that may be contributing to your issue. First, you're using a custom page template to display the blog posts index, instead of using <code> home.php </code> as specified by the Template Hierarchy. That might be a problem, because the <code> &lt;!--more--&gt; </code> tag doesn't work on singular pag...
not functioning
wordpress
Does anyone know how to get the name of the user who last updated a post/page please? (Not the post author). I can see that it is visible in the post/page revisions but don't know how to access it. Any ideas/help greatly appreciated.
You can use <code> the_modified_author(); </code> See https://codex.wordpress.org/Function_Reference/the_modified_author <code> &lt;p&gt;This post was last modified by &lt;?php the_modified_author(); ?&gt;&lt;/p&gt; </code>
Get the name of user who updated post
wordpress
I have this code that I am using on a site to check if the current user has a blog on the our wp network and as of now it is echoing the URL for both the main site and their blog. I would like to know, how can I modify the code so that it only echoes for the user's site and not the primary/main site. <code> &lt;?php if...
Ok I was able to eventually figure it out, what I did was exclude the main blog from the code. <code> &lt;?php if(current_user_can( 'edit_posts' )) { global $current_user; $blogs = get_blogs_of_user( $current_user-&gt;id ); if($blogs) { foreach ( $blogs as $blog ) { if($blog-&gt;userblog_id != 1) { echo '&lt;li&gt;&lt;...
WPMU - How to echo only one URL
wordpress
I see that it is possible to sort a user query by the number of posts each user has, but is it possible to exclude users with zero posts from the result? In the Wp_User_Query class there is a <code> pre_user_query </code> action, but query strings are a huge weak point, so I'm not sure what sort of filter action I'd wa...
Well I have come up with 2 solutions. Solution 1 - foreach loop and verify each user This one is based off of @GhostToast's solution, but with updated WordPress functions <code> //new query with default args $author_query = new WP_User_Query(); // Get the results $authors = $author_query-&gt;get_results(); if( $authors...
WP_User_Query to exclude users with no posts
wordpress
I figured out how to assign a template to a product category (from this thread stackexchange-url ("Different template of products for specific category. WooCommerce")), but I'm wondering if I can assign a custom template to specific products. EDIT: For more clarity, I want to have a certain style applied to the categor...
If the changes you need are strictly CSS, you can add the category names as classes to the <code> body_class </code> via the <code> body_class </code> filter. <code> add_filter('body_class','wpa76627_class_names'); function wpa76627_class_names( $classes ) { if( is_singular( 'product' ) ): global $post; foreach( get_th...
How to assign custom template to specific products in Woocommerce?
wordpress
I have made a plugin for wordpress which copies the image to another directory when a post has been edit. But if you only upload another featured image and don't save the post. The image has been attached to the post, but the post has not been updated. Which does not trigger my plugin function. Show which trigger (acti...
The <code> set_post_thumbnail </code> function uses the metadata functions to set the featured image. You have two actions to hook into that process: <code> update_post_meta </code> , before the data is written into the database <code> updated_post_meta </code> , after the data is written into the database You will hav...
Which action hook can I use when a featured image has been selected
wordpress
I have rules that only work on paginated pages (is_paged). However, they don't work on page number one (/page/1). This one is behaving exactly like the homepage (!is_paged), but unlike pages 2,3,4 etc. I want to prevent page 1 from behaving like the homepage and have it behave just like any other page. <code> if (strpo...
EDIT - SOLVED: OK, so for whoever else looks for this, I found a workaround that is actually quite straightforward: on the paged.php template, set a variable such as $paged = true, than instead of !(is_paged()) use !($paged).
page 1 is not paged
wordpress
I just started working on wordpress. Now i have created custom form and that form data I want to save in database and mail also. For that form creation, I have one php file which i have used as template on one page. and then that form submit, i have given action to another page [ which also made by custom template]. I ...
This is not exactly a WordPress question, because you made an error in your form. Try adding name="idea-outline" to your textarea, and you should be fine.
Custom form values without plugin
wordpress
I have placed images on Wordpress page templates without any inline style attribute but it seem Wordpress automatically add style tag with <code> width </code> and <code> height </code> set to zero. <code> &lt;img src="wp-content/themes/ecoblog/images/hiw-image-1.png" style="width: 0px; height: 0px;"&gt; </code> Someti...
Before you ask a question: maybe check on a other install of WP, is this the default? It is not? The problem is very often from plugins or themes. Disable plugins and switch to the default theme, current Twenty Twelve and check your problem. The current release 3.5 and 3.4* have not this insert as default, only the img...
Why is inline CSS added to images automatically?
wordpress
I have a page where I'm pulling in content from another post, outside of the loop. I've been successfull at getting the content of the specified post, but I cannot get the image from a custom field (advanced custom image field). This is working to get the content from the post who's ID is 299: <code> $my_id = 299; $pos...
see documentation for <code> get_field </code> . change: <code> $attachment_id = get_field('image'); </code> to pass the post ID as second argument: <code> $attachment_id = get_field('image', 299); </code> or: <code> $attachment_id = get_field('image', $my_id); </code>
How to get custom image field of specific post id
wordpress
I wish to remove the sub menus of post/link/media under the add new menu in the admin bar. I can remove the entire menu but I actually only want to remove the sub menu's <code> $wp_admin_bar-&gt;remove_menu('my-account-with-avatar'); </code>
See the Admin Bar remove_node function: <code> add_action( 'admin_bar_menu', 'remove_wp_nodes', 999 ); function remove_wp_nodes() { global $wp_admin_bar; $wp_admin_bar-&gt;remove_node( 'new-post' ); $wp_admin_bar-&gt;remove_node( 'new-link' ); $wp_admin_bar-&gt;remove_node( 'new-media' ); } </code>
remove admin bar new post/link/media sub menu
wordpress
When viewing the Favorite Plugins tab, <code> /wp-admin/plugin-install.php?tab=favorites </code> , the list comes unordered, is it possible to sort it from A to Z?
That page is rendered by the WP_Plugin_Install_List_Table class, which calls the function <code> plugins_api() </code> . In this function, we find two filter hooks that enable the manipulation of the table output: <code> plugins_api_args </code> and <code> plugins_api_result </code> . The problem is that the API doesn'...
How to Sort the Favorite Plugins Screen Alphabetically?
wordpress
I'm trying to edit just a few pieces of bbpress' breadcrumb default settings, but the filters I've tried end up replacing the whole function. How do you replace only bits? Here is the filter as it stands now <code> function custom_bbp_breadcrumb() { $args = array ( 'before' =&gt; '&lt;div class="bbp-breadcrumb"&gt;', '...
Looks like that isn't the filter the want. It runs right at the end of the BBPress <code> bbp_get_breadcrumb </code> function which is after the stuff you want to change. You can change just the separator with <code> bbp_breadcrumb_separator </code> and it looks like before and after can be set with <code> bbp_get_brea...
filter just a portion of plugin function
wordpress
I've seen techniques on how to remove specific Admin Bar items, but how do we do with those extra menus added by plugins/themes? How to remove all Admin Bar items? Related Q&amp;A's stackexchange-url ("Is the new WordPress 3.1 admin bar pluggable and how can I extend it?") stackexchange-url ("remove &quot;edit your pro...
I'm solving this getting all nodes from the Admin Bar, iterating through them and removing all that doesn't have a <code> parent </code> . An exception is made to the User Actions menu ("Howdy, user_name"), which needs an extra checking. <code> add_action( 'admin_bar_menu', 'wpse_76491_admin_bar_menu', 200 ); function ...
How to Remove All Admin Bar Menu Items?
wordpress
So far I've been using the following code to remove the dashboard update message ("WordPress 3.5 is available! Please update now."): <code> remove_action('wp_version_check', 'wp_version_check'); remove_action('admin_init', '_maybe_update_core'); add_filter('pre_transient_update_core', create_function( '$a', "return nul...
How to hide WordPress update mesages CSS The low-tech way to hide something is using css: <code> // Low-tech hiding of update-mesages // source: http://wpsnipp.com/index.php/functions-php/hide-update-nag-within-the-admin/ function remove_upgrade_nag() { echo '&lt;style type="text/css"&gt; .update-nag {display: none} &l...
Remove "Time to upgrade" message from dashboard
wordpress
Below is a DB query I am using to retrieve values and place them in a WP_List_Table. Values are currently being added by <code> add_option </code> , then those values are converted into a custom database table called <code> wp_testimonials </code> . I have no clue why I did it this way, but it works! So now I need to c...
The function <code> update_option </code> includes action hooks that you can use. Use <code> update_option_{$option_key} </code> as shown here: <code> function my_func($option, $value) { //this is called only when that particular option is updated //$option has the option key &amp; $value has the value array } add_acti...
Make Database query only when option is updated
wordpress
I have a command line script for maintaining a wordpress plugin and have to determine the wordpress base path to be able to load the wordpress core. I could just assume the script is several levels under the base path. But if I want to reuse the code and I have another similar script that needs to determine the wordpre...
I came up with this solution. This function checks in each directory level starting from the directory of the current file for the file <code> wp-config.php </code> . If it is found the directory is to be assumed the wordpress base path. The check can of course be changed to other wordpress core files. <code> function ...
How to determine wordpress base path when wordpress core is not loaded
wordpress
Is it possible to edit existing registered post statuses? I am using the Edit Flow plugin to create custom statuses, however, the plugin does not offer the option to set whether the statuses are 'public' or not. I went in to the code and was able to insert that in, but obviously that will get overwritten with any updat...
You can alter a post status after init by changing the global variable <code> $wp_post_statusses </code> : <code> function alt_post_status() { global $wp_post_statuses; $wp_post_statuses['custom_status']-&gt;public = true; } add_action( 'init', 'alt_post_status' ); </code> register_post_status() (line 922) does the sam...
Modify Post Status Arguments
wordpress
I have tried to apply filters to the_post_thumbnail() function using <code> apply_filters( 'post_thumbnail_html', $html, $post_id, $post_thumbnail_id, $size, $attr ); </code> Here's the code I have come up with but doesn't seem to work completely <code> function red_adjust_image_schema($html, $id, $caption, $title, $al...
You've simply the wrong arguments (incl. the list of them). <code> $caption, $title, $align, $url, $alt </code> are too much in there. And <code> $attr </code> is missing. Not that it matters how you name the vars (as long as they start with a character), but it's easier to read for later readers. <code> function wpse7...
Adding schema itemprop image to the_post_thumbnail with filters
wordpress
I have put together a custom registration form on my WordPress site and one of the items on the registration form is an ability to select an interest. Essentially I have the following code from the registration form... <code> update_usermeta( $user_id, 'interests', $_POST['interests'] ); </code> I would need a code tha...
See this example on the stackexchange-url ("question 19259"). The function was init on publish a post, change the hook to your post type or use on default <code> post </code> - Hook <code> publish_post </code> . Before you send check in the function your custom user meta field, like <code> get_user_meta( $user_id, 'int...
Notify users whenever a new post is published based on their preference
wordpress
I would like to know what $_registered_pages does and where am I supposed to use it. Thanks. p.s was unable to find any documentation on it online.
<code> $_registered_pages </code> is a temporary container for all registered admin menu pages. It is filled in <code> add_menu_page() </code> and <code> add_submenu_page() </code> and used used later in <code> user_can_access_admin_page() </code> . The leading underscore indicates you should not use it for anything. I...
What does $_registered_pages do?
wordpress
How can I add custom HTML/PHP file into head where custom post-type list showing like this ? Any Wordpress function can do this ? or I can only do by JS(jQuery) to append my custom content ?
If its okey you can hook into <code> admin_notices </code> . Like this: Change <code> post_type </code> to the real <code> post_type </code> name.. I assumed it would be "program". <code> function wpse_76471_add_html() { global $pagenow ,$post; if( $post-&gt;post_type == 'program' &amp;&amp; $pagenow == 'edit.php' ) { ...
Function to add custom HTML into head in custom post-type list page
wordpress
I have a blog where I publish Linux tutorials. Some of the commands I listed have a <code> -- </code> before command-line arguments. e.g.: <code> dpkg --get-selections </code> . The problem is that WordPress automatically switches <code> -- </code> to an &ndash; ( <code> &amp;ndash; </code> ). I know I could use the <c...
Problem solved with this gist https://gist.github.com/4329321 . <code> [notexturize]--[/notexturize] </code> worked like a charm.
Why is `--` converted into ndash and how can I get rid of it?
wordpress
I have added post formats support to my theme. The post formats box appears on the bottom of the sidebar in the New/Edit post page. It appears below the Categories, Tags and Featured Image. Is it possible to change its position in the sidebar and for example show it before the categories? I understand we can drag and d...
What you can do is remove the post formats meta box and adding again in another position. If you put this in functions.php: <code> // remove post format meta box function remove_post_format_box() { remove_meta_box( 'formatdiv' , 'post' , 'side' ); } add_action( 'admin_menu' , 'remove_post_format_box' ); // Add post for...
Change position of Post Formats box?
wordpress
I have the following query which I call in my taxonomy.php template via <code> query_brands_geo('dealers', 'publish', '1', $taxtype, $geo, $brands); </code> This function works perfectly. However after reading codex for query posts it mentioned pre_get_posts as a preferred way to alter the default query. Would the pre_...
pre_get_posts will run the same query, so both will take same time. But, If you utilize pre_get_posts action you will save one or more SQL queries. Right now, WordPress is running default query and then you run your query with this function which replace the results of the default query (resulting, default query is of ...
Should I use Pre Get Posts or WP_Query
wordpress
I have a custom post type that hold real estate listings and I need to figure out a way to keep a record of the price of the property is listed for. For example a user lists a property for sale and then the user edits the property listing and changes the price. I need to show the price before and the new price and the ...
Your best option here is to create a second Custom Field and store an Array of all the versions that have been used together with the date of the update and the user who commited the changes, acually everything you need to know. Hook into the <code> save_post </code> action and compare the Value of the Custom Field wit...
How to keep a record of changes to a custom field?
wordpress
I have created a custom post type for a property rental site created with WordPress. In it I want to have the input section as checkboxes: and get the output like this:
You can do this by custom meta, all you have to do create custom metabox and the your checkboxes on it, the easiest way to create custom metabox is 1). Download WP Alchemy Metabox Class from here 2). Palce 'wpalchemy' folder inside of your theme folder in your function.php file <code> include_once WP_CONTENT_DIR . '/th...
How to output an image or icon for selected check box in a custom post
wordpress
On a particular archive page I've created, I'm listing a number of posts by post name and they're listed in alphabetical order. Is there away to have them separated even further? As in all posts starting with "A" are grouped and have a heading of "A", then all posts starting with "B" are grouped and have a heading of "...
You can do some tricky thing with PHP. Here is the algorithm you could use. Query posts to get posts as alphabetical order. <code> for/while </code> loop starts. <code> $t </code> = Get first character of the title string. <code> $temp = '' </code> empty string. <code> if $t != $temp echo $t </code> . set <code> $t = $...
Arrange and separate posts
wordpress
I'm trying to add <code> &lt;i class="icon-ok"&gt;&lt;/i&gt; </code> before the content inside the <code> &lt;li&gt; </code> of the blogroll widget. I'm assuming that's done through the link_title filter, but I can't find a suitable explanation as to how. Any thoughts?
Filter the arguments for the blogroll: <code> add_filter( 'widget_links_args', 'wpse_76521_filter_blogroll' ); function wpse_76521_filter_blogroll( $args ) { $li_start = isset ( $args['before'] ) ? $args['before'] : '&lt;li&gt;'; $args['before'] = $li_start . '&lt;i class="icon-ok"&gt;&lt;/i&gt;'; return $args; } </cod...
Add filter to blogroll widget
wordpress
I am trying to use the isotope plugin for sorting on my taxonomy page and even though I don't know much about how to set it up, I tried using some advice found on here. stackexchange-url ("Wordpress and isotope filtering") I did so by taking this code <code> function isotope_categories() { $categories = get_categories(...
get_categories() does not require parameters, by default it will query the post type <code> post </code> and the taxonomy <code> category </code> . However, get_terms() require a taxonomy parameter. Also, in the second function, you wrote: <code> $categories = get_terms(); </code> It should have been <code> $terms = ge...
ISOTOPE - Missing/Invalid Arguement Get Terms
wordpress
I installed latest WordPress 3.5 in my CentOS server. When I tried accessing <code> http://example.com/wp-includes/ </code> , I received a listing of the directory: ( Index of wp-includes ). I added the following code at the top of <code> .htaccess </code> file, and it fixed the issue: <code> Options -Indexes IndexIgno...
The PHP files in the <code> wp-includes </code> directory will do nothing when accessed directly. They are designed to be <code> include() </code> 'd in an existing PHP script, such as on the front-end or in the dashboard. Your <code> Options -Indexes </code> entry in the <code> .htaccess </code> file simply prevents a...
File and directory permissions
wordpress
I need to create a custom query for the author archive (where the author is post_author OR is a meta co_author), and it have to work with WP Pagenavi. The query is something like this (omitting $wpdb and usual clauses for clarity): <code> SELECT posts.* FROM posts, postmeta WHERE posts.ID = postmeta.post_id AND (posts....
Ok, I think I found something that actually works, and I'm posting it just in case someone need it. The solution is simply to avoid using Pagenavi just for this page, using <code> paginate_links() </code> instead and forcing it to behave more or less like Pagenavi to maintain coherence all over the site. Let me explain...
Custom query (author is post_author or meta co_author) with Pagenavi pagination
wordpress
I recently published a WordPress plugin but all the links of plugin page (Description, Installation, FAQs, Screenshots etc) has same two line description I used in readme.txt. Although, I properly filled up the readme.txt template . But it is not picking up anything else except description.
Interesting bug you provoked out there :) The only thing I see missing is the "short description" located between the <code> License URI </code> and the <code> ==Description== </code> block. It is used in the Header area: While you are at it, take a look at this article: The Plugins directory and readme.txt files . And...
Setting up WordPress plugin's page
wordpress
After updating a 3.4.2 network install to 3.5, I receive Fatal error: Call to undefined function nocache_headers() in /wp-admin/admin.php on line 32 This happens in Chrome, and in Firefox (when I am not logged into admin). I have downloaded a 3.5 zip, and uploaded and overwritten /wp-admin, but the issue remains. I hav...
There were wp files in the web root which had file size of 0 bytes. Uploading proper copies from the zip file resolved the problem. The same cause of the problem has occurred to me quite a few times in the past, but I had forgotten it.
Call to undefined function nocache_headers()
wordpress
I have a command line script for maintaining a wordpress plugin and have to load the wordpress core to be able to access wordpress functions. This problem is very similar to stackexchange-url ("Initialize WordPress environment to use in a real cron script"). Though it differs from it as the referred question is suppose...
I came up with following solution. The script have to start with the following code. <code> &lt;?php if( php_sapi_name() !== 'cli' ) { die("Meant to be run from command line"); } function find_wordpress_base_path() { $dir = dirname(__FILE__); do { //it is possible to check for other files here if( file_exists($dir."/wp...
Initialize WordPress environment to use in command line script
wordpress
I modified an abandoned Stackoverflow form of badge plugin to work with Wordpress 3.4.2 and it does indeed. The full script for it is here: http://pastebin.com/Ta91zXiL When upgrading to Wordpress v3.5, I receive these warnings when publishing a post (or post a comment): <code> Warning: Missing argument 2 for wpdb::pre...
Lead developer Nacin answers this one: Hello plugin or theme author! You possibly found this post after searching the Internet for the error above: “PHP Warning: Missing argument 2 for wpdb::prepare().” So, this is a new warning in 3.5. No sites are broken, everything is fine as before. But, this is indeed something yo...
Stackoverflow type of badge plugin giving warnings in Wordpress 3.5
wordpress
I have constructed a <code> WP_List_Table </code> that displays on a custom theme page that I have built. I am having some trouble getting the row actions to display, despite me reviewing all the possible info on the Internet about WP_List_Table. Any help would be great! <code> class Testimonials_List_Table extends WP_...
In <code> display_rows() </code> you are using the following code to print the 'name' column: <code> echo '&lt;td '.$attributes.'&gt;&lt;strong&gt;&lt;a href="'.$editlink.'" title="Edit"&gt;'.stripslashes($rec-&gt;name).'&lt;/a&gt;&lt;/strong&gt;&lt;/td&gt;'; </code> Nowhere do you call <code> column_name() </code> , w...
Row actions not showing? Why?
wordpress
I'm using this code to generate all my custom field values from all posts for custom field named "autor". <code> &lt;?php $autor = $wpdb-&gt;get_results("SELECT meta_value AS autor FROM wp_posts, wp_postmeta WHERE post_status = 'publish' AND meta_key = 'autor' GROUP BY meta_value ORDER BY meta_value") ?&gt; &lt;ol&gt; ...
Your query is incorrect in the first place because you're not doing the join correctly. What you're actually selecting with that query is just all the postmeta's autor fields, without regards to whether the post is published or not. Here's the corrected query. <code> SELECT meta_value AS autor FROM wp_posts JOIN wp_pos...
Speed optimization of $wpdb-> get_results
wordpress
I want to add a ul to the list when a page have a child, Im making a foreach on all the post_types so i don't think that i can use something like wp_list_pages . I have been trying to sort this out but just ended upp with this: <code> // Check for children $children = array(); foreach ( $values as $post ) { if( $post-&...
<code> //first let's separate all the top level pages &amp; child pages $top_lvl = array(); $children = array(); foreach ( $values as $post ) { if( $post-&gt;post_parent ) { $children[$post-&gt;post_parent][] = $post; } else { $top_lvl[] = $post; } } //now we have all top level pages in $top_lvl //&amp; we can access t...
Add ul to its children with get_posts
wordpress
Is there some way to remove <code> wp_nav_menu </code> in a page template? I can't find anything related to page templates other than redirect default theme files etc. I know that just placing the <code> header.php </code> content in the page template will do the trick but this seems a awkward hack. Thanks for any clue...
Without knowing your theme, you have at least a few options. You could 1. hide it with CSS. <code> .your-page-template-php #your-menu { display: none; } </code> Or 2. you could create a custom header file. For example, duplicated header.php to header-nomenu.php. And in your new file delete the menu. And then in your pa...
Prevent menu from loading in a page template
wordpress
In a WP_List_Table example I'm using, I am seeing how to make a general query to the <code> wp_options </code> table in the Wordpress database. For example, <code> $query = "SELECT * FROM $wpdb-&gt;options"; </code> I also see that we typically create a <code> foreach </code> loop to display all the records in this tab...
The table <code> wp_options </code> can normally be queried using get_option() So you can use something like <code> $testimonial_settings = get_option('testimonial_settings'); </code> to retrieve the values of <code> testimonial_settings </code> . If the stored value is serialized, it will be retrieved as an array.
Filtering a Database Query
wordpress
I have some images uploaded in wordpress posts (eg. post#1, and post#2). Now I've created a new post (eg. Post#3), and in this post I have inserted the WordPress 3.5 gallery, I did not upload any image in the post#3, instead I used the images from the post#1 and post#2. Now in the post#3, I would like to get the links ...
I had the same problem - how can I display all the images from a post containing a gallery where some of the images are not attached to the post, or are attached to different posts? The new media interface in WP3.5 allows you to add any of the images in the media library to a gallery, regardless of whether they are "at...
How to get gallery images?
wordpress
I have a custom post type that imports external data nightly. When the import script runs for the first time, it imports approximately 4,000 records (data will grow). Each record consists of a post title, body and 15 additional meta fields. After the import has run at least once, all subsequent nights it updates at lea...
One big help I have found with importing / updating large qty's of posts is to use InnoDB tables and transactions, in batches of 200-500 posts (with more postmeta, use smaller post batches). It greatly improves performance, given that much of it is individual MySQL statements each of which must hit the db transaction l...
Resource Issues: Importing external data into custom post type and keeping records up to date
wordpress
Here's my site: http://dev.shoeporn.com/ I'm running WP 3.5 and using this plugin: http://wordpress.org/support/plugin/responsive-select-menu It is supposed to allow you to select which menus you want to be responsive, but it doesn't seem to work. I only want the <code> &lt;div id="header-bar"&gt; </code> menu to be di...
I was missing the "theme_location" parameter for my wp_nav_menu() functions. http://wordpress.org/support/topic/selectively-activate-theme-locations-not-working
How can I only show one responsive menu on mobile devices?
wordpress
I am creating a Wordpress page that searches through posts based on a date variable that is set through a _GET variable. I want to make sure that I am doing this in the best way possible and that I sanitize the input correctly, I haven't worked with sanitizing php much. Here is the code I have and it functions properly...
<code> strtotime </code> will return false if you give it weird information. <code> echo strtotime('&lt;script&gt;'); // bool(false) </code> However, if you do what you are doing and nest two statement you may not get what you expect. <code> echo strtotime('+1 day',strtotime('&lt;script&gt;')); // int(86400) </code> An...
Escaping date string in url with wordpress
wordpress
I'm creating a menu with the wp_nav_menu() function. Now I'd like to add a GET variable to the end of ever link in the menu, like this: www.mysite.com/page/?variable=123 Is there any way I can do this when using wp_nav_menu? Thanks for your suggestions
Filter <code> 'wp_nav_menu_objects' </code> . You get an array as argument, a list of all items. Pseudo-code, not tested: <code> add_filter( 'wp_nav_menu_objects', 'wpse_76401_filter' ); function wpse_76401_filter( $items ) { $out = array(); foreach ( $items as $item ) { if ( isset ( $item-&gt;url ) ) $item-&gt;url = a...
Appending a GET-Variable to wp_nav_menu
wordpress
Wordpress appears to let content be addressed by many URIs in an MU install. For example: <code> example.com/wp-content/blogs.dir/5/files/picture.jpg example.com/bob/files/picture.jpg example.com/bob/wp-content/blogs.dir/5/files/pictures.jpg </code> All appear to route to the same place. Are there more aliases? Which o...
Short Answer example.com/bob/files/picture.jpg is the preferred, canonical URL for images in a WordPress Multisite installation . The two URLs with <code> blogs.dir </code> in the URL are essentially identical, and both leverage the filesystem structure. The path with 'bob' exists because you did a sub-directory instal...
Which asset URLs are acceptable in a "vanilla" MU install?
wordpress
I have imported advanced custom fields from one of my other site and now I want to add few more options to those fields but I can't figure out how to do it via Dashboard ? I have imported the field using php export/import option of the plugin. Is there anyway that imported fields shows up in Field Groups section in Das...
Fields added by PHP are not shown in the Dashboard. Recently, I came across this post in the User Submitted Fields section of ACF forums: PHP Recovery Tool . The author posted a plugin in GitHub, Advanced Custom Fields Recovery Tool from PHP Export . Haven't tested, though. Use this plugin to import fieldsets from PHP ...
Edit Imported advanced Custom Fields from wordpress Dashboard
wordpress
http://www.milknhny.co.uk/DVine/?page_id=19 Please can someone help, i have added the categories, however it appears to be off line. I have tried to style this in a class but this screws up the whole thing. I wrapped like the below but it seemed to apply to the whole of the div it was wrapped in <code> &lt;div class="c...
The way i fixed the issue was to insert the following code into my main CSS. <code> .post-categories, .post-categories li {display:inline; padding: 0px;} </code> I hope this helps others in this issue in the future.
Category location styling
wordpress
I´d like to echo the post name instead post id. My code shows just the id. <code> &lt;?php global $post; $customlink = get_post_meta( $post-&gt;ID, 'clink', true ); echo $customlink; ?&gt; </code> Thanks Ogni
Does this meta field store some other post's ID, of which you want to retrieve the post name? If so, try this <code> &lt;?php global $post; $customlink = get_post_meta( $post-&gt;ID, 'clink', true ); echo get_post_field( 'post_name', $customlink ); ?&gt; </code>
Chance post id into post name
wordpress
How to fire on bulk actions inside of an extended WP_List_Table. I have been adding the following bulk actions to may table's select box but on Apply won't really happens anything here are how I added my bulk actions <code> function get_bulk_actions() { $actions = array( 'delete' =&gt; 'Delete', 'parsing' =&gt; 'Parsen...
If you add a bulk-action, then you have to react on this action. Simply adding a function doesn't do anything, you have to call it: <code> class WPSE_List_Table extends WP_List_Table { public function __construct() { parent::__construct( array( 'singular' =&gt; 'singular_form', 'plural' =&gt; 'plural_form', 'ajax' =&gt...
wp_list_tables bulk actions
wordpress
I have installed a wordpress site and for some reason I can see these 2 directories: .git .qidb Do I need them? Can I remove them? Will it hurt me in any way?
You should not need the .git directory but I would not delete it. It contains the version control for your site, and is thus an incredibly valuable resource should you need a developer to fix or upgrade your site in the future. It also shows you a full history of the development of your site. This will save future deve...
Do i need the git directory?
wordpress
I am working on a wordpress navigation menu and trying to simlpy (of course, dynamically) add number inside a span tag for each menu li item. So I created a "top menu" using the wordpress custom menu function then I used a simple jquery function to add a "span" tag inside each tag like so: <code> $("#top .menu ul li a"...
<code> $("#top .menu ul li").each(function(i, el) { $(this).children('a').prepend("&lt;span&gt;" + (i+1) + "&lt;/span&gt;"); }); </code> or much better <code> $("#top2 .menu ul li").each(function() { var $this = $(this); $this.children('a').prepend("&lt;span&gt;" + ($this.index()+1) + "&lt;/span&gt;"); }); </code> chec...
Adding numbers inside a span tag in nav menu
wordpress
I have noticed in Role Scoper recently (sure it wasn't always like this) that contributors can see all the pending posts of all users. Basically I have it set up so users have to submit their posts for review. But I don't really want any posts to be public in any way other then to admins and the user them self until it...
Found a solutin, using the following plugin: http://code.mincus.com/41/manage-your-posts-only-in-wordpress/
Role Scoper, don't allow other users to see pending posts
wordpress
I'm building a landing page and want to remove the navigation menu from the page. The navigation menu is in header.php which is of course in the page template. Is there a WordPress function I can use to remove the navigation menu from this specific page? I know I could do it with jQuery and do display:none for the nav ...
Use a conditional tag: Codex References: Function Reference (is_page) Function Reference (Conditional Tags) You can specify the landing page by Page ID, Page Title or Page Slug. Here is an example: <code> &lt;?php if ( !is_page( 'landing-page' ) ) { wp_nav_menu( array( 'show_home' =&gt; 'Home', 'container' =&gt; 'false...
Remove navigation from header in custom page template
wordpress
I need some help because I want to use some jquery (and css probably) on some custom fields on post edit screen. What I need exactly is to make , and . magically apear when user types a number: types 100, jquery makes it 1,00 and so on. The custom field I created using the plugin Types and it's named wpcf-imovel-preco....
You can use the admin_enqueue_scripts hook for add custom javascript files into the backend.
Jquery on custom-field backend
wordpress
Is wordpress capable of having hierarchical taxonomy and hierarchical custom post types in one permalink ? I would like to do the following: tax-1/tax-2/cpt-1/cpt-1-post/cpt-2/cpt-2-post/ in other words: continent/country/travelog/travelog-post/videos/video-post/ or in a real case where "a-day-at-the-beach" is the trav...
To cut a long story short the answer to the question is Yes. In the end I was able to create: tax-1/tax-2/cpt-1/cpt-1-post/cpt-2/cpt-2-post/ and another structure: tax-1/tax-2/cpt-1/cpt-1-post/cpt-2/custom-field/cpt-2-post/ I used Types from http://wp-types.com/ to create the hierarchical custom taxonomy, the custom po...
Is it possible to have hierarchical taxonomy and hierarchical custom post types in one permalink?
wordpress
What I'm trying to do: Add new user meta fields that can be updated when the user edits their profile Validate them correctly when the form is submitted What I've done: I have successfully added the fields to the user editting form and have them being updated to the options database as follows: <code> public function s...
After examining the code and much trial and error, I have a solution: There is a filter - <code> user_profile_update_errors </code> - that is called in the file <code> wp-admin/includes/user.php </code> just after Wordpress does it's own input validation. This filter allows plugins to return their own errors by adding ...
Validating a new user registration field
wordpress
I have a shortcode for my content. This shortcode organizes a couple of things in my posts on the frontend. However, when I look at my feed, the content in the entirely leaves out any content from my shortcode and only starts after the shortcode content. When I take the content outside of my shortcode it shows up in th...
Ok I had to write my own custom excerpt like such: <code> function custom_excerpt($text = '') { $raw_excerpt = $text; if ( '' == $text ) { $text = get_the_content(''); // $text = strip_shortcodes( $text ); $text = do_shortcode( $text ); $text = apply_filters('the_content', $text); $text = str_replace(']]&gt;', ']]&gt;'...
Shortcode content does not show in feed discription/excerpt
wordpress
I have a custom post type setup with a custom taxonomy. Once a post is created with custom meta data and terms in the custom taxonomy. If I delete the post does it delete the terms and custom meta?
Terms should work like categories (which basically they are but with with different names). They are attached to posts but not dependent upon them. If you delete a post the term stays, like with categories. Custom post meta is dependent upon its post and will be deleted when the post is permanently deleted. It isn't de...
After deleting a post are terms, and custom meta deleted?
wordpress