question
stringlengths
0
34.8k
answer
stringlengths
0
28.3k
title
stringlengths
7
150
forum_tag
stringclasses
12 values
Is there a place where actions like post creation/deletion, page creation/deletion, modification, etc. is saved? Is this stored in the Apache logs? If this is not saved, is there a way (plugin?) to do this?
There is a plugin called Audit Trail. It will pretty much log all actions for your wordpress backend such as page creation / deletion, post creation / deletion, logging in / logging out. You can find it here: http://wordpress.org/extend/plugins/audit-trail/
Log Author Actions
wordpress
My question is how to force the users that are auto-logged in because they previously checked "remember me" to log in again? It may be something with cookies, but is there anything I can change/modify to do this ? Thank you. UPDATE Generally, using jQuery cookie plugin, the code that checks for a cookie in user's syste...
You can reset the security keys, forcing all cookies to expire and all users to log back in. Edit wp-config.php and change even one character in any of the security strings. There's a plugin that allows you to set the expiry time on your user's cookies. I haven't personally used it, so proceed with caution: Cookie Timo...
How to force "remember me" users to login again?
wordpress
If I want to put a Wordpress (3.2.1) site into Maintenance mode, is it still necessary to use a plugin? If so, is this a good option?
Yes there is. But it is primarily meant for short interruptions (such as during upgrades) and not very user-friendly. WP creates <code> .maintenance </code> file in root (with timestamp info about time) to trigger it and removes after it is done. See WordPress Maintenance Mode Without a Plugin for reference. In practic...
Is there a maintenance mode in Wordpress core?
wordpress
How can I display a different style snippet if a user selects and option from my theme options page select box. For example. To show the sidebar on the right a user would select "Right" and the default stylesheet would be used. However, if they chose "Left" to display it on the left, a small style snippet would appear ...
Just put your dynamic CSS inside of a callback function, hooked into <code> wp_print_script </code> , e.g. <code> function mytheme_custom_css() { ?&gt; &lt;script type="text/css"&gt; &lt;?php if ( of_get_option('show_post_sidebar', true ) ) { ?&gt; .post{width:720px} &lt;?php } ?&gt; &lt;/script&gt; &lt;?php } add_acti...
How to display custom style based on theme option select box
wordpress
I would like to implement a plugin that requires new users to reply to an email, to verify their email address, on registration. I am already doing extensive codex research, but I am very new and would appreciate some hints, especially regarding keeping the user inactive until they have verified their email. The rest I...
I had a very similar problem which I solved the other day. In my case I wanted to allow users to choose their own password, and then activate their account via email. There's alot to this, so I'll just outline how to I achieved the e-mail verification. First, I used <code> user_register </code> (runs when a user is reg...
Email verification for new users
wordpress
I just moved a website from a hosted web server to MAMP and I am getting a strange error. When I visit the homepage I get the default "It works" apache message. the url should be <code> test:8888 </code> but the homepage is being converted to just <code> test </code> To make matters worse all other pages are working <c...
The :8888 is the port your local Apache server is listening on and isn't actually part of the url. To use your own custom domain name locally open up your host file <code> sudo nano /etc/hosts </code> and add this line to the bottom <code> 127.0.0.1 custom-domain.dev </code> Then add your domain to wp-config.php: <code...
Issues when moving from server to MAMP
wordpress
I know this is a fairly common topic around here, but I can't seem to figure out a solution to my particular case from reading similar threads. Basically, my permalink structure needs to be /%postname%/ for compatibility with a finicky plugin. The plugin authors may fix this in the future, but for now I need to come up...
Even though this is no longer a problem for you, I decided to pursue it for purely academic reasons. I got it working by prepending rewrite rules and filtering permalinks. Note that I wouldn't actually recommend doing this, but it's fun to know it's possible :) <code> function filter_post_link($permalink, $post) { if (...
Custom Permalinks for Blog Posts Only
wordpress
My wordpress makes use of custom post templates. I'm now trying to create a custom comments template as well. I noticed that the comments template is called via this function <code> &lt;?php comments_template( '', true ); ?&gt; </code> I checked in my functions.php and comments.php but don't see the function being decl...
The <code> comments_template() </code> template tag sets up the commenting variables and functions, and includes the <code> comments.php </code> template-part file. So, to create a custom comments template, use <code> comments.php </code> . From there, you will need to get comfortable with the arguments, filters, and c...
How to use a custom comments template
wordpress
Currently I have this code <code> $tag_list = get_the_tag_list('&lt;ul&gt;&lt;li&gt;','&lt;/li&gt;&lt;li&gt;','&lt;/li&gt;&lt;/ul&gt;'); </code> and outputs: <code> &lt;ul&gt; &lt;li&gt;&lt;a href="tag_link"&gt;tag_name&lt;/a&gt;&lt;/li&gt; .... &lt;/ul&gt; </code> How can I change it so it displays like this? <code> &...
So, from the <code> get_the_tag_list() </code> Codex entry: $before (string) (optional) Leading text. Default: 'Tags: ' $sep (string) (optional) String to separate tags. Default: ', ' $after (string) (optional) Trailing text. Default: None Since you're using this example: <code> get_the_tag_list('&lt;ul&gt;&lt;li&gt;',...
How do I change the output of get_the_tag_list()?
wordpress
I built a navigation menu using the native menu builder in WordPress 3. This is the code I use to render it: <code> &lt;?php wp_nav_menu( array('menu' =&gt; 'Main Navigation','menu_id'=&gt; 'headernav','menu_class'=&gt;'navigate')); ?&gt; </code> It renders exactly the way I would expect on every page except 404.php. T...
This isn't an answer necessarily, but after some more research I found these threads: http://wordpress.org/support/topic/custom-menu-not-displaying-on-404-error-page http://www.prettyscripts.com/software/wordpress/wordpress-custom-menu-not-displayed-on-404-page There is some conflict or bug that causes custom menus to ...
Why do I have a weird rendering issue only on 404.php caused by wp_nav_menu?
wordpress
is there a way to set the order of posts via the url? /orderby/date/order/desc/ i have tried several things with add_rewrite_rule whiteout success. <code> add_action( 'init', 'wpse13483_init' ); function wpse13483_init() { add_rewrite_rule( 'category/(.+?)/orderby/([^/]+)/order/([^/]+)(/page/?([0-9]{1,}))?/?$', 'index....
adding this in the functions.php file works. Just remember to re-save your permalinks &amp; empty the cache a few times to see the changes. <code> add_action( 'init', 'wpse13483_init' ); function wpse13483_init() { add_rewrite_rule( 'category/(.+?)/orderby/([^/]+)?/?$', 'index.php?category_name=$matches[1]&amp;orderby=...
Define orderby in url
wordpress
Is is possible to paginate the get_users function with the "offset" parameter? I have complete my custom query of users for my list and now I need to paginate the results into multiple pages. Here is my sample code: <code> &lt;ul&gt; &lt;?php $args = array( 'meta_key' =&gt; 'jabber', 'meta_value' =&gt; 'User Name', 'me...
<code> $args = array("role" =&gt; "subscriber", "number" =&gt; 10); get_users($args); //First 10 Users with the Role Subscriber $args['offset'] = 10; get_users($args); //10th to 20th Users with the Role Subscriber </code> and so on. Offset = page * number
How to use "offset" to paginate get_users?
wordpress
<code> The uploaded file could not be moved to /var/www/wp-uploads/localhost/2011/10. </code> That's the error message I get when I try to upload a wordpress theme. This is my current permission status of my folder. <code> $ sudo ls -la /var/www/wp-uploads/localhost total 12 drwxrwxr-- 3 root www-data 4096 2011-10-27 1...
From quick search of source for this error message, it is likely to be triggered by failed <code> move_uploaded_file() </code> function call, which is native PHP and not WordPress. Documentation says that it has some restrictions, related to <code> safe_mode </code> and <code> open_basedir </code> so that might be your...
Cannot upload themes. Error: "The uploaded file could not be moved to /var/www/wp-uploads/localhost/2011/10."
wordpress
i will star with some back ground and my goal before i gt to the point i am trying to make a anime viewing website using wordpress like www.watchanimeon.com and www.animedreaming.tv i tried a couple of techniques like tiring to use custom fields to store data but of no avail as they all got way too complected for a lit...
If i understand right you want to create relations between custom post types, you can achieve this with this plugin http://wordpress.org/extend/plugins/posts-to-posts/ after installing go to your functions.php and setup relations <code> &lt;?php function my_connection_types() { // Make sure the Posts 2 Posts plugin is ...
how to use custom post types collectively integrated with each other
wordpress
is there a way to hook / filter or add action that would be printed in the wp-config file? lets say i want to add some simple command like "empty the trash" aka <code> define('EMPTY_TRASH_DAYS', 1 ); </code> This should be changes in the wp-config but i want it to go with theme.. Any way to do that?
There is, as far as I know, no way to hook into <code> wp-config.php </code> from a Theme. For one, <code> wp-config.php </code> shouldn't be writeable; for another, <code> wp-config.php </code> is executed well-before a Theme's <code> functions.php </code> file is parsed . For a great overview of how WordPress boots, ...
hook a functions to change wp-config from functions.php
wordpress
I have a WP multisite installation. All the posts for the default blog are in the subdirectory /blog. All those URLs are fine, all the category and archive links work well. However, visiting the "www.domain.com/blog/" URL leads to a 404. Is this expected behaviour? I thought it might be something to do with my particul...
Normal. Make a page called "blog" and use a blog page template and it works. Proof: http://atypicalife.net/blog/
Multisite: should /blog go to a 404 page?
wordpress
I know I'm probably doing something dumb here but I just can't get this to run. I'm trying to set up a little API for my plugin and to create a class to display admin notices a little easier. Here's what I have: <code> // Send data to class to get HTML for admin notice $efpd=Efpdd::getInstance(); $plugin_update = $efpd...
Try this. I cleaned up your arg array and placed everything in a function. Also, why are you using the getInstance method when your efpd_admin_notice is public? See the code below for accessing this method properly. <code> function plugin_update(){ $plugin_update = Efpdd::efpd_admin_notice(array( 'type' =&gt; 'update',...
admin_notices not displaying in plugin
wordpress
I'm using the following code to deactivate my WordPress Plugin if the requirements are not met <code> public function activate() { if (!$this-&gt;check_requirements()) { deactivate_plugins(plugin_basename(__FILE__)); wp_redirect(admin_url('plugins.php')); exit; } } </code> The function activate() is called when the plu...
Actually, there's a better way. All of my plugins require PHP5. Until recently, that wasn't a requirement in WordPress, so a lot of people tried to install my plugins on systems missing vital PHP functions. I added some checks to my plugin to make sure it would work and, if not, display a message. But I keep the plugin...
Displaying a message when plug-in is deactivated
wordpress
The code I am currently using in the loop is in this code snippet: https://gist.github.com/1316622 This just seems messy, and long. I am thinking the best method would really be to use CSS sprites and the post class, but for some reason I cannot put my brain around how to do this. I created another gist of the output o...
Using CSS and image sprites is exactly what I do in Oenology. ( See it in action here .) Mine is a bit tricky, because I change the post container based on post-format type (some have post headers/titles, others don't; some have left/right margins added; etc. - also, I have dark and light icon sets, based on the color ...
Displaying icon image for WordPress post formats, is there a cleaner way to do this?
wordpress
I am developing a theme for general release and there is a large content slideshow on the homepage. I have included a checkbox meta box in the post edit screen that allows users to determine which posts are featured in the slideshow but I can't figure out exactly how to create a query for this. The checkbox relates to ...
You can filter on meta values using <code> query_posts() </code> or a <code> new WP_Query() </code> for example: <code> query_posts( array( 'meta_key' =&gt; 'slideshow', // the custom field key to check 'meta_value' =&gt; '1', // the value eg. 0 or 1 'meta_compare' =&gt; '=' // check for equivalence ) ); // your loop g...
Only show content slideshow if "slideshow" custom field exists
wordpress
I've been using this snippet to generate a list of recent posts from particular categories in a widget. I'm currently restructuring the site using custom post types and taxonomies and want to generate a list of recent posts from 3 custom post types, taxonomies and categories don't have to be part of the query at this s...
You can use custom variables ( <code> $recentPosts </code> ) like this: <code> $recentPosts = new WP_Query(array('showposts' =&gt; 9, 'post_type' =&gt; array('mycustomposttype1', 'mycustomposttype2','mycustomposttype3'))); while( $recentPosts-&gt;have_posts() ) : $recentPosts-&gt;the_post(); the_title(); endwhile; </co...
Create a list of recent Custom Post Types posts
wordpress
I'm very new to WP, and from following books and online examples, I have several different 'esacping' functions in my first plugin. I would like to know if there is one function, or a minimal set of functions, I can use to prevent malicious HTML stored in my DB from doing anything bad. I would, however, always like to ...
Well, I would start with the one called <code> esc_html() </code> . EDIT Longer answer: You should perform sanitization on input , and escaping on output . To sanitize HTML content on input , I would use one of the <code> kses() </code> family of filters - particularly, <code> wp_kses_post() </code> , which will filter...
What function can I use consistently to escape possible HTML for editing and display?
wordpress
i'm trying to add a user login system in my wordpress as like regular php sites. when a user logged in then , i wanna show the specific page content otherwise no. Is there any process to add nice registration and login system in wordpress and no back end access also ? thanks
To block users from WordPress back office, you may use this plugin. To show specific page content after login, you need to hook through the redirection filter after login and redirect them to that page directly. If you don't want to write code for it, there is a plugin also.
how to add user registration and signup in wordpress and create members only page?
wordpress
This search.php shows all the results from a said search however, doesn't include the title, The Search Results For...... and search query amount; or even the no searches found and prints the searchform. <code> &lt;?php get_header(); ?&gt; &lt;?php if ( have_posts() ) : ?&gt; &lt;h1 class="page-title"&gt;&lt;?php print...
I see at least two potential issues: You have <code> if ( have_posts() ) : </code> twice. Here: <code> &lt;?php if ( have_posts() ) : ?&gt; &lt;h1 class="page-title"&gt;&lt;?php printf( __( 'Search Results for: %s', 'nothing' ), '' . get_search_query() . '' ); ?&gt;&lt;/h1&gt; </code> And here: <code> &lt;ul id="post-l...
Why does this search.php not work?
wordpress
This is my category / archive page i want to include a template before loop but i cant get posts based on category, it showing latest post only on every page. when i removed this line before the loop <code> &lt;?php include( TEMPLATEPATH . '/includes/tb/hot_posts.tpl.php' ); ?&gt; </code> it work smoothly, but i need t...
try and add <code> &lt;?php wp_reset_query(); ?&gt; </code> at the end of your template. http://codex.wordpress.org/Function_Reference/wp_reset_query
Include template before a loop
wordpress
I am trying to set up an image menu to show "all posts", "all videos" (custom post type: rich_media). I want to have an individual image for each post type, and by clicking it I want to show all posts in the current category of the chosen post type. All post_types share the common categories taxonomy. I managed to list...
<code> function add_post_type_to_archives($query) { if(is_archive() and empty($query-&gt;query_vars['suppress_filters'])){ $query-&gt;set('post_type', array('post', 'rich_media')); } return $query; } add_filter('pre_get_posts', 'add_post_type_to_archives'); </code> For a custom post type to be shown in archives, it nee...
How to add a link(href) so when i click it, it renders (shows all) posts of custom post type (rich_media), from the current category?
wordpress
Im using swish-e to index my corporate site and documents. Problem is that i need to login to wordpress via get variables. Wordpress login uses post variable but i need to login with GET variables http://mysite.com/wp-login.php?log=username&amp;pwd=password There is any easy way to do it? I dont mind changing core file...
Using GET variables for usernames and passwords is never a good idea. But anyway, something like the following should work <code> if(isset($_GET['log']) &amp;&amp; isset($_GET['pwd'])){ $creds = array(); $creds['user_login'] = $_GET['log']; $creds['user_login'] = $_GET['pwd']; $creds['remember'] = true; //Do you want t...
login to wordpress with Get variables instead of Post
wordpress
I'm using Wordpress Version 2.8 (Can't upgrade where I work) ; and I used 'Emerald Stretch' theme as the basic bone structure of what I'm developing. (Which ultimately will be a responsive wordpress theme, using css3 media queries, and a rotating jquery banner underneath the header and ideally I'd be able to use this o...
The warning is telling you that you need to chmod (the permissions) the folder to 777 via your ftp client. This will enable the plugin to read, write and execute to the folder on the server.
Error with Image Slide plug-in/ s3slider in WP
wordpress
this is my code in Custom page Template <code> &lt;?php query_posts('showposts=8'); ?&gt; &lt;?php $count = 1; if (have_posts()) : while (have_posts()) : the_post(); if($count == 1) : ?&gt; </code> &amp; this is wp_pagenavi code <code> &lt;div class="more_entries"&gt; &lt;?php if (function_exists('wp_pagenavi')) wp_pag...
Looks like Old Famous Problem with <code> paged </code> try this for <code> quey_posts(); </code> <code> $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; query_posts(array( 'posts_per_page' =&gt; 8, 'paged' =&gt; $paged ) ); </code>
WP-PageNavi not working on Custom page Template
wordpress
I hope i can explain this right , what im trying to do is use the default word press loop to show all my posts etc.. but for the first post I would like it to be styled completely different depending on what parent category it was published in, so there would be a lot going on in that first post. Right now I'm some wha...
one loop with a conditional statement to catch the first post should work; example: <code> &lt;?php if( $wp_query-&gt;current_post == 0 &amp;&amp; !is_paged() ) : ?&gt; /*the output of the first post*? &lt;?php else : ?&gt; /*the output of all other posts*/ &lt;?php endif; ?&gt; </code>
How to make the first post in the loop be styled like a "new / featured" post?
wordpress
Without using plugins, how to create a custom WordPress navigation menu with the code? I have Wordpress ver 3.2.1 and Buddypress ver 1.5.1 I would like to create a menu. I would like to place the buddypress menu navigation items into one item (social). when you pass the mouse over this item it appears the buddypress me...
Well first of all you can use the menu feature in the newer WordPress. First you want to activate the fact that you want to use this feature via your functions.php file. <code> // This theme uses wp_nav_menu() in two locations. register_nav_menus( array( 'primary' =&gt; __( 'Primary Navigation', 'your_theme_name' ), 's...
How to Create a Custom WordPress Navigation Menu with the Code?
wordpress
I'd like to make a site about choirs, composers, conductors and singers. And so far I decided that I need to make a custom post type for "piece" -- any piece can be associated with choir[s], composer, conductor and singer[s]. I could do this with taxonomies (tags), assigned to every "piece". But I need to be able to wr...
You only need to define two post types: 'piece' and 'person' and a connection field 'role'. See https://github.com/scribu/wp-posts-to-posts/wiki/Connection-information
how to interconnect custom post types?
wordpress
I am sorry if this is stupid. I can't seem to figure out what special things it does. If I embed a youtube video(embed/iframe) it works for both standard and video format. Surely, I am missing something...
Couple of things to point out actually: It will add a class on <code> post_class() </code> so you can use different formatting via css. In the case of Post Formats, the taxonomy is <code> post_format </code> and the terms are <code> post-format-{format} </code> . i.e. <code> taxonomy-post_format-post-format-link.php </...
What difference does it make if I enable support for video post format?
wordpress
Is there a function in the wordpress api that lets me programatically add pages ? something on the lines of : <code> add_page($title,$content) </code> Is there such a function ?
Yes, it's <code> wp_insert_post() </code> .
Add a new page to wordpress programmatically
wordpress
We are trying to rethink how a blog is laid out, by using Tags as primary headers for each post, instead of Categories. In order to do this, we have to set a Tag for the post as Primary. So, we are trying to read the Tags as they are input into the Post Tags widget in the Post Admin, by using Javascript to read the AJA...
Looks like someone on on of my listserves provided the answer: He said to, "use innerHTML() within your ajax callback function. It looks like you're using jquery, so use the .load() function." I checked on the jquery site and it said .innerHTML is .html in jQuery, so we'll go with that then and see if we can pull the A...
How to make a Post Tag primary?
wordpress
In WordPress, I have a page for News that is using a specific page template I created. This page is populated by news posts assigned to the news category. I need to show only two of the latest news posts on this page with Previous / Next links at the bottom if users want to read more news. However, the next / previous ...
When you perform a custom query such as this one, you have to do a bit of a "hack" to get pagination to work properly. Change this: <code> &lt;?php query_posts( "category_name=news&amp;orderby=date&amp;order=ASC&amp;posts_per_page=2" ); ?&gt; </code> ...to a <code> WP_Query </code> call: <code> &lt;?php $news_query = n...
Posts archive index pagination in a static page custom query
wordpress
I have <code> [gallery] </code> inside the post, and I'm interested in a way to add already existing images from media library in to this gallery? once I trying add any image I have only one option - insert into post. Thanks in advance, Dmitry
By default, you can't. Galleries are tied to posts, and only to posts. Options: Insert the gallery from any arbitrary post, via <code> [gallery id="123"] </code> where <code> 123 </code> is the ID of the post. Create a custom filter for the <code> gallery </code> filter hook, whereby you query/include the images that y...
Add existing images from Media Library in to custom gallery
wordpress
I have two pages where I want to use galleries with the same pictures (those pages are in different languages). Is there any way to create a gallery with already uploaded images in the other post. By default it's not possible. maybe there is a plugin for this purpose? Thanks!
You can use the default Gallery Shortcode within your post by specifying a post ID. <code> [gallery id="123"] </code> ID == the original post the photos to which the photos are attached. Hope this helps.
Reusing pictures in gallery from other posts
wordpress
I've created a menu using wp_nav_menu in my theme using the most simple setup as possible: <code> wp_nav_menu( array( 'theme_location' =&gt; 'my_theme_top_menu') ); </code> And in my functions.php: <code> register_nav_menus( array('my_theme_top_menu' =&gt; 'Top Menu' ) ); </code> However, I'm running into strange behav...
Here's the default usage of <code> wp_nav_menu() </code> : <code> &lt;?php $defaults = array( 'theme_location' =&gt; , 'menu' =&gt; , 'container' =&gt; 'div', 'container_class' =&gt; 'menu-{menu slug}-container', 'container_id' =&gt; , 'menu_class' =&gt; 'menu', 'menu_id' =&gt; , 'echo' =&gt; true, 'fallback_cb' =&gt; ...
Arguments ignored/markup changed in wp_nav_menu if no menu is selected
wordpress
In my theme I provide an option for users to set a 'blog category' that queries and displays only posts from that category on <code> index.php </code> using <code> WP_Query </code> : <code> $shortname = get_option('of_shortname'); $cat_option = get_option($shortname.'_cats_in_blog'); $catid = get_cat_ID($cat_option); $...
For your second example, I think you're initiating your Loop incorrectly. You're declaring <code> $query </code> , which hasn't been globalized? <code> // Search is working, querying is not global $query_string; // required $posts = query_posts($query_string.'&amp;posts_per_page=3&amp;cat=$catid'); while ( $query-&gt;h...
Search breaks when querying main loop for category
wordpress
I am working on anew blog. I am logged in as administrator, and above every post there is a option to 'edit this entry'. Can I have WordPress set up so that even is I am logged in as administrator, I will still view the front end of the website as if I was not logged in. This was I can see how the user would see the pa...
See this stackexchange-url ("related question"). You should be able to add this code to your themes functions.php <code> add_filter( 'edit_post_link', '__return_false' ); </code>
How To View Site from Non-Logged-In User's Perspective
wordpress
I want to make a custom feed page* with the slug of 'feed', but when I try to save, Wordpress changes it to 'feed-2'. Is there a way I can force Wordpress to let me use a slug of feed—or, if it's better practice, to hook my custom feed template* into the default Wordpress RSS feed generator? If the latter, what code do...
That's because "feed" is a reserved term (actually wp_unique_post_slug will match your page name against the rewrite rules). You might be able to change this by removing the WP feed on <code> init </code> : <code> unset($GLOBALS['wp_rewrite']-&gt;feeds[array_search('feed', $GLOBALS['wp_rewrite']-&gt;feeds)]); </code> (...
Wordpress won't let me use a page slug of 'feed'
wordpress
Okay, so you know how you can break up a wordpress post by inserting the next-page/page break quicktag. Then, using the wp link pages function in your template, wordpress will generate page 1, 2, 3, etc. links for your now paginated post. Great. But is there any way to put the post back together again? Think about all ...
Yes, it is possible, and I use it on my own site. Here it is in action: my Settings API post is paginated, but can viewed on a single page , using the "Single-Page View" link. First, you need to prepare a custom query variable, e.g. in <code> functions.php </code> , add the following: <code> function cbnet_parameter_qu...
Single Page View for Paginated Posts
wordpress
I've created a custom post type with 2 custom fields attached to it... When I create a post of this type and fill in the custom fields, the data is, in fact, saved to the db... However, if I trash one of them, then that post's custom fields data is deleted from the database. I thought trashing was just supposed to basi...
It seems that the action save_post gets fired when sending a post to the trash... Therefore, my custom metadata save function was being activated with no $_POST data to send thru it. To circumvent this, I wound up adding a nonce to the save function. <code> function wpg_testimonial_author() { global $post; $custom = ge...
Custom field values deleted when trashing custom post type
wordpress
I can get the permalink of a specific post tag or category, but what if I want to get the permalink of a custom post type? I can't find anything in the Codex or anywhere else about how to do this.
How about <code> &lt;?php get_post_type_archive_link( $post_type ); ?&gt; </code> , where <code> $post_type </code> is your post type? Further reading: Codex
How do I get the permalink of a custom post type?
wordpress
Hi I am trying to figure out on how to get the "view" link on the manage posts / custom post types and pages to open in a new tab or window. I know it is probably possible to do via the functions.php file of the theme and would much rather go that route than using a plugin. Any help with this would be appreciated. Than...
Late answer WP core offers a function for that case, that makes it much easier and future proof: Simply map it on each item. Wrapped up in a plugin Best used as mu-plugin. <code> &lt;?php /* Plugin Name: (#32093) »kaiser« Open "action"-links in post type list screens in new windows/tabs */ function wpse32093_link_targe...
Is there a way to have the view link on manage posts page to open in a new window or tab?
wordpress
I've created a class to dynamically create pages. I'm checking to see if the page exists by comparing the new page's title to <code> post_name </code> . The comparison seems to work ok, but even if there is a match the page is created anyway and I can't figure out why. My code looks like this: <code> class createDynami...
Why are you comparing <code> $post-&gt;post_name </code> to <code> $this-&gt;title </code> ? You should be comparing slug to slug . Try changing your comparison from this: <code> if( strtolower( $page-&gt;post_name ) == strtolower( $this-&gt;title ) ) </code> ...to this: <code> if( strtolower( $page-&gt;post_name ) == ...
Check to see if page exists problems
wordpress
On index.php page, I am showing only thumbs and two custom fields. How can I set specific number of posts in one row like this one; http://www.whatmobile.com.pk
Step 1 : build a Loop that loads the posts you want. Note: you can number the limit of results using the <code> posts_per_page </code> parameter. Step 2 : style the posts using CSS. Give each post box a width and float them to the left.
Display posts in row Horizontally
wordpress
How do I get the page title of the upper most parent page of the page the visitor is currently on? Let me describe: I have this page structure: Example Title 1 Example Title 1-1 Example Title 1-1-1 Example Title 1-1-2 Example Title 1-2 Example Title 2 Example Title 3 Example Title 4 Here is what I want to return: User ...
Found this way: <code> if ( 0 == $post-&gt;post_parent ) { the_title(); } else { $parents = get_post_ancestors( $post-&gt;ID ); echo apply_filters( "the_title", get_the_title( end ( $parents ) ) ); } </code> Anyone got a better way please answer.
Get top level page parent title
wordpress
I want to rename "Widget" to something else Like "Block" or something else. please help me. EDIT Per the user's comment below, she wants to change <code> class="widget" </code> to <code> class="block" </code> (or any arbitrary class name) in the rendered, sidebar Widget.
The classes assigned to rendered Widgets are specified by the argument array passed to the <code> register_sidebar() </code> call used to register the sidebar. e.g.: <code> &lt;?php $args = array( 'name' =&gt; sprintf(__('Sidebar %d'), $i ), 'id' =&gt; 'sidebar-$i', 'description' =&gt; '', 'before_widget' =&gt; '&lt;li...
How to rename wordpress Widget
wordpress
The Question ::: This is a strange question but I need to add content to <code> content() </code> in <code> page.php </code> . How do I do this? The Why ::: You see there's a plugin that uses the [plugin id="1337"] and I am linking this id with user ID so the ID needs to be dynamic and then added to the content of the ...
<code> // Hook into the_content filter here function append_to_the_content($content){ ob_start(); // Start doing stuff here ... // End doing stuff here ... $new_content = ob_get_clean(); return $content.$new_content; // Append new content return $new_content.$content; // Prepend new content } // function append_to_the_...
Add Content to Content()
wordpress
I'm on a server that does not have FTP installed and will not have FTP installed. I have another website that I've been able to install plugins in before, including the one I'm trying to install now (WP-PageNavi). Does anyone have a list of standard permissions for WordPress that they use themselves so that they don't ...
Standard permissions for most WordPress installations is 755 for directories and 644 for files. For media uploads, auto plugin installation and updates the directories need to be owned by the same user PHP is running under. Usually this is nobody:nobody or www-data:www-data.
Standard permissions for wordpress; Plugin installation asks for FTP credentials
wordpress
I'm creating a template, and one of the files is getting overloaded with pig-ugly mixed html and php. At first I thought that maybe I should cut out chunks of the code, and call them using include(). Then I thought - maybe there is a wordpress way to do things. Perhaps I should abstract out my logic from the templates,...
This is personal preference and there are many ways it can be done. I like to keep my templates as clean as possible and use get_template_part() to include the various parts. For parts of code that is used often I like to create functions and call the functions in the templates.
How can I abstract code out of a template by using functions.php
wordpress
WP provides a function to insert terms: <code> &lt;?php wp_insert_term( $term, $taxonomy, $args = array() ); ?&gt; </code> I have 60 $terms, each has its own $args, I want to prepare the 60 terms as an array, then, insert them at once. Is this posible? How?
As far as the codex for wp_insert_term says , it is not possible to insert an array directly. Put all your terms in an array, then foreach over it and inside every turn, call <code> wp_insert_term </code> once per term.
How to insert an array of terms using wp_insert_term?
wordpress
Scenario: I have a mother site <code> example.com </code> which has a blog and say about 12 category. I also have 12 other wordpress site. Some in the subdomain of <code> example.com </code> and some are different domains. 12 Sites represent 12 category. When I Post on a category the post should be also posted to a app...
It really depends on where you want your focus to be. Here's a case for and against each: XML-RPC It sounds like your standard process is: Log in to main site Write post in X category Publish post Post is copied to the child site specific to X category In this setup, XML-RPC makes the most sense. You write a post on on...
Help Me Choose RSS or XML-RPC
wordpress
I am working with site that is done with WordPress, and I need to add some parts that are outside WP, and to check user login, Logging users outside WP. I tried with md5 of password but it's not... I tried this code: <code> require_once( 'wp-includes/class-phpass.php' ); $wp_hasher = new PasswordHash( 8, TRUE ); $passw...
Based on your other question ... it sounds like you're trying to validate a given plaintext password against what's stored in the database. Here's the function WordPress uses to do just that: <code> function wp_check_password($password, $hash, $user_id = '') { global $wp_hasher; // If the hash is still md5... if ( strl...
How to validate WordPress generated password in DB using PHP?
wordpress
I have a custom theme that displays the excerpt: <code> $data = get_the_excerpt(); if ($data) echo "&lt;div class='excerpt'&gt;$data&lt;/div&gt;"; </code> if nothing is entered in the excerpt field in the post editor, Wordpress will automatically use the auto-generated teaser . I would like to get rid of this behaviour...
Try using <code> $post-&gt;post_excerpt </code> instead: <code> // globalize $post, just in case global $post; // find out if the post has a defined excerpt $data = $post-&gt;post_excerpt; // If so, output something if ($data) echo "&lt;div class='excerpt'&gt;$data&lt;/div&gt;"; </code> This method will bypass the auto...
Disabling automatic teasers
wordpress
I've taken over the maintainance of a large WP-MS powered site. The site has ~200 templates, many page specific, and with no standard naming procedure. It would save a lot of time if while surfing around the site I can see the template names which make up the current page. Is this possible? I've looked at the debug plu...
this is also a quick way; <code> &lt;!-- &lt;? print_r( debug_backtrace() ) ?&gt; --&gt; </code> paste it just before the closing tag
Print WordPress template filename(s) for debugging
wordpress
I'm setting up a multi-language blog using WPML. I works well using the button to change the language. Is there any way to automatically jump according to the Browser's language? My WPML version is 2.0.4.
yes under, WPML--> Languages---> Browser language redirect. Select one of the 3 options and hit "apply".
How to Automatically jump to the corresponding language of the page using WPML plugin in wordpress
wordpress
I have a difficult post a page problem. I have this code : <code> function wpse31701_4filter_query() { global $wp_query; // Check year and month $wp_query-&gt;set('orderby', 'date'); $wp_query-&gt;set('order', 'ASC'); if ( $wp_query-&gt;get( 'year' ) == 2005 and $wp_query-&gt;get( 'monthnum' ) == 9 ) // Check page numb...
"The problem I have it that on the first 8 pages only 1 article is displayed." That would be due to this line of code: <code> if ( $wp_query-&gt;get( 'paged') &lt; 8 ) { $wp_query-&gt;set( 'posts_per_page', 1); } </code> See here for more info: codex.wordpress.org/Class_Reference/WP_Query#Pagination_Parameters EDIT: Tr...
another post a page problem
wordpress
I'm trying to display the Next/Prev navigation buttons on my page which displays all of the pages within my 'events' custom post-type. The issue is that the buttons are not even displaying, but I have no idea why not. I have had this working with my Blog page posts, but I wonder whether there is something different I n...
<code> next_posts_link() </code> and <code> previous_posts_link() </code> use the global <code> $wp_query-&gt;max_num_pages </code> to determine if there are more pages. since you're using a new instance of <code> WP_Query </code> , the <code> $wp_query </code> global does not relate to this new query. Try explicitly p...
Display Next/Prev when looping Custom post-types archive?
wordpress
I have a form in WordPress with options when clicked they retrieve a filtered posts. I want to take the options from the form and place it like normal links. Can this be done? Thank You all in advance :) <code> &lt;form action="" method="get" id="filter"&gt; &lt;select id="sort_by" name="sort_by" onchange="this.form.su...
Yes. First of all, to be able to highlight the current sorting method, we attempt to retrieve if the GET variable <code> sort_by </code> occurs in the url: <code> &lt;?php switch ($_GET["sort_by"]) { case 'most_recent': $active = 'most_recent'; break; case 'most_favourite': $active = 'most_favourite'; break; case 'most...
How to take options from form fields and turn them in to links?
wordpress
I'm using the code below in order to remove all classes but the current-menu-item and current-menu-parent classes from the custom menus. It works very well, however, there's one nagging issue I'm trying to overcome. Some menu items end up with empty class attributes: <code> &lt;ul id="menu-site-menu" class="menu"&gt; &...
Unfortunately there is no filter which can overcome this issue. You have to override the start_el function of the walker . Here is the original source: <code> $class_names = join( ' ', apply_filters( 'nav_menu_css_class', array_filter( $classes ), $item, $args ) ); $class_names = ' class="' . esc_attr( $class_names ) ....
Problem with empty class attributes when running a filter on nav_menu_css_class
wordpress
I'm working on a site that has a fairly large page structure a few levels deep - in some sections there are a lot of pages. The basic setup is something like this... Parent Parent Parent -Child -Child --Grandchild --Grandchild --Grandchild ---GreatGrandchild -Child -Child --Grandchild --Grandchild --Grandchild ---Great...
This should work, using nothing more than the available argument-array parameters for <code> wp_list_pages() </code> : specifically, <code> depth </code> and <code> child_of </code> . To display one level of hierarchy, for descendant pages of the current page: <code> &lt;?php // Globalize the $post variable; // probabl...
Show just one level of child pages, wp_list_pages woe
wordpress
I'm trying to add a sidebar loop to list 3 news post. I'm using thematic framework and since I don't find any hook to use I first write this function in functions.php <code> function sideloop(){ global $post; echo '&lt;div id="side-News"&gt;&lt;ul&gt;'; // The News Query $args = array( 'numberposts' =&gt; 3, 'post_type...
I think the problem is that you're calling <code> get_post() </code> (note: singular ) instead of <code> get_posts() </code> (note: plural ). EDIT Other problems: The <code> get_posts() </code> function uses the <code> category </code> array key, rather than <code> category_name </code> . The <code> category </code> ar...
Sidebar loop - Thematic Framework
wordpress
I am setting up a wordpress blog on a Ubuntu LAMP with ispconfig 3 and freedns.afraid.org. I have everything set up, can log in to domain/wp-admin to create posts, etc. But the blog views as the "Welcome to your website!" ispconfig page. What should I check to figure out what is wrong? Thanks!
Delete or rename index.html as it's the default file served if it's available. This should then allow the server to start displaying your site files.
All posts display default index.html
wordpress
I'm trying to use the search query along with an array of arguments to narrow down search results, but I'm failing horribly. This is what I have so far. <code> $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; $query_string = 's=test&amp;category=wordpress' $s_array = array( 'post_type' =&gt; 'blog', 'cal...
I'd suggest not using <code> $query_string </code> to simplify things. If you're using an array, stick with the array form for the query variables: <code> global $wp; $paged = ((int)get_query_var('paged')) ? (int)get_query_var('paged') : 1; $s_array = array( 'post_type' =&gt; 'blog', 'caller_get_posts' =&gt; 1, 'paged'...
Working with query_posts ( arrays and query strings)
wordpress
I seem to have exhausted all the references on this subject, but if this is a duplicate post my apologies. I am having a problem where ANY custom post page displays the 404.php file's error content, regardless of method of getting there. This includes simply going to something as rudimentary as http://domain.com/?p=123...
As soon as I was done asking the question, I went to close functions.php for the night and happened to notice the custom post types were being registered along with other admin-specific features inside an <code> if (is_admin()) { </code> evaluator. Taking them out of that did the trick. Reasonably enough, it looks like...
Unusual Custom Post 404 problem (NOT a permalink issue)
wordpress
I need to extend some wp tables (wp_posts, wp_comments, wp_users) to store some additional fields. I can't use metadata because I need to query those values directly via MySQL. I need an help to choose if it's better to extend the original table or to define an additional one with those fields, with a 1-1 relationship ...
The second approach (joining additional table) is better for several reasons. When plugin is not active, you won't retrieve it's data (or with other words, you won't select additional data unless you explicitly join it) It's more maintainable. You can alter your plugin table without altering posts table and vice versa....
Add some fileds to the wp_posts table
wordpress
I have this function and I need to somehow exclude a category number 14 from my submission form. Is there any way to do it inside this function? <code> function retrieve_cat_data($byid = false){ $massive_categories_obj = get_categories('hide_empty=0'); if($byid): $massive_categories = array(); foreach ($massive_categor...
What about using the <code> exclude </code> array key in your <code> get_categories() </code> call? e.g. change this: <code> $massive_categories_obj = get_categories('hide_empty=0'); </code> to this: <code> $massive_categories_obj = get_categories('hide_empty=0&amp;exclude=14'); </code> Note that <code> exclude </code>...
exclude category from WordPress Form function
wordpress
I am using the simple fields plugin to provide additional rich text editors and have no need for this 'main' text editor box on any of my 'page's I have tried the following code in my functions.php: <code> function my_remove_meta_boxes() { remove_meta_box('postdivrich','page','normal'); } add_action( 'admin_menu', 'my_...
see <code> remove_post_type_support </code> <code> function remove_pages_editor(){ remove_post_type_support( 'page', 'editor' ); } add_action( 'init', 'remove_pages_editor' ); </code>
Is it possible to remove the main rich Text box editor?
wordpress
I am curious as to why my screen goes completely blank when an error is present in my code. This only happens to me when it is an admin function. No warnings, no syntax error messages, nothing. Just a blank screen. Which makes it really difficult to find the problem. How do I get the errors to show up and how do I stop...
You need to add the following to your <code> wp-config.php </code> file: <code> // Enable debugging define( 'WP_DEBUG', true ); </code>
why don't I get error messages in admin when developing?
wordpress
I have been attempting to disable the ability to collapse admin meta boxes. By the looks of it WordPress creates this functionality in postbox.js /wp-admin/js/ but I have been unable to find a hook or suitable JavaScript to overwrite the built in functions. This is a some test code I am working with: <code> jQuery('.po...
Add this to your functions file and it will kill the metabox toggles: <code> function kill_postbox(){ global $wp_scripts; $footer_scripts = $wp_scripts-&gt;in_footer; foreach($footer_scripts as $key =&gt; $script){ if('postbox' === $script) unset($wp_scripts-&gt;in_footer[$key]); } } add_action('admin_footer', 'kill_po...
Disable collapse of admin meta boxes
wordpress
Ok so i've got categories like setup like this. <code> Products Category A Sub Category 1 Sub Category 2 Category B Category C </code> What i need is to have the Products category page showing the main Categories (A,B,C). The main Category pages (A,B,C) showing their sub Categories (1,2). Then the Sub Categories (1,2) ...
After searching the internet for some time I've finally got it working. This goes in the functions.php <code> function category_has_children() { global $wpdb; $term = get_queried_object(); $category_children_check = $wpdb-&gt;get_results(" SELECT * FROM wp_term_taxonomy WHERE parent = '$term-&gt;term_id' "); if ($categ...
Category template to show different categories based on parent
wordpress
There is the option to turn off trackbacks/pingbacks under <code> Settings &gt; Discussion </code> . But I'd like remove the <code> X-Pingback </code> header WordPress sends and completely remove the the <code> trackback </code> endpoint. Is there a way to do this?
<code> &lt;?php /* Plugin Name: [RPC] XMLRPCless Blog Plugin URI: http://earnestodev.com/ Description: Disable XMLRPC advertising/functionality blog-wide. Version: 0.0.7 Author: EarnestoDev Author URI: http://earnestodev.com/ */ // Disable X-Pingback HTTP Header. add_filter('wp_headers', function($headers, $wp_query){ ...
Is There a Way to Completely Turn Off Pingbacks/Trackbacks?
wordpress
I would like to create an area on an HTML homepage (HTML site that contains WP pages) that presents through an iframe or other, the titles of all posts for one custom post type. Any ideas would be greatly appreciated.
If you made the home-page of your site a WordPress page, you could just create a page-template for that home page. Within that page template you could have all of your HTML, as well as the loops for showing your posts or pages or whatever else.
Create scroll of custom post types
wordpress
I have one question. I need to query posts from category based on the filter most favorited ( http://pastie.org/2751114 ) which is placed in custom_sort.php to my index.php page This is how the posts from categories are called ( http://pastie.org/2751131 ) in index.php. Is there any way to get the posts from category b...
<code> query_posts </code> accepts custom query variable as arguments. So assuming that adding <code> ?sort_by=most_favourites </code> to an url alters the sort order to sort by the most favourites (i.e. you've set <code> sort_by </code> as a recognised WordPress query variable, and setting it sorts the returned posts ...
Query posts from category based on a filter most favorited
wordpress
Am I losing my mind? I seem to recall that somewhere in the Admin back-end there was a page that basically listed out all the fields within wp_options. Does this ring a bell to anyone else? I thought maybe it was a MU thing but it's not there either. At one point I seem to recall running into a page where you could edi...
<code> // Adds 'ALL' options page - only accessible for admins and custom roles that have the 'manage_options' capability. function wpse31956_all_settings_page() { add_options_page( __('All'), __('All'), 'manage_options', 'options.php' ); } add_action( 'admin_menu', 'wpse31956_all_settings_page' ); </code> Note: As I j...
WordPress Admin back-end - advanced options page?
wordpress
What, in your opinion, is the best way to setup a network of WP sites with a shared login? I want users to stay logged in to their account when they switch sites I want this to be used with different domains
What you're asking for is very easy with this plugin: http://premium.wpmudev.org/project/domain-mapping/ It does cross-domain cookie syncing with all of your sites on one Multisite installation. I've used this a couple times and it works dandy.
Best Way to Setup a Network of WP Sites?
wordpress
I've created a custom post type for "testimonials" as well as rearranged the edit post display with custom columns for that post type... Everything works as expected EXCEPT for the fact that when I hover over one of these custom posts, the list of "action links" that normally appears beneath it enabling you to edit/del...
Ok, so it may not be the most efficient method... but I've found a solution. In the end, I wound up having to write a custom function to handle the addition of the row actions for each post. Here's how it turned out: <code> function wpg_row_actions() { global $post; if($post-&gt;post_type == 'page') { if(!current_user_...
No Edit / Delete Links for Custom Post Type?
wordpress
I'm using site tags for a glossary. I would like to display a link to the tagged page if the tag exists, otherwise just display the tag title. Is there a check which would allow me to determine if the tag is has been tagged on posts? <code> $tags = get_tags( array( 'hide_empty' =&gt; false ) ); if ($tags) { foreach ($t...
Try using the <code> has_tag() </code> conditional template tag. e.g., to query for the tag "foobar": <code> &lt;?php if ( has_tag( 'foobar' ) ) { // The current post has the tag "foobar"; // do something } else { // The current post DOES NOT have the tag "foobar"; // do something else } ?&gt; </code> If you're inside ...
Verify if tag is used on posts
wordpress
I am trying to sharding BLOGUPLOADDIR but couldnt success atm. This is default one: <code> define( 'BLOGUPLOADDIR', WP_CONTENT_DIR . "/blogs.dir/{$wpdb-&gt;blogid}/files/" ); </code> I am trying to set it: <code> if($wpdb-&gt;blogid&lt;10){ $bloggroup = 'global'; }else{ $bloggroup = 'bloggroup'.floor($wpdb-&gt;blogid/2...
Copy the body of <code> wp-includes/ms-settings.php </code> into <code> sunrise.php </code> , from line 25 to line 127. At the bottom, add your <code> BLOGUPLOADDIR </code> defines. <code> // from ms-settings.php ms_subdomain_constants(); if ( !isset( $current_site ) || !isset( $current_blog ) ) { // [trimmed, but you ...
Sharding BLOGUPLOADDIR
wordpress
I have create the appropriate code to handle AJAX request on WordPress but I get 0 as responce from the server. My plugin code is here: <code> class my_plugin { function my_plugin() { add_action('wp_ajax_do_ajax', array($this, 'do_ajax')); add_action('wp_ajax_nopriv_do_ajax', array($this, 'do_ajax')); add_action('wp_he...
I would recommend using a few different tools to try to debug the interaction. First of all, you can see exactly what jQuery is sending via AJAX using the debug console built in to many browsers. If all else fails, hit F12 and it will launch the console window in just about everything. If that doesn't work, install Fir...
WordPress front end AJAX. Return 0 :?
wordpress
I have a website that I'm converting over from a static html site to WordPress. I got almost everthing done, but I'm having trouble with there "about us" page. When you click on their profile it opens up a html iframe about their bios. The current "about us" page I have created sub pages for the bios in WordPress , but...
So, if I understand your question correctly, your problem is that your iframes are showing the theme (nav menu, sidebar, etc.) and you don't want them to. If that's the case, I'd recommend creating a new Page Template that is styled after your bio iframe (no menus, no sidebar). There's more info on creating custom page...
WordPress Subpages Fancybox Trouble
wordpress
How can I set full image thumbnail on category pages? Image should be small in dimensions but not been cropped. Currently my theme WP-Davici (Solostream) use "Get The Image" plugin to generate thumbnail. you may have a look at http://ideabroad.com/
These are two different things: How can I set full image thumbnail on category pages vs Image should be small in dimensions but not been cropped. In order to display the full-size image thumbnail, use: <code> &lt;?php the_post_thumbnail( 'full' ); ?&gt; </code> In order to display a box-resized , rather than hard-cropp...
Show full image thumbnail
wordpress
I am in the process of writing a very long post -- currently 8,500 words and around 40 images, with more to come -- and, all of a sudden, the preview doesn't work: It just shows empty content, with the header loading correctly. The symptoms are the same as described on this page , however I am not using any shortcodes....
In the following snippet, you'll see all filters attached to the title, content &amp; excerpt (from /wp-includes/default-filters.php). Try to remove in a first try only stuff like capital P dangit, smilies and such and if this doesn't work, remove the more critical stuff. I'd only do this until the post saves and then ...
Post Size Limit
wordpress
I have a Wordpress blog hosted on a shared web server: http://martinnormark.com I would like to add a whole new "area" to this site, called Consulting. When navigating to http://martinnormark.com/consulting - another template with different navigation should be used, and the frontpage should be blog posts for that spec...
The framework is not the problem. You just need to exclude your Consulting category from the loop each time you have it. Then use a custom template for the marketing page. Another option would be to set up a multi-site install and then use Consulting as its own blog. EDIT: To exclude the category try adding this to you...
Subsite with different template, and content
wordpress
I am using WP 3.2.1. I try to do permalink like: /en/1/some-string. Structure is: %lang%/%pageID%/%some random string% So I add a rewrite rule: <code> function nw_lang_addRewrite($aRules) { $_aRules["(en|lt|ru)/(\d+)(/.*)?$"] = 'index.php?p=$matches[2]&amp;lang=$matches[1]'; $aRules = $_aRules + $aRules; return $aRules...
I found a problem. I needed change function parameter name to "$aVars". <code> function nw_lang_addQuery($avars) </code>
custom permalink's rewrite rule for page id
wordpress
I've just added a new Custom Post Type to my WordPress site. When I go to create a new post though, the only option I have to edit is "Slug". Normally with a regular post you would have Format, Categories, Post Tags, Featured Image, Excerpy, Send Trackbacks, Custom Fields, Discussion, and Author. How do I get all of th...
Did you add post-type support for those features, via <code> add_post_type_support() </code> ? Use this format: <code> &lt;?php add_post_type_support( $post_type, $supports ) ?&gt; </code> The <code> $supports </code> argument is an array, that can include the following strings: 'title' 'editor' (content) 'author' 'thu...
Adding new Post through Custom Post Type only offers me "Slug" as an option, how do I get more?
wordpress
I'm trying to add a 'sub post' to each post on my site, eg site.com/product-one/changelog site.com/product-two/changelog site.com/product-three/changelog This is the code I'm using atm, which I found here somewhere: <code> global $wp,$wp_rewrite; $wp-&gt;add_query_var('sub-page'); $wp_rewrite-&gt;add_rule('([^/]+)/(cha...
<code> add_rewrite_endpoint( 'changelog', EP_ROOT ); </code> Will add the endpoint, <code> changelog </code> , which you can then check on <code> template_redirect </code> hook. On match the query variables ( <code> $wp_query-&gt;query </code> ) array should contain key <code> changelog </code> containing whatever come...
Pretty URL with add_query_var
wordpress
I have the following piece of abridged code: <code> &lt;?php class New_Walker_Nav_Menu extends Walker_Nav_Menu { function start_el(&amp;$output, $item, $depth, $args) { $attributes = ! empty( $item-&gt;target ) ? ' target="' . esc_attr( $item-&gt;target ) .'"' : ''; $attributes .= ! empty( $item-&gt;url ) ? ' href="' ....
<code> apply_filters() </code> applies a set of registered (with <code> add_filter() </code> ) callbacks. When you apply a filter make sure its name is not one of the reserved ones , <code> the_title </code> looks dangerously "collissible" with other filters. Your filter application is almost correct, but the 'modifyTi...
How can I apply filters in my class that extends Walker_Nav_Menu?
wordpress
I will have two admin users, one of them only speaking italian and the other only speaks english. How can I setup multi-language admin user interface?
There are a couple of methods that this can be done without the overhead of plugins. Method 1 The first method involves hooking to the <code> load_textdomain_mofile </code> filter. ( This must go into a separate plugin ) <code> function wpse31785_change_mofile( $mofile, $domain ) { if ( $domain == 'default' and get_cur...
How can I set up multi language admin ui?
wordpress
I'm using Wordpress. I have a movie review website called Filmblurb . For my blog posts, I'm trying to create posts with different categories. Under the "Reviews" category, I have a "Details" box that serves as meta information for all my reviews. The problem is when I try to create a post that has the category of "Fea...
This gets asked a lot so lets try and fully explain it. We can simply wrap it in an <code> if </code> statement and echo the value, for example, <code> &lt;?php if ( get_post_meta($post-&gt;ID, 'genre', true) ) : ?&gt; &lt;?php echo get_post_meta($post-&gt;ID, 'genre, true) ?&gt; ?&gt; &lt;?php endif; ?&gt; </code> But...
Need help on creating If-statement for custom meta fields
wordpress
I guess this question is more or less about aesthetics and organization rather than functionality, but I'm curious nonetheless... I know I can add a custom menu item in the dashboard for my plugin using the <code> add_menu_page() </code> function, but my question is: Is it possible to add a "master" menu item with "sub...
Yes, http://codex.wordpress.org/Administration_Menus Specific to your question <code> add_submenu_page </code> : http://codex.wordpress.org/Function_Reference/add_submenu_page
Master menu item for multiple plugins?
wordpress
In plain php and frameworks coding is done with the help of IDE tools, im using PhpStorm and very happy so far, recently i decided to discover most popular CMS this days and got confused how do you code for it? 1) do i have to deploy WordPress not only on my server, but locally too? edit files in IDE/editor and use Wor...
Judah's way of developing for wordpress is definitely not wrong - simply different from the way I do things. Also, the two links he provided are very good. The blogpost appears worth a read and the codex is every wordpress developers bible. To offer you some more options to look into, this is my take on wp development:...
How do you code for WordPress?
wordpress
I would like new users of the blog to have custom role, rather then Subscriber. How do I set this programmatically? I know that it can be changed from the backend.
This allows plugins to easily hijack the default role while they're active. <code> // Hijack the option, the role will follow! add_filter('pre_option_default_role', function($default_role){ // You can also add conditional tags here and return whatever return 'subscriber'; // This is changed return $default_role; // Thi...
How do I programmatically set default role for new users?
wordpress
Good morning WP fans ! I try to find a theme for a .wordpress.com blog (it's hosted there) What I would like to have is a "notification system", like for example to notify the visitor that there are updated/unread posts in a category since his last visit/refresh/whatever. Like for example with a bold number inside bran...
What you're looking for is a combination of KB New Posts , which shows visitors posts that they have not yet read Smart Unread Comments and some notification bar system, one of these four may make a good choice Of course you will have to couple them yourself to suit your needs and requirements. As far as I know there i...
Looking for a theme to show unread/updated posts since last visit or like that
wordpress
Got a problem with a shortcode.. i probebly dont know where &amp; how to set the condition so it will display the right image according to the topic / category of the toturial.. Help Plz :) <code> function postInfoBoxSc( $atts ) { extract( shortcode_atts( array( 'subject' =&gt; 'Category type', 'difficulty' =&gt; 'User...
I wasn't able to replicate your problem exactly, but here's a tip: include some default behavior, in case the user puts in a bad value for the subject: <code> // Set image acorring to guide type if ($subject == 'wordpress') { $subjectImg = '&lt;img src="'.get_bloginfo('template_url').'/img/postInfoBox/wordpress.png" al...
Conditional Shortcode image display
wordpress
I'm having a trouble un-attaching media from a post without deleting it entirely from my site. Is there a simple way to unattach an image from a post for instance?
I learned from Brian stackexchange-url ("Fegter") that you can Un-attach an image from a post while participating in this question: stackexchange-url ("Can I attach an image to a different post?") It isn't exactly "simple", but not to difficult. It's the only solution I've been able to find.
How can I UN-attach media from a post?
wordpress
How would I go about requiring each post to have no more than one tag? I would like to require the user to create a tag or choose one previous tag for each post. If you could give me any information, that would be very helpful.
Have fun. This works for any post type (including customs) that supports the 'post_tag' taxonomy. 99.9% of the time, it will apply only to 'post' post type. But we make compatible stuff ;) <code> /* Plugin Name: Single Postag Description: Enforces use of single 'post_tag' taxonomy on select posts. Author: EarnestoDev V...
require one tag for each post
wordpress