question
stringlengths
0
34.8k
answer
stringlengths
0
28.3k
title
stringlengths
7
150
forum_tag
stringclasses
12 values
I am using WordPress 3.4.2. The codex doesn't say anything about this function being depreciated: http://codex.wordpress.org/Function_Reference/get_most_recent_post_of_user
get_most_recent_post_of_user() is for multisite installs to get the most recent post of the user from each blog. Here is a comparable function you can use that will return the post object of the defined users most recent post. <code> function wpse_get_user_recent( $user ) { global $wpdb; $recent = $wpdb-&gt;get_row( $w...
Why do I get Fatal error: Call to undefined function get_most_recent_post_of_user()?
wordpress
The default category for the page News is news. But I want the page news to show all posts. Not just news posts. All posts, includes news posts and engineering posts. When you hit the main site is http://www.papermepress.com , it does indeed do this, as you can verify. But when you go to News it it only shows the news ...
I'm not sure you are understanding what a 'category page' is doing; for example your news page: <code> http://papermepress.com/?cat=1 </code> this is pulling out all post with the categoy 'news' which has cat id equal to 1. depending on your needs there are two possible things you can do. 1 - if you simply want all pos...
Setting default category for display
wordpress
I would like to attach a ZIP file to every post I write on my blog. I'd like to find a plugin that will do these things: 1- Insert on the post editor a box like this which allows me to upload the file. 2- Automatically insert at the bottom of each post a box that allows the reader to download the file I attached.
I would still use the WordPress uploader, but you'll need to modify it to make it work. So say you want gpx files (assuming this is what you mean). When you upload something, WordPress looks at it's file extension and based on a set of allowable mime types lets the upload go through or blocks it. Those allowed mime typ...
Attach a file to a post
wordpress
I'm currently working on a University project wich is a website for managing a GameJam event that occures every 6 months. Our users will be in teams of 1 to 4 people and will be able to post about their game development live on our website during 48h. Last year, we used a simple wordpress blog and told our users not to...
Use a multi-site installation (see our multisite tag), give each team its own sub-site on <code> /team-name/ </code> and use the master site for the rest. Advantages All users on a multi-site setup are stored in the same database, they don't need a separate account for the main site. You can give each user a different ...
Creating teams of users in Wordpress
wordpress
I have this really simple setup where I loop through an array of actors, and for each actor name I successfully insert a term. Then I use wp_set_post_terms to assign the terms to a post, but this only assigns the last term to that post. I am new to using taxonomy/terms so maybe there's an obvious solution. Here's my co...
You need send a fourth argument to the function: <code> wp_set_post_terms($post_id, $actor_term_id, 'actor', true); </code> Each time the function executes, you're replacing any existing terms. The fourth argument specifies that you wish to append them. https://codex.wordpress.org/Function_Reference/wp_set_post_terms
wp_set_post_terms is assigning only the last of several terms to a post
wordpress
Hey all i have this code here: <code> if ( !function_exists('AddThumbColumn') &amp;&amp; function_exists('add_theme_support') ) { // for post and page add_theme_support('post-thumbnails', array( 'post', 'page' ) ); function AddThumbColumn($cols) { $cols['thumbnail'] = __('Header Images'); return $cols; } function AddTh...
functions attached to <code> manage_pages_custom_column </code> get fired for every custom column, you have to check the name of the column within the function to only output data for that specific column: <code> add_action( 'manage_pages_custom_column', 'AddColumnValue', 10, 2 ); function AddColumnValue( $column_name,...
create 2 custom columns in page edit in Admin panel
wordpress
I must be thick, but I could use some help grasping the way template files are chosen to be used. I noticed loop.php is no longer around, and looking at the file structure for twentytwelve there is now a 'page-templates' directory. As well as content-* files. We have index.php, page.php, content.php which one is used w...
Template hierarchy consist of templates, but not every template file is necessarily in hierarchy. Essentially hierarchy determines entry points (one of matching templates with pre-defined name structure), but from there template can further load additional arbitrary files. <code> page-templates </code> directory holds ...
Help Understanding Template Hierarchy
wordpress
I have a site setup with content, themes, plugins, and modified code. However, I want a mobile version. I googled this and it looked like there use to be plugins that helped with this, but it seems most have been dis-continued. Is there a strategy for making a site mobile?
You have 3 choices choose a Responsive Theme for your site (Responsive adapts for different screen sizes) choose a plugin (such as WPTouchPro - which is both plugin and theme) build a second site which you access at m.example.com, this duplicates all the content and has its own theme ... there is a 4th option ... being...
Strategy for making a mobile version of an existing site?
wordpress
I am trying to figure out how to paginate a post for it's images. I have a custom post type set up to act like a gallery - images only. And would like to paginate the images. I am having a hard time trying to figure out where to start with this. I am using get_posts() within the loop to get the images attached to the p...
You could use <code> paginate_links() </code> to paginate the total gallery. This highly depends on your permalink settings. The best would be to check stackexchange-url ("other answers on that topic here on WPSE"). Next/Prev post links for attachments. Than there's also the task to navigate on single attachment displa...
Setting pagination for images attached to a post
wordpress
I'm using finnish translation of wordpress. I found the fi.po file which contains all the translations, but for some reason, editing the contents wont edit the contents of the page. Can I make changes to the translation?
You can make changes to the translation, yes, but it's not as simple as editing the text inside the fi.po file (or any PO file, for that matter). That's because WordPress actually uses another file, with an .MO extension, to render the translations. That extension is not meant to be read by humans, so you wouldn't be a...
Make changes to translation?
wordpress
I am planning to create a "Photography" page in my wordpress site. In that page, there will be a list of the photographers (maybe create a user group called 'photographers') and display the images they have uploaded, next or under their avatar. The list of the images uploaded has to be updated automatically when they u...
This example loops through all photographers and then displays all images uploaded by them: <code> &lt;ul&gt; &lt;?php $photographers = get_users( 'role=photographer' ); foreach( $photographers as $user ) : $pictures = new WP_Query( array( 'author' =&gt; $user-&gt;ID, 'post_type' =&gt; 'attachment', 'post_status' =&gt;...
Display list of uploaded images, filtered by user under a specific user group
wordpress
I am writing a code in the header that pertains to link rel='prev' and link rel='next' thing but I need to check if the post is multipage. I check out these global variables: $numpages $multipage However they don't work in header.php or outside the loop? Example code to verify in header (just a test, but it does not wo...
Just inspect the current post content for <code> '&lt;!--nextpage--&gt;' </code> : <code> function wpse_check_multi_page() { $num_pages = substr_count( $GLOBALS['post']-&gt;post_content, '&lt;!--nextpage--&gt;' ) + 1; $current_page = get_query_var( 'page' ); return array ( $num_pages, $current_page ); } </code> On page...
How to Access Global $multipage or Global $numpages outside the loop?
wordpress
I'm using a plugin called CMS Page Order http://wordpress.org/extend/plugins/cms-page-order/ (Now referred to as CPO) It's pretty simple, the said plugin adds a new item to the submenu of every custom post type. The menu item leads to a page where you can reorder the posts of the certain post type. I've added so that y...
You can also change the menu with the global variables of WordPress for display the menu and submenu. All first items are in the var <code> $menu </code> and all suparts are in <code> $submenu </code> . Also a small example for change the order of the submenu-items with <code> edit.php </code> . Add thius plugin and se...
Change top level menu item to point to custom submenu item
wordpress
In the codex it says its possible to do get_users() with multiple meta keys by using the meta_query parameter but it doesn't explain how. Can someone give me an example?
As it mentions in the Codex page for <code> get_users </code> , it works the same as a <code> WP_Query </code> <code> meta_query </code> , see that page for full arguments list and examples. <code> $args = array( 'meta_query' =&gt; array( array( 'key' =&gt; 'some_key', 'value' =&gt; 'foo', 'compare' =&gt; '=' ), array(...
How to do get_users() with multiple meta_keys
wordpress
Came across a line in some Wordpress code I am modifying and just flat out don't know what the $2.$3 is? Maybe it's a PHP thing that I just never learned? Can anyone explain this to me? Here's the plugin I'm modifying: <code> &lt;?php /* Plugin Name: Pinterest Plugin Plugin URI: http://www.WordPressPinterestPlugin.com ...
Agree this isn't really a WordPress question. However, I believe the $1, $2, and $3 refer to the capture groups determined by the (.*?) wildcards. Now, regex is totally voodoo to me so I'm sorry I can't explain it 100%. However if you look at the $pattern definition: <code> $pattern = '/&lt;img(.*?)src="(.*?).(bmp|gif|...
What does $2$3 mean?
wordpress
So the question seem unclear, i rewrite it to hope for the best and get some great ideas. I write a WordPress Sticky post (always first on top). In that post text there is something written like : Act fast, enroll in the next class. next date : sept 10 2012. But as time past, date changes, and to keep that post current...
Here's summed up what you need to do: Get a meta box library . Add custom fields with dates Attach a filter callback action to <code> the_content </code> filter Get the current date, check your custom fields, append date in content. So here's the filter callback, that lets you append your "next date": <code> function w...
How to change text (date) in post base on the day
wordpress
I am trying to get all the posts in a specific category separated into 3 different sections. Each category will be in a different div. When I try doing this, WordPress lists every post in every category in each div. How can I get it so that it will only list the posts in each category? I tried to modify loop.php so tha...
Here is something i have used recently... not too complicated... First.. we call all categories. Then.. we get posts inside each category using foreach <code> &lt;?php $allcats = get_categories('child_of='.get_query_var('cat')); foreach ($allcats as $cat) : $args = array( 'posts_per_page' =&gt; 3, // max number of post...
how to separate categories in loop.php?
wordpress
I have a WordPress install that has a ton of categories. I want to convert some of these categories into a custom taxonomy. For example, I have: Categories: Category A Subcategory 1 Subcategory 2 Category B Subcategory 1 Subcategory 2 Category C Subcategory 1 Subcategory 2 And I would like to make Category C and all of...
You can create whatever new taxonomies you want to by adding register_taxonomy() function in functions.php After that you can simply assign all the posts related to Category C to that custom taxonomy using Convert Post types plugin .
How can I convert some categories to a custom taxonomy?
wordpress
I am using supersized full slider for my themes, but it need all the script and stylesheet gets enqueued before wp_head. So it becomes the part of the header. Now whenever I use the header template (which is essential) Supersized also get included in all pages. I want to use it in front and home page only. I have a def...
Well first of all it depends how you are enqueing your other scripts but make sure you dont add them before the jQuery library itself has been included. There is nothing stopping you using conditional code in header.php to add scripts depending on the page that is loading, or even the template, category etc; <code> &lt...
Using a specific template for front page only
wordpress
Is it possible to just show the most recent tags from e.g. the latest 10 posts as a tag cloud? The only things that I found were the WP Recent Tags plugin which is a bit outdated and no tags are displayed when I use the widget. I found the following posts: stackexchange-url ("How can I get a list of the most recent tag...
Sure, just feed your tag list to wp_generate_tag_cloud : <code> $found_tags = $final_tags = $id_records = array(); // get last 10 posts $last_posts = get_posts('numberposts=10'); // gather tags foreach($last_posts as $post) $found_tags = array_merge($found_tags, wp_get_post_tags($post-&gt;ID)); // prepare final tags fo...
Displaying the most recently used tags
wordpress
Assume this is my site name : <code> www.example.com. </code> I saw different websites have different themes in a site. For example I want to have different themes for <code> www.example.com </code> and <code> www.example.com/othertheme. </code> I know it should have different database for that. But how?
This is one of the best use cases for WordPress Multisite . There are some plugins ( like this one ) that do this on a per-page or per-category basis, but I've never used them. Multisite has a lot of nice advantages (network-wide updates, user management, etc), along with some fun extra bugs (a lot of the recent core s...
different theme in one website
wordpress
My portal has the following category structure: CategoryLevel1=> CategoryLevel2=> CategoryLevel3=> CategoryLevel4 I assign posts to CategoryLevel4 but I want to show the full category path beneath each post. Each node should be clickable. Thanks.
Assuming your categories are in a parent=> child hierarchy as listed(ie category4 is a child of category 3, etc) then this should give you what you're after: <code> the_category("&amp;raquo;", "multiple", $post-&gt;ID); </code>
How to show beneath posts the full category path?
wordpress
I know the former allows additional parameters, so you can more user info, but other then that, why do both exist? The specific reason I want to know is that wp_insert_user() is happening REALLY slowly. Somewhere between 5 - 10 seconds. I don't remember having this problem in the past, when I was using create_user, so ...
None. The whole source of <code> wp_create_user() </code> is: <code> function wp_create_user($username, $password, $email = '') { $user_login = esc_sql( $username ); $user_email = esc_sql( $email ); $user_pass = $password; $userdata = compact('user_login', 'user_email', 'user_pass'); return wp_insert_user($userdata); }...
What's the difference between wp_insert_user() and wp_create_user()
wordpress
How can I fix this, i get an error 404 when i acess the second page of post-type www.site.com/clipuri/2012/ www.site.com/clipuri/2012/page/2/ <code> register_post_type('clip', array( 'label' =&gt; 'Clip','description' =&gt; '','public' =&gt; true,'show_ui' =&gt; true,'show_in_menu' =&gt; true,'capability_type' =&gt; 'p...
For modifying the main query, I think it is best to take advantage of the <code> pre_get_posts </code> action. When using <code> pre_get_posts </code> the <code> $query </code> variable is passed "by reference" which means we can directly manipulate the <code> $query </code> object with the shortcut functions such as <...
How can I fix this, i get an error 404 when i acess the second page of post-type
wordpress
I've searched high and low for this but think the answer I seek is being buried by the more common questions. I am developing a theme for a client that has two specific image sizes (100x127 for thumbnail, 300x380 for medium). I have the media settings cropping like this when an image is uploaded, but if the user goes i...
There is a very good plugin that I believe covers all you are looking for, and more: Scissors Continued . I've been using it extensively on several websites, and recommend it.
Force image crop size in media editor
wordpress
I have no idea why this would/could happen. I have a custom metabox for an "event_end_date" set for a custom-post-type. If I leave this field blank it always puts out the publish-date of the post itself? I use the Custom-Metaboxes-and-Fields-for-WordPress library like this … <code> $meta_boxes[] = array( 'id' =&gt; 'ev...
I'm half asleep here so correct me if I am wrong here but it looks to me like you are saving the publish date of the post each time you save the post, <code> $wr_event_end_date = isset($_POST['wr_event_end_date']) ? $_POST['wr_event_end_date'] : ''; $event_end_date = new DateTime($wr_event_end_date); update_post_meta($...
Empty meta-box returns publishdate if no value is set?
wordpress
When i go to wp-admin/users.php, in the second column i can see the users full name, however, its not in the right order. In Hungary, we use a different name order: http://en.wikipedia.org/wiki/Hungarian_names So i need to change the name from "First name - Last name" to "Last name - First name" How can i do this?
You can't alter the default Name column, but what you can do is hide it and create your own custom column. First, we add the action and filter on <code> admin_init </code> that will add and manage our new column: <code> function wpa66544_user_custom_column_init(){ add_filter( 'manage_users_columns', 'wpa66544_user_add_...
How can i change the name order in the admin?
wordpress
I need to make custom search for specific house projects in my new wordpress site. It needs to have 4 dropdown lists - 1 [number 2] for categories and 3 [numbers 3,4,5] for tags. Tags need to be defined within the code because from 13 tags on whole site, 4 are for one dropdown, 5 are for second one a 4 are for third. I...
You can define any taxonomy in the arguments: <code> wp_dropdown_categories('taxonomy=post_tag'); </code>
Search with multiple selects that include tags
wordpress
My multisite setup has one sort-of-admin site, where users can insert/edit posts and specify on which site they want 'em published. This is a contract requirement and cannot be changed. EDIT: Check the accepted answer for a much simpler approach to this. The basic steps in inserting content are done and properly workin...
Who would say the solution would be this simple... After days battling with this, somehow it struck me: "what if we <code> switch_to_blog() </code> inside the media upload iframe?" What if we require the user to save the post before uploading any images? Turns out I had no answer to why we weren't doing this on the fir...
Upload images from one site to another in Multisite
wordpress
It looks like adding current-cat-ancestor class to category list was proposed, but never implemented. The only way I've been able to find so far is to re-create the <code> wp_list_categories() </code> function entirely: <code> function wp_list_categories2($args = '') { global $cat; if($args == '') $wp_list_categories =...
After fumbling around with this for a bit, I realized I needed this to work with custom taxonomies, not just regular categories. I unfortunately couldn't use "all" of what either the solution I found or Tom did, so I ended up writing my own. As long as you specify a <code> taxonomy </code> arg, you should be all set: <...
current_cat_ancestor Alternatives
wordpress
Is there any way to overwrite a <code> &lt;head&gt;&lt;title&gt;Category title&lt;/title&gt;&lt;/head&gt; </code> tag? Let's say i have a "Videos" category, when user point's his browser to <code> www.website.com/category/videos/ </code> , the page title (this one in <code> head </code> section) is Videos . What i need...
You can use the <code> wp_title </code> filter to modify the output of the <code> wp_title </code> function. quick example based on the example from Codex: <code> add_filter( 'wp_title', 'wpa66574_title_filter', 10, 3 ); function wpa66574_title_filter( $title, $sep, $seplocation ) { // account for $seplocation $left_se...
Overwrite category head title
wordpress
I found out something weird today. The current permalink is set to <code> /%category%/%postname%/ </code> but this happens (example): I have a parent category <code> Food </code> and 4 subcategories <code> Burger </code> , <code> Pancake </code> , <code> Waffles </code> , and <code> Pizza </code> . As expected, the lin...
When a post belongs to more than one category, regardless of their parent/child structure, WordPress will use the category with the lowest ID in the permalink. If that lower ID belongs to a child category, you'll see the parent/child structure in the permalink. If you always want parent/child category appearing in the ...
Hierarchy of Subcategories on Permalink (bug?)
wordpress
I´m creating a child theme for Twenty Twelve v1.0 and I want to remove the Open Sans font. Open Sans is added in Twenty Twelve´s functions.php: <code> wp_enqueue_style( 'twentytwelve-fonts', add_query_arg( $query_args, "$protocol://fonts.googleapis.com/css" ), array(), null ); </code> I´ve tried to deregister/dequeue t...
Found the answer stackexchange-url ("here"): Script dequeuing calls should be added to the wp_print_scripts action hook(..). This is because scripts are typically enqueued on the wp_enqueue_script hook, which happens early in the wp_head process. The wp_print_scripts hook happens right before scripts are printed, and t...
Remove Open Sans from Twenty Twelve theme
wordpress
I like the idea of making developers connect their copies to the same database and just set <code> WP_HOME </code> and <code> WP_SITEURL </code> to configure the domain name as they like it. In this model, we don't need to keep migrating databases between servers, and the content will be kept in sync between developers...
Instead of changing WP_HOME etc, it would be best to enforce a single domain, e.g. local.example.com or shared.example.com and then use the HOSTS file to set that address to 127.0.0.1 This way there is no change to the URLs at all as it is unnecessary, and the shared DB content is consistent (this menu doesn't work on ...
Multiple multisite instances connecting to the same database
wordpress
I don't use The Loop, because I use different queries to fetch posts (I use 3 queries instead of one). How to disable main query for home, category and search pages?
This is not trivial, because "home,category and search" are logically determined while main query churns through stuff. I am pretty sure I read this is possible, but that was in context of syndicating site that hadn't used posts/loop at all and scrapped it to do different stuff. More typical approaches are: Integrate c...
How to disable main query?
wordpress
When I enable WP_DEBUG, I get lots of the following kinds of notices (see below). Of course, I normally don't have the debugging turned on, but I'm wondering if these are a clue as to why it takes so long before my pages load. To be extra clear, my site is fine once the pages start loading (so it's NOT about loading bi...
No, notices by themselves are not a performance issue and generating them typically doesn't take considerable resources (there are exceptions if you are replacing error handler - I seen it get slow because of larger output volume and conflicts with antivirus). Of course what they do indicate is potential issues with co...
Do WP_debug notices explain why my site runs so slow?
wordpress
I am trying to get the username and password that entered by the wordpress admin in the add new user screen to use those into creating a webmail account using cpanel api. How to do that? is there is any hook for it? Also, When the user id changing his password, I want to get the new and old password and use it to chang...
You'll need three hooks: 1: user_register This is for when the user is created via the admin back-end. The username will be available via <code> $_POST['user_login'] </code> and the password will be available via <code> $_POST['pass1'] </code> . 2: edit_user_profile_update This is for when the password is updated on th...
How to get the password and username of the add new user form (admin back end) in wordpress
wordpress
I need to change my weblogs language to "English". I am refering to the article: http://en.support.wordpress.com/language-settings/ which allegedly was "Last modified: July 16, 2012". I only looked for this option in v.3.4 forward and I cannot find it. It's also absent in v.3.5 beta 1. I initially installed and still u...
No, they were never there. The link you posted is for WordPress.com hosted blogs, not self-hosted WordPress.org software. Refer to Installing WordPress in Your Language for info on use in other languages.
Were the language toggles removed from WP recently?
wordpress
I've added a column to the edit screen and add an input for that column in the quickedit. Everything saves and displays like I'd expect with one small hiccup. If I click on Quick Edit for a particular post, make a change to the custom input, and save.... well the column updates properly. However, if I click Quick Edit ...
The solution was on the jquery side of things. The .on function needed to bubble upwards to be sure that it was always getting the most recent, ajax-added content. I only had to adjust the first line to be more aligned with jquery documentation for <code> .on() </code> . <code> $( '#the-list' ).on( 'click', '.editinlin...
Fields don't reflect previous Quick Edit changes when clicking Quick Edit a second time
wordpress
I've created a custom post type called <code> 'publications' </code> and a custom taxonomy called <code> 'topics' </code> . I'm also using the standard taxonomy of <code> 'category' </code> . My Custom Query makes sure that it fetches ALL <code> 'publications' </code> that are in the correct <code> 'category' </code> b...
Finally, I have managed to make this work. I've found the holy grail of ordering custom post types by a custom taxonomy, with pagination. The code isn't pretty but it works. My method was to forget about SQL queries and to just select ALL the custom posts that matched the correct Category and the correct Custom Post Ty...
Custom SQL Query on Custom Post Type. Order by Taxonomy?
wordpress
I am using the Headway theme, and I need to add custom field code to page &amp; posttitles. This is what I need to be able to do. The red button will be added through a custom field. It needs to be shown inline with the title. I have worked out I can do this using the <code> headway_after_entry_title </code> hook, but ...
There's the <code> get_post_meta() </code> function to retrieve those data. So basically, you'd write a function in your functions.php file (or in a custom plugin - take "Hello Dolly" as example) and hook it. <code> &lt;?php /* Plugin Name: (#66495) »kaiser« Headway Title Button */ function wpse66495_headway_title_butt...
Add custom fields after post/page title
wordpress
How can i display in a archive themplate ( post type) page a number of post, Let say i want to display a number of 20 post....in archive page, under i want to display the pages... Please look here : http://cinema.trancelevel.com/trailer/aventuri/page/2/ I use post type pages... all the archive pages are now displayng 1...
Just use the <code> current_post </code> property in the loop: <code> if ( have_posts() ) { while( have_posts() ) { global $wp_query; the_post(); // Show current post number: echo $wp_query-&gt;current_post; } // endwhile; } // endif; </code>
How can i display in a archive page a number of post i want
wordpress
The <code> add_menu_page </code> documentation says to pass the menu title as the second parameter: <code> add_menu_page('Page Title', 'Menu Title', ...); </code> When adding more pages later via <code> add_submenu_page </code> , the main page becomes the first entry in the submenu: However, I want the first item in th...
You can make the 'slug' for the submenu page equal that of the top level page, and they'll point to the same place: <code> add_action('admin_menu', 'my_menu_pages'); function my_menu_pages(){ add_menu_page('My Page Title', 'My Menu Title', 'manage_options', 'my-menu', 'my_menu_output' ); add_submenu_page('my-menu', 'Su...
add_menu_page() with different name for first submenu item
wordpress
I have WordPress at address http://www.example.com/blog/ , now I want it to be accessible as http://www.example.com/ without moving wordpress to root directory. I have made appropriate .htaccess changes. wp-config.php: <code> define("WP_HOME", "http://{$_SERVER["HTTP_HOST"]}"); define('WP_CONTENT_DIR', $_SERVER["DOCUME...
Add to <code> wp-config.php </code> : <code> define('WP_SITEURL', 'http://example.com/blog/'); </code> On the codex . This is all you need.
How to make wordpress use www.example.com/blog/wp-includes/ instead of www.example.com/wp-includes/?
wordpress
In my theme i have a menu on the top of the page where i've links for my pages, this is the line of code in the header.php that generates topNav, <code> &lt;!-- BEGIN HEADER-TOP --&gt; &lt;?php wp_nav_menu(array('theme_location' =&gt; 'topNav', 'depth' =&gt; 3, 'fallback_cb' =&gt; false, 'menu_class' =&gt; 'topNav')); ...
<code> wp_nav_menu </code> has a <code> $container </code> parameter that can be used to set the type of container ( <code> div </code> or <code> nav </code> ) or to disable it. You could set the parameter to <code> false </code> and hardcode the wrapper <code> div </code> whilst including a date inside of it: <code> &...
How to insert date in topNav
wordpress
I have an object that saves its data in postmeta. When there is a post_id, the object class will query data by using get_post_cutom(); After get data, it starts to do its jobs, the end result is a graphic presentation based on the data. I understand that wordpress handles postmeta caching, but I would like to know: Sho...
If the generation of the graphic presentation requires a lot of CPU time or memory, then yes, you could cache your graphic presentation (HTML I guess, right?). Perhaps in the database/memory, as a transient . Caching post meta data (that you use to generate the graphic) is not necessary, because WP already handles this...
Is it duplicated if I cache an object that uses data from postmeta?
wordpress
I am currently using woocommerce and would like to redirect none logged in users to the home page, however i am having a little trouble determining where i should implements this I have done research and determined that using the is_user_logged_in() i can see if the user is logged in. I tryed implementing in the woocom...
You are going to want to insert your code at the top of the page templates for the Woo pages you would like the redirect to affect rather than the functions file. So for example if you want to redirect users when they try to access an individual product page you could put it at the top of the plugins-> woocommerce-> te...
woocommerce and is_user_logged_in() if not redirect to homepage
wordpress
I am trying to make a frontend product editor for WooCommerce, and have a loop that returns all of the products for the current user. I am trying to use gravity forms as the editor, so a single gravity form is displayed and populated for each product. However, I am not sure how to handle naming the function so it is no...
Before continuing, please read this: http://www.slideshare.net/andrewnacin/you-dont-know-query-wordcamp-netherlands-2012 It's by a core WordPress developer and you should consider it required reading. You should never use <code> query_posts </code> , and it's important to understand how to use loops correctly. That pre...
Having a Function Inside of the Loop
wordpress
My pretty permalink clearly shows the query_var: <code> localhost/site/?tree=312 </code> Yet when I run <code> var_dump(get_query_var('tree')); </code> I get NULL returned. Any reason why? Also when I print_r($wp_query), I can't find 'tree' anywhere.
You have to add any query vars that are not WordPress objects to the array of recognized query vars to be able to retrieve it from the <code> $wp_query </code> global: <code> add_filter( 'query_vars', 'wpa66452_query_vars' ); function wpa66452_query_vars( $query_vars ){ $query_vars[] = 'tree'; return $query_vars; } </c...
get_query_var returns null
wordpress
I have read through multiple questions here on StackExchange that concern WordPress scaling and the common opinion is that WordPress is indeed highly scalable provided you have the infrastructure to support it. However, all opinions point and talk about the database scaling. However, I must ask out of curiosity as to h...
If <code> INT </code> is set to <code> UNSIGNED </code> , allowing only non-negative integers, your value range is from <code> 0 </code> to <code> 4294967295 </code> . Thats... <code> 4,294,967,295 (4 billion +). </code> ...for the given table. Just to put things into perspective. Only through poor management and unnec...
WordPress database scalability from the code perspective
wordpress
I've made a custom <code> header-blog.php </code> (for blog page/ <code> home.php </code> ) in addition to <code> header.php </code> , both of which use the exact same <code> &lt;nav&gt; </code> code. On the pages that use <code> header.php </code> , the navigation works perfectly. However, on the blog page( <code> hom...
Well, I'm mostly thinking that you should maybe switch to using wp_nav_menu() for your navigation menus, and CSS to add the images to your nav items, because it's a lot more dynamic that way, and you can use "pretty" permalinks like http://urbanpalate.com/portfolio/some-work . As it stands though, I think your nav menu...
navigation doesn't work in custom header.php
wordpress
How can I change the order of posts in the admin dashboard, so they display alphabetically according to title, rather than latest first?
If you don't wish to always click the "Title" column to sort your posts by title, you can place this code in either your currently active WordPress theme's <code> functions.php </code> file, or within a plugin. This will automatically always sort your posts for you, so you don't have to click the title column every tim...
How to change order of posts in admin?
wordpress
I'm using <code> add_feed() </code> to create some custom feeds but calls to <code> is_singular() </code> , <code> is_home() </code> etc... just don't seem to work within the callback. Is there a workaround for this? Example code: <code> add_action( 'init', 'my_init' ); function my_init() { add_feed( 'new_feed', 'feed_...
You can only use conditional tags after the <code> posts_selection </code> action hook has run. According to the codex article on add_feed it should be called with the <code> init </code> action, which runs before. Now I don't know when and how you run it, because you don't say so in the above example, but I'd assume y...
Possible to use conditionals within add_feed() callback?
wordpress
How to hide (or not to show, better said) trackbacks on wp-admin/edit-comments.php page? I want to hide the comments with no email (also known as trackbacks) and comments with a specific email from the edit-comments.php page.
While this is not impossible, this is very likely to have ton of edge cases and backfire in some. In a nutshell comments are retrieved with comment query, which can be adjusted with something like this (if in admin and comment type not specified then only fetch normal comments): <code> add_action( 'pre_get_comments', '...
How to hide trackbacks on wp-admin/edit-comments.php
wordpress
I need to create a single post with title, content and excerpt with this command as it's described in the utility documentation. Could you please show me an example of how to use it? I couldn't find nor in official documentation neither on Google. Thanks!
If you type <code> wp help post create </code> you will get all the info you need. Example: <code> wp post create --post_type=page --post_status=publish --post_title='A new page' </code>
How to use command 'wp post create' in wp-cli properly?
wordpress
I'd like to use <code> get_users() </code> to return all users that have a particular meta_key, but I don't want to specify what the value has to be because it will change for every user. The value is a json string. Is this possible?
You can use the just the <code> meta_key </code> argument, the result will be similar to using the <code> EXISTS </code> sql statement. <code> &lt;?php $users = get_users(array( 'meta_key' =&gt; 'your_meta_key', )); </code> Alternatively, you can use an empty string for <code> meta_value </code> (the default) and <code...
Return all users with a specific meta key
wordpress
I'm developing a theme which uses the NHP Theme Options Framework to add some theme options. Naturally, the theme options framework creates a single row in the database to store the theme's options into. If I create a child theme of the parent, it shares the same theme options as the parent, which leads me to my questi...
Neither. Theme options should be stored as theme mods, using <code> get_theme_mod </code> and <code> set_theme_mod </code> . Internally these map on to options, but it is the official way to store theme specific options, that way when you change themes you don't get clashes, and your settings are preserved for if you e...
Should a child theme share the same theme options row as the parent, or should it have it's own options row?
wordpress
I am building a plugin for frontend submission. I am using shortcodes API to display the form for content submission, but I am having troubles. The problem is, wp_editor echoe's data, and shortcode should return data. When I integrate wp_editor like this: <code> $final_form .= wp_editor(); </code> form does render, but...
If a function <code> echo </code> s data, you can use php output buffering to capture the <code> echo </code> ed output and return it instead <code> // Turn on the output buffer ob_start(); // Echo the editor to the buffer wp_editor(); // Store the contents of the buffer in a variable $editor_contents = ob_get_clean();...
Using wp_editor in shortcode
wordpress
I have a pretty common loop: <code> global $wp_query, $wpdb; if ( have_posts() ) { while ( have_posts() ) { the_post(); get_template_part( 'template_parts/content' ,get_post_format() ); } } else { get_template_part( 'no_results' ); } </code> Now I need to add (for example) a <code> &lt;hr /&gt; </code> after each singl...
another possibility: <code> if( $wp_query-&gt;current_post &lt; $wp_query-&gt;post_count-1 ) echo '&lt;hr /&gt;'; </code>
How to add element after every post in the loop, but not the last one
wordpress
I currently display a URL from a custom meta box, but wanted to add a conditional check, so that if nothing has been entered, not to display the link text. <code> &lt;a target="_blank" href="&lt;?php $urlbox = get_url_desc_box(); echo $urlbox[0]; ?&gt;"&gt;Visit Website &amp;raquo;&lt;/a&gt; </code> At the moment, even...
<code> $urlbox = get_url_desc_box(); if ( !empty( $urlbox[0] ) ) { echo sprintf( '&lt;a target="_blank" href="%s"&gt;Visit Website &amp;raquo;&lt;/a&gt;', $urlbox[0] ); } </code>
Conditonally check if Custom Meta Box has input
wordpress
When looking through Wordpress snippets/tutorials/plugins I often see <code> add_action() </code> and <code> add_filter() </code> being placed before the function is declared: <code> add_action('publish_post', 'email_friends'); function email_friends($post_ID) { $friends = 'bob@example.org, susie@example.org'; mail($fr...
It is easier to read: When is what called? If you are debugging a hook you can immediately see if you have to read the function or not: If it is not your hook, you can skip the code. In my themes and plugins I combine all registrations for actions, filters and shortcodes at the top and I add the hook to the PHPDoc bloc...
add_action(), add_filter() before or after function.
wordpress
I am using wp_list_categories to list my categories in my menu. When the menu is generated each category is listed as a <code> &lt;li&gt; </code> -element with "cat-item[number]" as class. Is there a way to also or instead give the <code> &lt;li&gt; </code> s the category name as the class? Just like the posts have the...
I would use <code> get_categories() </code> instead, so that you can have better control over the output of your list. And if I recall correctly, <code> wp_list_categories </code> calls <code> get_categories </code> anyway. You can use the same <code> $args </code> array in either function, and you should get the same ...
Giving wp_list_categories the class of the category
wordpress
WooCommerce includes a handy Layered Nav widget. This allows you to filter the catalog items based on attributes that you've set, including for variations of items (like different sizes.) However, if you select a variation that's out of stock, it is still returned. I've been trying to alter the widget code, but it's pr...
It's not easy, but a colleague and I did it. Some of this is specific to our use case, and it will not be very performant on larger catalogues, but it technically works. As there's not way of telling if this is the case before fetching the items, we display all items on a page and simply display:none on the out of stoc...
How do I stop out of stock items from appearing on my WooCommerce site when using the Layered Nav widget
wordpress
I upload my website to the server and I changed the website url and home from localhost to mysite url. But it still is in localhost if I turned off wampserver it won't show the website. Just show me when wamp server is on. What should i do? any help will be appreciated
Wordpress hardcodes the domain into many of its permalinks in the database. An easy solution is to download an SQL dump of the database on your host using phpMyAdmin or an SQL client, and then opening the SQL file in a (robust) text editor, assuming your database isn't enormous. Then run a Find / Replace for the old do...
website is still in localhost
wordpress
I'm trying to create a function in functions.php that includes the next_post_link() and previous_post_link() without success. It returns empty. My guess is that these don't use the post ID... So what would be the best way to do that so I can store them values in $next_link and $previous_link in the following code? <cod...
<code> &lt;?php function get_all_images($post_id=0, $size='poster', $attributes='') { global $post; setup_postdata($post); $post_id = $_POST['post_id']; if ($post_id&lt;1) $postid = get_the_ID(); $post = get_post($post_id); $get_content = $post -&gt; post_content; $content = apply_filters('the_content', $get_content); ...
Retrieving next_post_link() and previous_post_link() in functions.php
wordpress
I am trying to add the most recent post from another Wordpress database (on the same server in all actuality), but am getting the following error: <code> Fatal error: Call to undefined method wpdb::query_posts() in /var/www/site/wp-content/themes/custom/footer.php on line 68 </code> Here is the code: <code> &lt;!-- .en...
The Wordpress wpdb class is a little different than the normal way of querying in that you run "vanilla" database queries. You can see documentation on the wpdb class on the Wordpress docs: http://codex.wordpress.org/Class_Reference/wpdb#Run_Any_Query_on_the_Database Also, in regard to your code, you should be able to ...
Most recent post from another database
wordpress
I have a custom, well kinda custom wordpress in only one page of my site, the background only displays in Internet explorer, no body or content just background though in firefox it's fine as with other browsers. Reverted back to the original twenty ten and it shows in IE. I know the code is horrible but it was a shot a...
In your initial style declaration that sets the background color: <code> background:#000D37; </code> You have an open HTML comment but no close. Close that and you should be fine.
Custom Wordpress Does Not Display Anything But Background in IE
wordpress
I want to display a different menu depending whether a user is logged into the CMS or not. I'm using this for my menu: <code> &lt;?php if ( is_user_logged_in() ) { $args = array( 'depth' =&gt; 1, 'show_date' =&gt; '', 'date_format' =&gt; get_option('date_format'), 'child_of' =&gt; 0, 'exclude' =&gt; '5, 80, 83, 138', '...
Seems as though the session needed to be destroyed with the following: <code> &lt;a href="&lt;?php $redirect = bloginfo('url'); wp_logout( $redirect, $echo ); ?&gt;"&gt; Logout &lt;/a&gt; </code>
wp_logout logging everyone out instead of just the user that clicked the logout link!
wordpress
I'm building a new design into WP and so technically it is a theme, however it is only a design for one site and won't be a theme anyone can use and hence I don't want to bother with internationalization. I have noticed WP makes use of internationalization in many functions by passing in the <code> textdomain </code> v...
It is only a design for one site and won't be a theme anyone can use and hence I don't want to bother with internationalization. If the theme will only ever be used by you, internationalization isn't a huge deal. Unless, of course, you will want to use a different language version of your theme in the future. However, ...
Internationalization and functions that use it
wordpress
Is there way to use custom validation on an advanced custom field? For example, I might not want a textfield to have a value that starts with certain prefix, or I might want a number field to have a value greater than 'x'. I might also want to run a regex against a value and return an error if it doesn't match.
There is now, I just posted a plugin that I wrote to do validation for Advanced Custom Fields to the Wordpress repository. It lets you do server side validation using either PHP code or regex, jQuery masked inputs, as well as unique value settings. http://wordpress.org/extend/plugins/validated-field-for-acf/
Advanced Custom Fields Validation
wordpress
I was looking at the <code> TwentyEleven </code> code and found this: <code> esc_attr__( 'Permalink to %s', 'twentyeleven' ) </code> This is come code that came out of the title tag for a post; the full code within the title tag being: <code> printf( esc_attr__( 'Permalink to %s', 'twentyeleven' ), the_title_attribute(...
General difference between <code> esc_attr </code> and <code> esc_attr_* </code> The difference between <code> esc_attr() </code> and <code> esc_attr__() </code> , <code> esc_attr_e() </code> , <code> esc_attr_x() </code> is that the later three are just "wrappers" or in other words higher level API functions. When you...
How do translated, escaped strings (esc_attr) in Themes work?
wordpress
With regards to how WP displays "preview" text on the home page, category page etc for each post, how do you stop it from including images in this section. I'm not talking about the featured image for each post, I'm talking about if the post has any included images within the post - I don't want them to show up in the ...
Place following code to your theme <code> functions.php </code> : <code> add_filter('the_content','wpi_image_content_filter',11); function wpi_image_content_filter($content){ if (is_home() || is_front_page()){ $content = preg_replace("/&lt;img[^&gt;]+\&gt;/i", "", $content); } return $content; } </code> From http://wor...
Stop WordPress from showing images on non post pages
wordpress
I am looking for a method to hide or remove WordPress from the login options in Jetpack Comments. I have tried adding <code> a#postas-wordpress {display:none !important} </code> to the theme's style.css, but no luck. Here is a screenshot of the default comment form with Jetpack Comments enabled. Thank you!
Expanding on Shines good find that its an iframe, i came up with this: If you can get a HTML element in next to the iframe (so that its a sibling to the iframe) you could make the parent and the iframe position relative and this new element (we can call the new element blockie) position absolute. now make sure that the...
How to disable or hide WordPress.com as a social media login option for Jetpack Comments
wordpress
I keep searching on how to add an extra field on every WordPress available widget, something like <code> Subtitle </code> after the widget's <code> Title </code> . Is there a way to hook on every available widget?
I know that the plugin Widget Logic does exactly that. Dissecting its code, the excerpt bellow will output a textarea in all widgets. But please note that: this is just a proof of concept, and the "save field" control is not present the best solution is probably making a fork of the plugin and removing the unneeded fun...
How To Add an Extra Field in All WordPress Available Widgets?
wordpress
Is there a way I can list all posts in a specific custom post type and arrange them by the custom taxonomy term attached to them? For example; Taxonmy Term #1 Post Type Post Type Post Type Taxonomy Term #2 Post Type Posty Type Any help would be most appreciated. Thanks.
Try this <code> $custom_terms = get_terms('custom_taxonomy'); foreach($custom_terms as $custom_term) { wp_reset_query(); $args = array('post_type' =&gt; 'custom_post_type', 'tax_query' =&gt; array( array( 'taxonomy' =&gt; 'custom_taxonomy', 'field' =&gt; 'slug', 'terms' =&gt; $custom_term-&gt;slug, ), ), ); $loop = new...
List all posts in custom post type by taxonomy
wordpress
I am inserting an array of terms into my custom taxonomy programmatically. Some terms have parents/children. After each term has been entered, I then insert an array of posts into my custom post type. After inserting each post, I then set each post to it's proper taxonomy terms (parent terms and child terms). After tha...
I asked the same question a while ago. Scribu gave me an answer stackexchange-url ("here"). The long and short of it: after you insert your terms, add this line of code. <code> delete_option("my_custom_taxonomy_children"); </code> Of course, replace my_custom_taxonomy with your own, but leave the <code> _children </cod...
Programmatically insert hierarchical terms & set terms for post causes glitch?
wordpress
I got some code from this site which is going to work great for me. If ound it in another post. What I have modified it to do is add a text box in the category edit area so that the user can input the path to an image. It is working. I have checked the database and I do see the option called "paradiso_category_fields_o...
Remember you need the get_option parameter in quotes, like this: <code> $option = get_option('paradiso_category_fields_option'); </code> and to get the img url out of that database option you presented it would be: <code> echo $cat_image[7]['image']; </code>
help using get_option
wordpress
I'm trying to create a page for each of the categories i got in my blog and it should appear on the menu i got in Chunk theme. the idea is to have a link to each of the categories which would guide you to something like this 'http://blog.direktio.com/category/business-intelligence/' so I found out that wp_nav_menu is t...
after searching around a little, I found that (as you may have noticed) I'm a newbie in wordpress.... there is no need to screw with code to do this I had never seen the "Menus" option in the administration side bar.... so ... go there and create a new menu... from which you can put custom links, links to the categorie...
wordpress 3.4.2 + wp_nav_menu + chunk theme not working
wordpress
I am trying to filter some data based on whether a variable from within the function that calls <code> apply_filters() </code> is equal to specific value. That variable is not passed to the <code> apply_filters() </code> parameters. This might explain what I mean: <code> // function in wordpress core function get_var_b...
Short answer: you can't. You're trying to access a variable outside of its scope. In your situation, <code> $var_a </code> is local to the <code> get_var_b() </code> function, so anything outside of that function cannot see it. This is equivalent to writing this sequence in PHP: <code> function get_var_b() { // This va...
How to access variables in the function where apply_filters() is called?
wordpress
We've had Limit Login Attempts installed for some weeks now, and the number of brute force attempts occurring on wp-admin/wp-login is pretty amazing. At first the attempts were all with the username "Admin," which doesn't exist on our site, so I considered it an annoyance but not much of a threat. However, now we're se...
If you have pretty permalinks enabled WordPress will redirect all calls to <code> /?author=1 </code> to the author archive with the user name, eg.: <code> /author/bob/ </code> . And then the visitor will know the author name. Use Login Lockdown , that plugin does not reset accounts, it will block IP addresses.
Securing Admin Accounts - Username Discovery
wordpress
I'm hoping somebody could help me out with the following issue. I have a wordpress page: http://www.howdesign.com/design-jobs and there is a list of jobs coming from behance.net via JavaScript. When you click on "Next Page" or a specific page number, the URL is supposed to be as follows: /design-jobs/?callback=Joblist....
The <code> redirect_canonical </code> filter is responsible for this, which you can selectively disable depending on the requested page. This is untested, but should work: <code> function wpa66273_disable_canonical_redirect( $query ) { if( 'design-jobs' == $query-&gt;query_vars['pagename'] ) remove_filter( 'template_re...
Disable wordpress pagination URL rewrite for specific page
wordpress
I am using the_posts action to filter out some unwanted posts - this works fine, but the pagination after this is applied gets broken. If for example there is a page with 10 results before the_posts is applied, then after it gets applied the page displays only 6 posts for example, yet there is 100 posts in total and 20...
Instead of using <code> the_posts </code> filter, you should try <code> pre_get_posts </code> action.
wordpress pagination fix after the_posts
wordpress
I want to give linebreak on Wordpress theme's description in <code> style.css </code> (the one in here): <code> /* Theme Name: Theme URI: Description: Author: Author URI: Version: Tags: */ </code> But it appears the formatting doesn't allow any linebreak. When I tried writing on the line below it, the text won't appear...
Is it not possible to add linebreaks in Wordpress theme's description? No. Sorry, to say - the question is valid, but I can't come up with a longer answer. Wouldn't make sense to explain the internals on this topic :)
Is it possible to use line break in theme description?
wordpress
a) I would like the person's username to be included in their activation email once they have registered. e.g. Activation email would look like: Thanks for registering! To complete the activation of your account please click the following link and log in using USERNAME and password you chose: activation link url Or if ...
You can add the username to the activation e-mail by adding this code either to the <code> bp-custom.php </code> or to the theme's <code> functions.php </code> file <code> add_filter('bp_core_signup_send_validation_email_message', 'add_username_to_activation_email',10,3); function add_username_to_activation_email($msg,...
Showing the user's username in registration email or activation page with BuddyPress
wordpress
I´d like to link <code> the_post_thumbnail </code> by using the <code> the_permalink </code> . I do this ( It Works without link ) <code> &lt;?php $args = array( 'post_type' =&gt; 'xyz', 'posts_per_page' =&gt; -1, 'orderby' =&gt; 'rand' ); $loop = new WP_Query( $args ); while ( $loop-&gt;have_posts() ) : $loop-&gt;the_...
That is because you haven't close php before anchor tag <code> &lt;?php $args = array( 'post_type' =&gt; 'xyz', 'posts_per_page' =&gt; -1, 'orderby' =&gt; 'rand' ); $loop = new WP_Query( $args ); while ( $loop-&gt;have_posts() ) : $loop-&gt;the_post(); ?&gt; &lt;a href="&lt;?php the_permalink(); ?&gt;" title="&lt;?php ...
Add Permalink to Post Thumbnail, syntax code issues
wordpress
I'm looking for the add_action() hook for when a current post is edited and saved. I know there's <code> edit_post </code> and <code> save_post </code> , but I'm looking for something that ONLY fires when a current post is edited, not created or altered in any other way.
Not a real answer. Take a look the files that use save_post and edit_post It will lead you to the hook post_updated Take a look and see if you can find a hook you need. Keep in mind that you might need to do some checks in the hook. You'll figure it out.
Action hook for editing post
wordpress
I am not too comfortable coding in PHP yet, but am currently working on a project where I need to create a custom page for the website, in a member area, where the members of the site can capture certain data, like total income for the day, number of calls made during the day, etc. Once this has been done I need to be ...
This is a pretty big project you're talking about.. Using Wordpress as the base CMS isn't necessarily a bad idea as you/an admin could create new users and it would take care of all the logging in procedures. Firstly I would recommend learning how to make basic Wordpress themes. You could try hacking about the default ...
create custom page for statistical data capture and reporting
wordpress
I am currently new to Wordpress development and I am developing a custom theme with a few custom post types and custom functionality. For the most part, it was pretty easy to find the information I need on the Internet and the codex. I am importing an older outdated system (proprietary) into Wordpress and I would like ...
I was able to solve this by using custom post types. I created a <code> Services </code> custom_post_type and I created a template meta box to allow me to assign special templates to the pages. The way this is implemented is: Parent pages in <code> Services </code> are the services we offer. Under the parent page is a ...
How to produce a sub-page-system in Wordpress
wordpress
I have an Editor user that I want to let use a plugin's options without being an Administrator. I can use $user-> add_cap but can't tell if any particular capability relates to the permission to edit plugin options. The plugin in question is Redirection, if that makes a difference.
The part of the capability is the job of the developers of the plugin. But normaly use the most plugins for manage options the object <code> manage_options </code> . But if you will, that your editor only change the plugin options from one plugin, than is this not so easy. All options of the core check for this object ...
Is there a capability for managing plugin options?
wordpress
I have around 2000 custom posts. And 7 regular wp pages. I want to delete all those custom post without effecting the pages. I thought the easiest way would be to empty the custom post table but I dont know how to do it. I am familiar with DB operations but I dont know the schema of wp posts, so have no idea where thes...
I used a custom page template to delete all the post from the wordpress database. Everytime I would go to this page it would delete 300 posts.The code for the page template is: <code> &lt;?php // Get 300 custom post types pages, set the number higher if is not slow. $mycustomposts = get_posts( array( 'post_type' =&gt; ...
How to empty wordpress custom post Database table
wordpress
I've created a custom post type with my requirements. I used "WP Video Gen" as menu label. But I want red marked item to name as "Videos". Is it possible? Ref: http://ScrnSht.com/jcvlhy Thanks in advanced.
When you register your custom post type there's an argument called 'labels' you can pass to <code> register_post_type() </code> . The argument is an associative array with named labels for the menu and screens of your post type. Specifically, the label you are looking for is called 'all_items'. I don't know your code f...
Custom Post Type menu name
wordpress
I'm trying to make a custom template for my category pages that only pulls in post under a specific category. At the moment, I am only able to pull in all post and not category specific... My code so far.... <code> &lt;?php //Identify current Post-Category-ID foreach((get_the_category()) as $category) { $postcat= $cate...
You've already got code to figure out which category you want to show posts from, here is how you would grab all the posts in that category: <code> // create a query to grab our posts in category of ID $postcat $q = new WP_Query(array( 'cat' =&gt; $postcat)); if($q-&gt;have_posts()){ // foreach post found while($q-&gt;...
How only display all post related to category
wordpress
I have created a custom post type for a slider (namely Piecemaker). I can add posts with featured images and descriptions, that can be used with the slider. Also, I have added a taxonomy for actually creating the sliders(sort of like a category that represents the slider ID, used for creating multiple sliders). My prob...
Since you are grouping the slides in a taxonomy then you can add "custom fields" to that taxonomy term. take a look at this tutorial to add te fields to the taxonomy term edit form.
Custom Type add Transitions
wordpress
Customized wp_new_user_notification I'm kind of inexperienced with it comes to editing Wordpress functions, yet i'm currently trying to customize <code> wp_new_user_notification </code> in order to personalize the email that administrators and users receive once they register. I'm aware there's some plugins that allow ...
You can only override pluggable functions in a plugin, not via <code> functions.php </code> . The function is already defined when <code> functions.php </code> is loaded, which is why your overriding function is skipped. Move the code to your own plugin to enable it.
Customized wp_new_user_notification
wordpress
<code> PHP Notice: Object of class WP_Error could not be converted to int in /var/www/vhosts/hayhauler.co/httpdocs/wp-includes/functions.php on line 2568, referer: http://hayhauler.co/ </code> I'm not even sure where to start with this or the right question to ask. I know that it is preventing me from posting some info...
One of the variables you're trying to pass into <code> wpdb::prepare </code> is a <code> WP_Error </code> object. <code> WP_Error </code> 's are like exceptions mixed with return codes: some functions in the WordPress API return WP_Error objects to tell you something went wrong (like <code> get_terms </code> ). We'll n...
WP_Error message
wordpress
I have a custom post type for events. A couple of days after each event photos are sometimes uploaded and attached to the event they were taken at. I want to highlight these image gallerys somewhere on my site, displaying them under a headline "Recently Changed Image Galleries". How can I query posts of type 'event' th...
This should do it for you. If you're calling it in a function, you'll of course need to ensure <code> $wpdb </code> is the global. <code> $required_number_of_attatchments = 3; $posts = $wpdb-&gt;get_col( $wpdb-&gt;prepare( "SELECT posts.ID FROM %s AS posts INNER JOIN ( SELECT MAX(post_modified) AS modified, post_parent...
How can I query posts with newly uploaded images?
wordpress
I did try using the plugin Front End Users but this clashes with something as it prevents access to some front end pages. So I need to manually just set it so that anyone who isn't one of two usernames (or roles) can't access wp-admin.
Plugin It's basically just a user capability check, followed by a redirect in an exit call. It then redirects to the site the request came from. <code> &lt;?php ! defined( 'ABSPATH' ) AND exit; /* Plugin Name: (#66093) »kaiser« Deny Admin-UI access for certain roles */ function wpse66093_no_admin_access() { $redirect =...
How to prevent access to wp-admin for certain user roles?
wordpress
taken on someone elses code and trying to get a clear understanding of just how the comments forms should work. they're being used as feedback for someones visit to the venue, so not as a comment on a post like normal wordpress installations. the comments form looks custom, but i think its fairly standard and it defini...
If you want to redirect the user to somewhere else after they submit a comment, then all you have to do is include a hidden input in your comment form with the name of "redirect_to" and the value of the URL you want to redirect them to. The lines of code you posted show that directly. No need to hack the core code.
how should the comment form really work?
wordpress
This may sound like a stupid / noob question. But I'm curious to wonder as to why you can't insert the wordpress php loop functions outside into say a blog.php file but you can in a index.php file? For instance, when I try running all the loop code in say a blog.php file, and linking the pages up nothing shows. I've ti...
That's because of the Template Hierarchy WordPress uses. The blog.php you're trying to use isn't part of the default templates WordPress uses.
Why cant you place the Loop outside of the index.php?
wordpress
I have multi-site wordpress, I want to redirect the main site to one of the sub-site but redirection in .htacecss gives error. Is there any way to redirect a main site to its sub-site. That looks not possible but I am not a wordpress expert so just verifying. The redirect should be like redirect 301 www.example.com/mai...
You can use the <code> parse_request </code> action to accomplish this. Simply enable this plugin on your primary blog. Place the following code in a .php file and upload it to your plugins directory. <code> /* Plugin Name: Redirect Main Site To Sub-Site Description: Redirect 'main-site' to 'main-site/sub-site/' Versio...
Redirect Main Site to Subsite in Multisite Wordpress
wordpress