question stringlengths 0 34.8k | answer stringlengths 0 28.3k | title stringlengths 7 150 | forum_tag stringclasses 12
values |
|---|---|---|---|
The order of categories on dashboard is alphabetical. Can I change it to custom order? | Found an answer in stackexchange-url ("this answer"). <code> add_filter( 'get_terms_args', 'wpse_53094_sort_get_terms_args', 10, 2 ); function wpse_53094_sort_get_terms_args( $args, $taxonomies ) { global $pagenow; if( !is_admin() || ('post.php' != $pagenow && 'post-new.php' != $pagenow) ) return $args; $args['... | How to Change the Categories Order in the Admin Dashboard? | wordpress |
this <code> filter </code> is on the Wordpress Codex … <code> add_filter('excerpt_more', 'new_excerpt_more'); function new_excerpt_more($more) { global $post; return '<a class="moretag" href="'. get_permalink($post->ID) . '"> &hellip; </a>'; } </code> This works perfect, however I wonder if it is als... | You can use <code> get_post_type </code> <code> add_filter('excerpt_more', 'new_excerpt_more'); function new_excerpt_more($more) { global $post; $post_type = get_post_type($post); switch( $post_type ): case 'event': $teaser = '<a class="moretag" href="'. get_permalink($post->ID) . '"> More events </a>'; ... | Add $more_link_text parameter to the_excerpt() | wordpress |
I am running the latest version of Wordpress on the Genesis Framework with the AgentPress theme. There is an annoying four line gap between the page title and the Wordpress Post Tab widget that I have installed. Using Firebug, I discovered that the gap is caused by four line break tags < br > , which seem to be auto... | You can hide <code> <br /> </code> elements with CSS using <code> display:none; </code> ofcourse you might want to try going into your post editor and removing any blank lines. WordPress converts line breaks into tags for you automatically when the content is rendered using a function like <code> the_content() </... | Removing Line Break Tags from a Page | wordpress |
I wish to export all of my posts as individual plain text files. So, the format may be something like: <code> title.txt </code> <code> Title: title Pub date: date Category: cat Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et </code> Is this possible? Is the... | Try this (you may need to bootstrap WP by loading <code> wp-load.php </code> , depending on where you put this code). <code> $args = array( 'post_type' => 'post', 'post_status' => 'publish', //'posts_per_page' => -1 //uncomment this to get all posts ); $query = new WP_Query($args); while ( $query->have_post... | Export all posts as individual plain txt files | wordpress |
I have this code on a query I'm doing <code> <?php query_posts('post_type=vendors'); ?> <?php while (have_posts()):the_post(); ?> <?php $featured = get_field('promote_to_homepage', $post -> ID, true) ; ?> <?php if($featured){ ?> <div id="vendor-img"><img src="<?php the_field('vend... | Here's a very basic example that should do what you need it to do. Basically, we get all of the posts in your custom post type, then loop through them individually. When we find the one set with "promote_to_homepage," we render some display and exit the loop: <code> // Query for all posts in the post type "vendors" que... | Question about querying posts | wordpress |
Is there a way to add a banner to the WP dashboard? I don't mean in a custom widget or anything, just a simple image banner. | Workaround using jQuery DOM insertion. Note the use of PHP Heredoc sintax to print the script. <code> function wpse_53035_script_enqueuer(){ echo <<<HTML <script type="text/javascript"> jQuery(document).ready( function($) { $('<div style="width:100%;text-align:center;"><img src="http://cdn.sstat... | Add a banner to the Dashboard | wordpress |
At some point, my readers were able to add comments on both the main (front) page of my site and from the post pages as well. Without any obvious change to the configuration of my site, the comment form has disappeared from my article page and, when I click the link from the front page to "add a comment," I'm brought t... | Verify comments are enabled by default: Dashboard -> Settings -> Discussion -> Default article settings. Verify comments are enabled for all posts/pages: Dashboard -> Posts -> Check all posts. -> Bulk actions (Edit) -> enable comments. Same thing for pages. Verify your template files. Do you still have a comments.php f... | Ability to leave comments broken | wordpress |
I have a WP site and also have a external DB (means not WP DB) with users. The insertion process at that table uses the same algorithm as WP uses. What I'm need to do here is login in WP but using this external DB which is in the same host by the way. I check this links http://www.tyssendesign.com.au/articles/cms/conne... | You can override the core wp_authenticate function. You would need to create a custom plugin and declare a new version of wp_authenticate. The function accepts a username and a password and returns a WP $user object. wp_authenticate is a 'pluggable' function and it is found in the wp-includes/pluggable.php file. | Login in Wordpress using external database data | wordpress |
I'm trying to edit my new theme and I got the following comments : Single image gallery post: image shifted in left side with footer Need next and previous image gallery link on single image gallery post. I know how to create a gallery post with many thumbnails, but how do I create a single gallery post in order to sim... | Read Theme Unit Test and import the test data (including images!) into a new blog. You will get everything you need to test. There is a gallery post included ( Images Test ), and if you click on an image you get an attachment page for this gallery image. Here is a screen shot from TwentyEleven: See the links in the upp... | Single Image Gallery Post | wordpress |
<code> <?php $my_query = new WP_Query( "cat=11&posts_per_page=1" ); if ( $my_query->have_posts() ) { while ( $my_query->have_posts() ) { $my_query->the_post(); the_excerpt(); } } wp_reset_postdata(); ?> </code> Where it says the_excerpt, how come I am unable to add other code alongside this? I'm gues... | To insert new code you need to break php code and past your new html+/-php code. But pay attention that after passing all will have correct syntax. Your question should be made like this: <code> <?php $my_query = new WP_Query( "cat=11&posts_per_page=1" ); if ( $my_query->have_posts() ) { while ( $my_query->... | How can I add more code to this? | wordpress |
I want to manage Wordpress installations for some customers of mine. They need an a+ service but I am still struggling with setting up my hosting. What I want: Backups, if I make an mistake I want to have an backup to restore it. Easy scalable, if I decide to get more customers, I want to be able to upgrade the hosting... | Backups: Sounds like you need two types. 1. Versioning (eg use Git or SVN) and 2. Failsafe backup - some good plugins for this, or use a cron job to backup the WP files and database Sounds like there's two needs here as well. 1. An environment to easily scale WP and 2. A host that you can easily scale with. Personally ... | How to host and manage for clients | wordpress |
I have a problem with search queries. Anytime you put additional queries, like: mywebsite.com/?s=wordpress&post_type=page mywebsite.com/?s=wordpress&post_type=page,post mywebsite.net/?s=wordpress&cat=1 mywebsite.net/?s=wordpress&post_type=post&tag=genesis-post mywebsite.net/?s=wordpress&post_typ... | I've found that passing <code> post_type </code> doesn't restrict searches to that type, but just adds that type to the array it already searches. What you can do to build complex search queries is hook <code> pre_get_posts </code> and do a little query manipulation. For a simple example, first I add my own query var t... | Search queries don't seem to work? | wordpress |
I'm trying to get a list of posts from one category, echo the title and the permalink of all posts on that category but exclude the permalink and the post name IF the current post is on that list. It will be displayed on single.php after or inside the loop Anyone knows if it is possible, if so how? Thanks in advance <c... | First off, note that, since your custom loop is a secondary loop/query, you should use the <code> WP_Query </code> class instead of <code> query_posts() </code> . stackexchange-url ("Read why"). That being said, <code> /* main post's ID, the below line must be inside the main loop */ $exclude = get_the_ID(); /* alterna... | List posts by category exclude current post | wordpress |
I try this: <code> add_action('admin_print_scripts', 'custom_admin_scripts' ); function custom_admin_scripts() { echo '<script type="text/javascript" src="' . get_bloginfo('stylesheet_directory') . /admin-scripts.js"></script>'; } </code> but by this way it doesn't recognize jQuery. So I get <code> Uncaught... | The problem is that you are loading your script before jQuery has been loaded. Do not print scripts directly . You should (register and then) enqueue them using the provided API. jQuery is already a registered script, so you can just enqueue it (say on the <code> admin_enqueue_scripts </code> hook). However you only ne... | How can I include JavaScript that use jQuery on admin side | wordpress |
I am interested in: how can we change the default login url <code> /wp-admin </code> to <code> /login </code> how can we add another url for login so that both <code> /wp-admin </code> and <code> /login </code> would work I tried to use a custom filter and .htaccess as in the following example but without success. func... | another option - redirect <code> /admin/ </code> to <code> wp-login.php </code> with a <code> parse_query </code> action hook: <code> function wpa53048_parse_query( $query ){ if( $query->query_vars['pagename'] == 'admin' ): wp_redirect( wp_login_url() ); exit; endif; } add_action( 'parse_query', 'wpa53048_parse_quer... | Allow admin login at /admin | wordpress |
I am working on a plugin where the user can define shortcode tags himself. What would you suggest to allow in there? My thought is only allow ascii characters. So how do I sanitize? <code> strip_tags </code> and then regex to allow only <code> a-z, 0-9 </code> or is there a better solution? Does WordPress have filter f... | You can use almost every character. Just the character <code> / </code> is dangerous. Do not allow it. WordPress is using <code> preg_quote </code> to escape the shortcode name, but it doesn't include its own regex delimiter <code> / </code> when doing that. So the shortcode will not be properly escaped and you get a P... | What characters are allowed as a shortcode tag and how should they be sanitized? | wordpress |
this is in my sidebar.php file, which is pulled in in the header.php file (is this bad practice?). anyways, the last item in the list is the current page title, despite my query_posts with an args of only the custom post type of newsletters <code> <?php if (function_exists('dynamic_sidebar') && dynamic_sideb... | Simple answer - because you're using <code> query_posts() </code> , which alters the main query. It almost always produces unintended results, as you're finding out the hard way right now. Generally, it's best to call the sidebar using <code> get_sidebar() </code> instead of <code> include </code> (which you probably a... | why is the current page title being output? | wordpress |
I'm a little new to Wordpress and the JSON API so forgive me if this is a newbie question but i'm trying to get all of the posts of a few different custom post types and return them as JSON via my own JSON controller (extending the JSON API) if I do this: <code> $posts = $json_api->introspector->get_posts(array('... | I'm answering my own question because it might be useful to someone else sometime. After reading through the somewhat sparse documentation on the wordpress plugin directory and getting nowhere. I found a variable in the JSON API code here's how it works PS -1 just mean "all": <code> $json_api->query->count=-1; $p... | wordpress JSONAPI introspector always limits number at 10? | wordpress |
Live site. I'm having trouble pinpointing exactly why the Blog page is showing up as the Home/landing page. I've changed the page template to General/page.php and have WP reading settings set to Front Page as Static/Home, and Posts page as Blog. Any ideas? All of the other pages I've set to use the General template hav... | You should read up on the template hierarchy . <code> page.php </code> is automatically used for all static page. It should NOT have a "Template Name" header in it. <code> home.php </code> is for styling your BLOG page. It should have a loop that can handle multiple articles. <code> front-page.php </code> is for stylin... | blog page showing as home/landing page despite template change and reading settings | wordpress |
Why does the output of this function <code> // One Recent Post function most_recent_post_shortcode() { return wp_get_archives( 'type=postbypost&limit=1&format=custom'); } add_shortcode( 'recent-post', 'most_recent_post_shortcode' ); </code> and shortcode <code> [recent-post] </code> show the output at the top o... | The default of the <code> echo </code> argument is <code> true </code> for <code> wp_get_archives() </code> . I think this would fix it: <code> // One Recent Post function most_recent_post_shortcode() { return wp_get_archives( 'type=postbypost&limit=1&format=custom&echo=0'); } add_shortcode( 'recent-post', ... | Shortcode for output of wp_get_archives displays at top of post | wordpress |
I'm using a cron to take data from Facebook and i have divided the job into three calls, to avoid making to many call all toghether, now how do i set up calls so that they don't overlap? <code> // Set the CRON for pages wp_schedule_event( current_time( 'timestamp' ), self::FB_CRON_FREQUENCY, self::FB_CRON_PAGES, array(... | Ok that was pretty easy <code> // Set the CRON for pages wp_schedule_event( current_time( 'timestamp' ) + 450, self::FB_CRON_FREQUENCY, self::FB_CRON_PAGES, array( Ai1ec_Facebook_Graph_Object_Collection::FB_PAGE ) ); // Set the CRON for groups wp_schedule_event( current_time( 'timestamp' ) + 900, self::FB_CRON_FREQUENC... | How to set-up multiple cron task with wp_schedule_event so that they do not overlap? | wordpress |
I have a blog that is working on wordpress installation and now I want to transfer it to the my new blog under WordPress.com domain name. Is it possible to carry all the content to new WordPress blog? | If you're dealing with a WordPress.com hosted site, then you don't have direct DB access. You'll need to export out your content, and import it into the new site using the options in the WP admin area. You also may not be able to use the same theme. WordPress.com hosted sites have way more restrictions than other hosti... | Transferring standalone wordpress blog to the one under **.wordpress.com | wordpress |
I have a strange question... I have my term as a variable... <code> $mailer = 'may-2012-newsletter'; </code> And I'm trying to echo on my page the Name of my term, using the variable above. But this is not in a loop. My term name is: May 2012 Newsletter But I'm trying to echo this from using my term slug: may-2012-news... | You can use get_term_by to get the term object if you know the slug and then just echo out the name ex: <code> $by = 'slug'; $slug = 'may-2012-newsletter'; $taxonomy = 'mailers'; $term = get_term_by( $by, $slug, $taxonomy); echo $term->name; </code> | echo term name outside the loop, using term slug | wordpress |
I have the following function in functions.php that allows sorting alphabetically or by recency. I want to change the alphabetic to sort by most viewed. This is the code I have for the sorter, which is a dropdown select menu: <code> function sorter($wp_query) { if(mysql_real_escape_string($_REQUEST["sorting"]) == "date... | You can use what you currently have and add a new condition: <code> function sorter($wp_query) { if(mysql_real_escape_string($_REQUEST["sorting"]) == "date"){ usort($wp_query->posts, 'cmp_date'); }elseif(mysql_real_escape_string($_REQUEST["sorting"]) == "title"){ usort($wp_query->posts, 'cmp_alpha'); }elseif(mysq... | sort posts by getPostViews in functions.php | wordpress |
I currently have a list of posts with the custom field "Name," with several posts having the same value for "Name." I would like to retrieve a list of posts that all have unique values for "Name." For example, Post 1 and Post 2 can't both be "Michael." Is there a way to do this by altering the SQL query directly, befor... | If you have several posts with the same value, but you want only the most recent ones with any value, as long as values don't get repeated, you'r best bet might be running two loops on the same query: <code> /* Fetch all possible values - use this to order the results and define which get selected */ $valueids = new WP... | Alter SQL query to return posts with unique custom field value, no duplicate values | wordpress |
Need some help, I created these websites <code> http://mccsedu.org http://parents.mccsedu.org http://faculty.mccsedu.org http://students.mccsedu.org </code> The main site is working fine, but the pages of the those subdomains are not working. it always returns 404, you can try visiting those sites and click on any post... | You can always delete the .htaccess for each root directory, then visit each domain.com/wp-login.php then visit: Dashboard -> Settings -> Permalinks & save changes. (Automatically generates a fresh .htaccess) OR login to phpmyadmin for each domain, check out the database... options table... verify the "siteurl", an... | Sub Domain's Pages return 404 | wordpress |
I want to make some edits to a plugin that I've downloaded. I used the Plugin Editor, but the changes did not show up. I tried refreshing, logging out/back in, and deactivating/activating the plugin. I gave up on that route and decided to: deactivate/delete the plugin via the admin page delete the plugin folder via FTP... | Easiest way to test for caching - make a plugin-breaking change (remove a <code> ; </code> or something), upload it, and see what happens. If your admin panel whitescreens, congratulations - you don't have caching. If it doesn't, chances are your server is caching all php content with something APC. Contact them and as... | Edits to plugin not taking effect | wordpress |
This is a spin of: stackexchange-url ("how to create child WordPress plugin") I am using a plugin that I use and like a lot, but there is a feature that I need and it seems like the author is busy with life. I am a PHP developer so I could hard code my feature to his plugin, but this way on the next update I will not b... | Personally I'd either write my own plugin with a if plugin x exists clause or just edit it and send the code off to the developer saying "I have added a feature to your plugin, hope you like it" kinda deal. Realistically though, in my own site I just edit the code and be done with it cause I know that plugin will be th... | How to create a child/addon plugin | wordpress |
is there any error in following code? when i use following code in content.php file of my theme, then nothing is displayed on blog, it seems there is some error. and when i comment folowing code everything gets back to normal. <code> <?php if (empty(get_custom_field_value("signature",""))) : ?> &mdash; <?p... | <code> empty </code> will only take variables passed by reference. so <code> empty(some_function()) </code> will never work. See the php docs for more information. <code> <?php if (get_custom_field_value("signature","")) : ?> &mdash; <?php the_category( '<span>/</span>' ); ?> <?php endif;... | using custom fields on content.php file of my theme | wordpress |
I want to keep this category title on my pages, but I don't want it to be a link. <code> <?php echo get_the_term_list( get_the_ID(), 'portfolio_cats', ' ', ' , ', ' '); ?> </code> Can anyone help? Thanks | You could use <code> get_the_terms() </code> and <code> wp_sprintf_l() </code> : <code> function wpse_52878_term_list( $args = array() ) { $default = array ( 'id' => get_the_ID(), 'taxonomy' => 'post_tag', 'before' => '', 'after' => '', ); $options = array_merge( $default, $args ); $terms = get_the_terms( $... | I want to remove the links from the term list returned by get_the_term_list | wordpress |
I have in my plugin dir a endpoint.php and need to rewrite like this: <code> http://domain.com/API/endpoint.php </code> This is the code I've used: <code> add_rewrite_rule( 'API/endpoint.php', 'myplugin-path/endpoint.php', 'top' ); </code> When I print the <code> $wp_rewrite </code> global I got this: <code> [non_wp_ru... | Wordpress rewrite mechanism works in a different way, not like .htaccess rewrite rules. More information about it you can find in codex ( Rewrite API , WP_Rewrite , etc.). But fast work around could be the following: First of all we need to register our query var and rewrite rule: <code> function myplugin_add_query_var... | rewrite file to wordpress | wordpress |
I am trying to add a delisting feature to my WordPress network. Posts which are delisted would not appear in post lists, but would still be visible if accessed directly. I've written a plugin that helps editors delist entries with custom meta values on authors and posts. So there are two meta values that I need to chec... | Shortly after writing my question, The Theme Foundry wrote a blog entry that answered my question. The solution is to <code> add_action </code> s for both <code> posts_join </code> and <code> posts_where </code> . These each take clauses as arguments, which you append with your own conditions and return the appended cl... | Delist entries in the_loop | wordpress |
I'm trying to use custom taxonomy with pages. Basically a page has a "relevance" taxonomy, depicting who the page is relevant for. The pages are created in a hierarchy based on the departmental structure of the school district which the site is for. So say I'm on the alumni page, and I want to list all the child pages ... | Custom taxonomies are not meta values, but rather their own thing. I don't think <code> wp_list_pages() </code> or <code> get_pages() </code> can query based on a taxonomy, so I'd recommend using WP_Query instead: <code> <?php $relevant_pages_args = array( 'post_type' => 'page', 'posts_per_page' => -1, 'post_p... | meta_key & meta_value not working with get_pages and custom taxonomy | wordpress |
I'm trying to style a form on a website, but I'm hitting a snag. Wordpress is automatically generating <code> <br> </code> tags when I directly edit the HTML for pages. What I've got is this: <code> <fieldset> <legend>* Your name:</legend> <ul class="singleLine"> <li> <span> &l... | Try using <code> get_the_content(); </code> in your page template loop instead of <code> the_content(); </code> EDIT 05/24/2012 - Try this: <code> <div id="main-content"> <?php while( have_posts() ) : the_post() ?> <h1 id="pagetitle"><?php the_title(); ?></h1> <div class="pagecontent"&g... | How to prevent pages from automatically adding line breaks? | wordpress |
i can't manage to "see" the value of <code> $originalArticle </code> in <code> echo '/'.$originalArticle.'== &'.$sameArticle; </code> : i tried with "global" before, but it does not work... The output is for example : /== &48 Any help? <code> <div id="post-<?php the_ID(); ?>" <?php post_class(); ?&g... | Use <code> get_the_ID() </code> , not <code> the_ID() </code> . The latter just prints the value, it does not return a value you can store in a variable. So … <code> $originalArticle = get_the_ID(); </code> | variable value disappears in a second loop | wordpress |
I'm using WPAlchemy on a project. For a template, I need to use a custom metabox which is working fine with a tinyMCE editor. Code to insert the meta box on the template (this is a piece of code from https://github.com/helgatheviking/WP-Alchemy-Holy-Grail-Theme/ because I end up trying it after a looooog search, but ma... | sorry you were having trouble with my "Holy Grail". It looks like you missed an important part in my functions.php sample: <code> apply_filters('meta_content',$simple_textarea->get_the_value('test_editor')); </code> You weren't using WP Alchemy's <code> get_the_value </code> method. So instead of: <code> $richtextco... | Cannot get tags working from a WPAlchemy metabox with wp_editor() | wordpress |
I recently changed a few categories, so I know I have a bunch of broken links now. Instead of spending hours going through previous posts and fix them manually, I want to use a plugin that can do that for me. My friend Google told me about the " Broken Link Checker " plugin which seems to be quite popular, but for what... | Try WP Link Validator - Detect Broken Links plugin. Looks like it should help you. Pay attention that this plugin is not free. | Plugin suggestion: Find broken links | wordpress |
How to make one query for display a list of links like this: Date 05/20/2012 Category - Link Category - Link Category - Link Category - Link Category - Link Date 05/19/2012 Category - Link Category - Link Category - Link Category - Link Category - Link .... | Try it like this: <code> $dates = array(); // declare an array to hold dates echo '<ul>'; if (have_posts()) : while (have_posts()) : the_post(); $thisday = get_the_time('m/d/Y'); // this post's date if (!in_array($thisday,$dates)) { // check if it's in the array echo '<h5>Date '.$thisday.'</h5>'; // i... | Help in query for list links | wordpress |
I have created some custom roles using a plugin and I have also created custom user meta fields that are show in the Profile pages of each user (/wp-admin/profile.php) I have a problem with saving the custom fields, I can save the fields ok if I don't change the users' role. So, to give an example: User 1 has fields a,... | Observation: following the guidelines stackexchange-url ("suggested in this article"), I'm trying to improve the quality both of the Q and the A. It's a learning process... In your original code , you were displaying different input fields according to the user role and other conditionals. <code> add_action( 'show_user... | How to Save Different Usermeta Fields According to User Role? | wordpress |
I am trying to get metadata for a post (of custom post type). I had a look in the database, and the table "wp_postmeta" holds a row with "post_id" = 65, "meta_key" = "name_text" and "meta_value" = "Lars Åkerkvist". I am trying to fetch that value, Lars Åkerkvist, using get_post_meta as below <code> get_post_meta(65,"na... | Change <code> $single </code> back to <code> false </code> , e.g.: <code> <?php $name_text = get_post_meta( 65, 'name_text' ); ?> </code> Why? If set to true then the function will return a single result, as a string . If false, or not set, then the function returns an array of the custom fields. This is not intu... | get_post_meta returns 0 | wordpress |
I have a shortcode that shows a loop for a custom post type: <code> while ( $loop->have_posts() ) : $loop->the_post(); // do something endwhile; </code> Some of the posts are in categories ($term-> name), how do I display list of these categories and posts within them based on that loop ? Example: I have 2 catego... | I think you can try the following options. <code> wp_list_categories </code> with the <code> 'show_count' </code> parameter http://codex.wordpress.org/Template_Tags/wp_list_categories <code> get category </code> and use <code> $count = $category->category_count; </code> http://codex.wordpress.org/Function_Reference/... | Displaying terms based on loop posts? | wordpress |
No matter how many times I go into settings, and update my website title, it remains the same. And does not update? I've tried clearing my cache, uninstalling my old theme, searched through source files, and CANNOT figure out why - my title just won't update. Any suggestions? | It looks like you can't update your low accept rate either. Anyways, have you tried checking your theme's header.php file? What is the value between the title tags? Are you using any third party plugins for SEO like Wordpress SEO by Yoast? Try adding this between the title tags: <code> <?php wp_title("",true); ?>... | My title won't update | wordpress |
I'm working with a plugin called media tags... The foreach looks as following (simplied as much as possible) <code> foreach($mediatags as $mediatag){ $args = 'media_tags=animals&numberposts=10&return_type=li&size=thumbnail'; $media_items = get_attachments_by_media_tags($args); echo $media_items; }; </code> ... | You use <code> $mediatags </code> variable in global scope as array in your loop, and then try to use the same variable as object in your function. You override your global <code> $mediatags </code> variable in your loop. Try to use following code: <code> foreach($new_name_for_mediatags_array as $mediatag){ $args = 'me... | Why can't I call a (member) function from within a foreach? | wordpress |
So Long story short, im working on a custom theme and wrapping the WP hooks onto said theme etc and i noticed that, When writing a post/page etc, that say for example i want to make a word bold/italic etc, That applied styles dont come through. So for example, say i select a word, click the "B" icon to make the word bo... | Most likely, your theme uses some form of CSS reset . Your markup ("b", "i", etc) is probably being saved and rendered correctly, but the CSS reset overrides all of the styles that the browser would normally apply. Try viewing the source of your page, and see if the markup ("b" tags, "i" tags, etc) actually exists. If ... | WP text styles not coming through to actual post | wordpress |
I'm running a property site where many properties are sold in apartment blocks. Because of this what the content editors do is create a post/property with all the details and then use a duplicate post plugin to create the others. Each time they duplicate a post/property they change the title to reflect the property num... | The easiest workaround could be: <code> function myplugin_update_slug( $data, $postarr ) { if ( !in_array( $data['post_status'], array( 'draft', 'pending', 'auto-draft' ) ) ) { $data['post_name'] = sanitize_title( $data['post_title'] ); } return $data; } add_filter( 'wp_insert_post_data', 'myplugin_update_slug', 99, 2 ... | Force post slug to be auto generated from title on save | wordpress |
When I use wordpress to install a new theme it creates the permissions and ownership in such a way that I can't edit the files via FTP. Any ideas? (Using Plesk) | Given that you are the webhost: If the server is a dedicated server, or you're in any situation where you're the only user of the server in question, then this is a GOOD thing! It means your setup is more secure this way. It basically means that somebody who hacks into your site through the webserver "door" will have a... | new theme permissions don't allow me to edit | wordpress |
Live site In the lower portion of the landing page, I'd like there to be three blog post previews- just the headline and thumbnail for the three most recent posts. I'm using the following code: <code> <?php get_header(); ?> <div id="container"> <div id="landing"> <div id="intro"> <h1>Hi, I... | It sounds like you need a second loop on your home page to call the 3 most recent posts. Try something like this: <code> // Main home page content here <?php $my_query = new WP_Query( array( 'posts_per_page' => 3, 'nopaging' => true ) ); while ( $my_query->have_posts() ) : ( $my_query->the_post() ); ?>... | post preview/thumbnails not displaying correctly- linking to "home" instead of post? | wordpress |
What is the best way to get the author's page url, so http://example.com/author/user73 , from their ID number? | http://codex.wordpress.org/Function_Reference/get_author_posts_url | How do I get the author's page url from their ID? | wordpress |
I am trying to build a custom view of categories, I want to have all 'post's show their thumbnail within a jQuery carosel (4 in each slide) , I have got it to a stage where it visually looks how I want it to look, but it's showing ALL posts rather then the category your on, I have a big feeling this is due to my custom... | Why are you running a complete new query for every single post? Here is what is happening: WordPress gets all the posts in the category then gets your template and sees the loop ( if have_posts() etc... ) and says ok I have all these posts from this category now it's time to display them. Bam HALT!!! Ok I have these po... | Custom Wordpress category page showing all posts rather than the specified category | wordpress |
I am using the Types plugin and have ticked Categories under the Registered taxonomies that will be used with this post type section. However, no categories seem to appear. Has anyone encountered this problem before? Any advice appreciated. | By default, category and tag archives only list Posts in that category. So, despite the UI appearing on the backend, the posts don't show up in the archives. Luckily this isn't too hard to solve. Look at this support thread and this answer in particular . It has resolved this issue for me in the past. Make sure not to ... | How can I list Custom Post Types created with the Types plugin under categories? | wordpress |
I'm looking for a way to check how many posts are returned by a specific loop. So if I have a loop like this.. <code> <?php $featured_post_id = get_the_ID(); global $post; $args = array('cat' => '9', 'posts_per_page' => 5, 'post__not_in' => array($featured_post_id) ); $my_query = new WP_Query($args); if ( $... | Try this: <code> if ($my_query->post_count < $min_posts) { // Do Something. } </code> Good luck! Hope that helps. | Check to see if specific loop has less than certain amount of posts | wordpress |
On PHP 5.3.13/MySQL 5.5.21 the following code doesn't work: <code> if($check_custom_fields_form!=1){ $sql = "CREATE TABLE IF NOT EXISTS ". $table_custom_fields_form ." ( `form_name` longtext NOT NULL, `field_id` bigint(20) NOT NULL, FOREIGN KEY (`field_id`) REFERENCES $table_custom_fields (`ID`) ON DELETE CASCADE ON UP... | Do I really have to live with that until dbDelta supports FOREIGN KEY? Quite frankly, yes. But that's the beauty of open source - anyone is welcome to post a patch! However , expanding it to cover other aspects of schema design would almost certainly incur unwanted complexity & heighten the possibility of failure -... | dbDelta support for FOREIGN KEY | wordpress |
I'm trying to get a feed for pages and a separate feed for posts. The feed for posts works perfect as it is. I just want a separate one but i have tried all the plugins and searched for about a week straight and still could not find a solution Is it possible to take feed-rss2.php and duplicate it to change the code to ... | Feeds for post types are called with <code> feed/?post_type=POSTTYPE </code> . For no obvious reasons this doesn't work for the post type <code> page </code> – you get the posts instead. But there is a filter to fix that: <code> 'pre_get_posts' </code> . Let's use it: <code> add_action( 'pre_get_posts', 't5_pages_in_fe... | How to get a feed for post type 'page'? | wordpress |
I created a Custom Post Type for Games, but when I add it, the permalink is showing as http://site.com?my_games=test-game where my_games is the custom post type name and test-game is the post name. I have <code> 'rewrite' => false, </code> , is there something else I should be doing? I want the permalink structure t... | Your question has the answer right in it! I have 'rewrite' => false,, is there something else I should be doing? From the Codex : To prevent rewrites, set to false. By setting that to false, you're preventing the default behavior that you want. | Custom Post Type permalink doesn't match post permalink | wordpress |
In a stackexchange-url ("previous question") I was trying to solve an issue where WordPress was using the wrong url in sortable column headers & pagination in the admin when behind a proxy, the only solution that worked involved modifying core files, specifically On lines 491 and 658 in wp-admin/includes/class-wp-l... | I threw this question around on Twitter and asked for feedback from some other core developers. My gut instinct was to make <code> $current_url </code> either filterable or generated by a function that could be overridden. This is, apparently, the wrong way about it. @markoheijnen : @EricMann Resetting <code> $_SERVER[... | Possible to fix admin URL behind proxy issue without hacking core? | wordpress |
I had trouble accessing wp-login.php, so I changed the name of the theme I'm developing to force WP to switch to default. I then turned on debugging and received the errors below. I'm a little puzzled as to why these have come about because they were not showing when I was last working on the theme a few days ago, and ... | Replace <code> get_bloginfo( 'siteurl' ) </code> with <code> home_url() </code> . As the <code> get_bloginfo() </code> Codex entry explains, <code> siteurl </code> is deprecated : <code> 'siteurl' / 'home (note this is deprecated! from version 2.2)' / 'url' </code> - Returns the <code> 'Site address (URL)' </code> set ... | debugging errors.. how to remedy? | wordpress |
I have years of experience with PHP and MySQL, but just starting to develop plugins for WordPress and need some help. Currently, I am working on a plugin that will add extra functionality to another plugin. I need to read the data stored by the original plugin and manipulate it with my plugin. So far so good, but when ... | This is a serialized array. PHP is able to read them as if they were regular arrays (or objects, in some cases) by using the <code> serialize </code> and <code> unserialize </code> functions (WordPress does this for you). All you need with WordPress to do is use <code> get_option </code> (or comparable WordPress functi... | How is the data stored in the database? | wordpress |
I got a message from Hostgator about my account being suspended because of the load it put on their servers. This is about the fifth time this has happened. I am on a shared server. And they said it could be resolved by simply adding new indexes to the database or optimizing the database using other techniques. I have ... | The WordPress database is already indexed. See this codex article for a detailed list of indexes per table: http://codex.wordpress.org/Database_Description And even if it weren't, you'd need to know what queries are being run in order to effectively add indexes. Meaning, there would be no quick fix--you'd have to learn... | How do I add indexes to Wordpress Database? | wordpress |
I have a custom post type called LAW. LAW has three custom fields: LAW_DATE, LAW_TEXT and LAW_AUTHOR. I want to build a search page that allows me to search independently each of these custom fields. I.e. different criteria for each field, combined with and/or to each other. Thanks. | The following function needs to be put in the functions.php of your template code. Or in a plugin. <code> function custom_search_query( $request ) { $query = new WP_Query(); // the query isn't run if we don't pass any query vars $query->parse_query($request); $request['post_type'] = 'LAW'; // this is the actual mani... | How to search in a Custom Field? | wordpress |
I would like to make sure no email address is published in plain. So i developed a plugin that replace all email addresses by a spambot-safe alternative. But some users put their email address in their blog header, outside the post loop. How can i capture and filter that? This works: <code> add_filter('the_content', ar... | You can't protect against everything a user will do. What if they hard-code an email address in the footer/header/sidebar of their theme? The only way to capture and escape that is with output buffering ... and that can become a performance nightmare. My recommendation would be to do two things: Hook in to all of the p... | Filter all html output | wordpress |
I own a blog and finally wants that my users should be able to get a weekly newsletter on the blog. Basically I am a new user of wordpress and not sure how i can do that. I got some material on internet how can i create a weekly newsletter but all are paid services and right now I wont be able to afford them. Can anyon... | I would personally advise against running the newsletter from your server directly as their can be issues with delivery rates and mails being flagged as spam. Instead http://www.mailchimp.com have a free user plan that would be suitable for you; as they are a premium service provider you can feel more confident that yo... | How can i create a newsletter for my wp blog? | wordpress |
When viewing my theme files via "Appearance > Editor", the index.php file that's listed there is an index.php that's inside a subfolder of my theme directory, not the main index.php file that resides in the root of my theme folder. How can I tell WP to list my theme's index.php there? | I've found the problem. I had placed an empty index.php file into a subdirectory folder under my main theme folder to prevent directory browsing on that folder. The presence of this index.php was causing the wordpress file editor to assume it was the default index.php for my theme. Renaming that file to home.php has re... | How to get the theme index.php listed in appearance editor | wordpress |
I run an increasing number of WordPress sites, as well as several for clients - and logging in to perform upgrades is becoming tiresome. I'm looking for a means of automating the process, preferably from a single command line script - and upgrading all the sites in one fell swoop. My ideal would be to hook into the ver... | I'm not sure if this will address your issue... But there's something new in WorldWordPress. http://infinitewp.com/ It's akin to ManageWP, but free :o) I'm not affiliated with them in any form, just starting to play with it. (ht: wpmail.me ) It's a platform that you install in your server. Add the client plugin to your... | Automating the Backup Process (30+ websites) | wordpress |
I'm creating a template for a custom taxonomy for my theme. At the beginning of the page, before the loop that lists all the posts associated to a term of that taxonomy, I want to output the description for that term. I have tried with <code> term_description() </code> but it doesn't work, no output... get_the_terms an... | The <code> term_description() </code> function returns the description rather than echoing or printing it. To fix the issue, use: <code> echo term_description(); </code> | How to get the term description in a taxonomy term archive query? | wordpress |
Is there a function that does something like: <code> is_in_taxonomy($term, $taxonomy) </code> Where it returns true if <code> $taxonomy </code> has that <code> $term </code> . ???? Thanks! | You're probably looking for <code> term_exists() </code> : <code> <?php term_exists( $term, $taxonomy, $parent ); ?> </code> <code> $term </code> is required (obviously). Both <code> $taxonomy </code> and <code> $parent </code> are optional, but if you want to determine if a specific taxonomy has a given term, ju... | Check if term is in a taxonomy? | wordpress |
I've trying to get a showreel title and video id into an URL that can then be accessed by the page. i have the two in the same URL and it either doesn't work or only one comes in. Currently the page isn't being found ? (i am constantly flushing the permalinks) Url i want to get variables from will look like directors/t... | This seems to work! ? post_type =directors& name =$matches[1] seems to be the key <code> add_rewrite_rule( 'directors/([^/]*)/showreels/([^/]*)/video/([^/]*)/?', 'index.php?post_type=directors&name=$matches[1]&showreel=$matches[2]&video=$matches[3]', 'top' ); </code> so final code now; <code> function w... | add_rewrite_rule not loading correct page nor getting variables | wordpress |
I am working on a WP plugin and I want to add a custom function to pluggable.php (located in /wp-includes). I am calling that function from admin.php (located in /wp-admin) eg. Consider the function <code> auth_redirect </code> which is called from admin.php. <code> auth_redirect </code> is the function defined in plug... | You should not and do not need to write to <code> pluggable.php </code> (or any other core WordPress file). You can override a pluggable function simply by defining it in your plug-in's files (or for themes, <code> functions.php </code> ). These get loaded before <code> pluggable.php </code> , and so the function defin... | How to add custom function to pluggable.php | wordpress |
I have a multisite workpress install (v 3.3.2). I'm trying to save the WPLANG field but nothing happens. I get the confirmation message "Site options updated", but the field is still blank. And when I query it with get_locale, it get the default 'en_US'. I've tried entering in: ja_JP 'ja_JP' "ja_JP" ja-JP 'ja-JP' "ja-J... | To set a specific language in a multi-site the language files must be available in the language directory, usually in <code> wp-content/languages </code> . So if you want to set the language to <code> ja_JP </code> a file <code> ja_JP.mo </code> must exist there. You can get the language files from the SVN repository . | Multisite WPLANG won't save | wordpress |
I want to use <code> wp_enqueue_script </code> to load <code> media.js </code> from frond end. I use Win Grep searching through the whole WP dir, couldn't find which handle this <code> media.js </code> was registered. in this <code> media.js </code> , there's a function <code> findpost.open </code> , that's what I need... | The handle is <code> media </code> . View in source, line 403 . | What's the handle for media.js? | wordpress |
I don't know whether it's something I'm doing wrong or an issue with the Gravatar website in general, but it doesn't seem to let me create an account (no error is given, the account just doesn't get created). There's no contact information that I could find for them to contact them. Regardless, is there something that ... | How to contact Gravatar support There are also several options( 1 , 2 ; just examples) for handling the avatars locally instead. | Gravatar alternative for Wordpress | wordpress |
Limiting the number of words or characters in Wordpress slug/permalink. I would like to limit the number to the first 5 words (or 20 characters) even if the post title is longer. example: Title: Welcome to my site - this is my first post url: mysite.com/welcome-to-my-site Some function or alteration in the core Wordpre... | You can probably do something with the <code> sanitize_title </code> hook based on the context conditionally, but I'm not familiar enough with where else <code> sanitize_title </code> is used to say for sure that this is a good solution. The trick to this is going to be limiting your slug without including stupid words... | Limiting the number of words or characters in the slug/permalink | wordpress |
When I click on Reply, the reply form appears at the bottom of the page (under the last comment). How can I add the Reply Form inside the comment to which I am going to add the reply? | Ensure that you have Threaded Comments enabled: go to <code> Dashboard -> Settings -> Discussion </code> and enable the option to thread comments Ensure that your Theme enqueues the <code> comment-reply </code> script . Look for the following, usually in <code> header.php </code> , <code> functions.php </code> , ... | Comments Reply Form | wordpress |
In the theme admin menu below, the "MyTheme Menu Label" is being duplicated twice on the sidebar menu, once for the main menu link and again for the first submenu link. How can I remove the 2nd instance of the link <code> add_menu_page( "MyTheme", "MyTheme Menu Label", //THIS IS REPEATED TWICE IN THE MENU "edit_themes"... | There is a workaround to hide this automatically created submenu. In the past I've used it quite often, but lately I have returned to leaving it as is (or renaming it, as m0r7if3r suggested). Also note, that aside your main question, you have switched the positions of the menu_slug and function arguments in <code> add_... | How to remove duplicate link from add_menu_page | wordpress |
I'm doing some custom loops that I initialize with a query like this <code> $the_query = new WP_Query('page_id=266'); </code> It works fine. It's just I'ld to call my page with its slug and not its ID. Would it be possible ? | use <code> pagename= </code> to query by slug. See WP_Query for full list of valid arguments. | Use the page slug in a WP_Query? | wordpress |
Given a blog featuring several categories (such as "Sport", "Nature", etc), I've then proceded to create a custom taxonomy, which allows me to show articles in certain areas of my blog with terms such as "slideshow", "sidebar-highlight", "top-category", etc. Inside my sidebar, I've created an area where articles (from ... | Pass the post ID from the first query as a <code> post__not_in </code> parameter to exclude it from the second query. <code> $nature_loop_1 = new WP_Query( array ( 'category_name' => 'nature', 'tax_query' => array ( array ( 'taxonomy' => 'highlight', 'field' => 'slug', 'terms' => 'sidebar-highlight', 'op... | Avoid WP_Query's duplicate posts with taxonomies | wordpress |
I'm working on improving my git workflow as it applies to my WordPress development projects. Often, when developing a content management system, I'll create a development server (like <code> http://dev.finalsitename.com </code> ) containing the custom post types and taxonomies that will be used in the production versio... | There are 3 options from easiest --> Use only one remote database that you all connect to with lots of backups. That way you just have to worry about files and not the db. Use the import and export functionality built into WordPress and throw it into your version control right into the wp root (like in a new folder). S... | Keeping WP database synced across multiple developers using git | wordpress |
I need to paginate some custom posts...I can’t see why but I’m getting 404’s when going to the next page. Here’s my code: <code> $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; query_posts( array( 'post_type' => 's_stories', 'posts_per_page' => 4 , 'paged'=>$paged) ); if (have_posts()){ while (... | query_posts </code> . This is a classic example of what happens when you do :) Basically, when WordPress receives an url, it interprets this as a query - it then queries the database to find the results (if any) and serves up an appropriate template (such as 404.php in the case of no results). If it happens to reach yo... | query_posts and pagination, still stuck after much research | wordpress |
I want a theme very similar to these two websites. I am a newbie to wordpress and am trying to understand what theme is it. It looks like both the sites have a similar theme. Is there a way I can fin out what is the theme that they are using? Any help would be appreciated. http://www.evanmarckatz.com/ http://www.winggi... | In your browser select "View page source" search for <code> style.css </code> you'll find something like this: <code> http://domain.com/wp-content/themes/ThemeName/style.css </code> there you already have the theme name, and if you open the URL you also gonna see at the beginning of the stylesheet a header with all the... | Identify current wordpress theme | wordpress |
Is there a best practice for including your <code> wp-config.php </code> file in your version control repository? I'm considering creating a new site with this type of configuration, (similar to Alex King and Mark Jaquith): <code> /index.php /local-config.php /wp-config.php /wp/ (core) /wp-content/ (plugins, themes, et... | Here is how I do it and I haven't come across anything better than this. I keep a different version of wp-config.php file under version control and then keep a file one directory above which holds all the database credentials and salts/keys. Also this way, I am able to distinguish between the type of setup I am running... | Best practice for versioning wp-config.php? | wordpress |
I use a standard loop in my index.php and that shows all the posts beeing posted. What i'm looking for is a code that only shows the posts that have image(s) in it. With other words: i only want to show posts that have images in content in my loop. | I found and modified a chunk of code found here: http://www.wprecipes.com/wordpress-tip-detect-if-a-post-has-at-least-one-image . <code> <?php while ( have_posts() ) : the_post(); $content = $post->post_content; $searchimages = '~<img [^>]* />~'; preg_match_all( $searchimages, $content, $pics ); $iNumber... | How to only publish posts with image in it | wordpress |
I would like to add some code in functions.php that does this: If the first paragraph contains an image, show my custom code right AFTER it. For example: <code> <div class="entry-content"> <p><img src="http://example.com/example.jpg" alt="Image in 1st para" /></p> <div>MY CUSTOM CODE</d... | How about a few simple lines With jQuery? <code> jQuery(document).ready( function ($) { if ($(".entry-content:first-child").has('img').length) //this check for the img tag $(".entry-content:first-child").after("<div>MY CUSTOM CODE</div>"); else $(".entry-content:first-child").before("<div>MY CUSTOM CO... | Check if first paragraph is an image, then show custom code right after it? | wordpress |
I have been using this code for a long time : <code> $temp_arr_content = explode( " ", substr( strip_tags( get_the_content() ), 0, 720 ) ); $temp_arr_content[count( $temp_arr_content ) - 1] = ""; $display_arr_content = implode( " ", $temp_arr_content ); echo $display_arr_content; if( strlen( strip_tags( get_the_content... | First, I wouldn't modify the string/word length of the content . Semantically, you're dealing with an excerpt , so let's focus on that. Second, to limit the number of words returned for the excerpt, simply filter <code> excerpt_length </code> : <code> <?php function wpse52673_filter_excerpt_length( $length ) { // Re... | How to correctly limit the content and strip HTML? | wordpress |
I'm wondering if is possible to change the text "Enter title here" based on the post format that you selected? For example: If you select the post format Quote than your text will be "Enter author's quote". Is that possible? | You need to do the following; <code> jQuery(document).ready(function( $ ) { $('input.post-format').click(function(){ $('#title-prompt-text').val( $(this).next('label').text()); }) }); </code> This will replace the title with whichever post format you select. Save the above into a file called <code> custom-post-title.js... | Changing "Enter title here" based on post format | wordpress |
In my plugin's <code> init </code> function <code> load_textdomain( 'myplugin', ABS_PATH_TO_MO_FILE ); // OK load_plugin_textdomain( 'myplugin', false, ABS_PATH_TO_LANGS_DIR); // No effect echo( __('Test', 'myplugin') ); </code> In the code above, the load_textdomain works, but not load_plugin_textdomain, any idea? | Looking at the source <code> load_plugin_textdomain </code> takes three arguments: <code> load_plugin_textdomain( $domain, $abs_rel_path = false, $plugin_rel_path = false ) </code> It seems you are passing the absolute path to your language domain, as a relative path. Try: <code> load_plugin_textdomain( 'myplugin', ABS... | Why load_textdomain work but not load_plugin_textdomain? | wordpress |
I'm trying to use an existing plugin in order to make my posts print friendly. I haven't got any support from the plugin developer. I think I have narrowed down the script to the function that places the 'Print' text in the posts. Problem is that this plugin places the 'Print' button automatically. But I would like to ... | <code> remove_filter( 'the_content', 'printme_add_link' ) </code> will prevent the link from being placed. You can just call <code> printme_add_link() </code> in your template to generate the print button. Alternately, you can just <code> add_query_arg( 'print', 1, get_permalink() ) </code> and use that as the link if ... | Making a wordpress page print friendly | wordpress |
I use WordPress SEO by Yoast, especially for the Google News sitemap feature. My theme is coded in such a way that the main image of a post is also the featured image of the point (i.e. the same image, but a different size, is shown for post thumbnails). That's the design decision I had to make (for various reasons I c... | Apparently, there's no way. UPDATE! Joost De Valk, the author of WordPress SEO by Yoast, modified how the plugin works on my request in the plugin's support forums. So, problem solved! | Plugin scans for images in post_content, how about "featured image"? | wordpress |
When a script times out, and there is nothing you can do about it ( cause it's running on a bloddy shared hosted resource where you have 0 control over the script time-outs ), can you run register shutdown or something to that effect? You may ask what on earth does this question have to with wordpress... Well, it kind ... | I faced with the same issue when I was writing my backup plugin. The bug appear when you fetch all data from db by calling <code> $wpdb->get_results( ... ) </code> . And as you can suppose it fetch all data into memory allocated for php. The better approach is to use <code> mysql_* </code> functions to fetch row one... | Allowed memory size of 33554432 bytes exhausted (tried to allocate 9967617 bytes) in ...\wp-includes\functions.php | wordpress |
Explaining my goal: I would create the title by taking the first words of the post content. Ex: In the Admin interface would be the title field blank and the first 10 words of content would be sent as a title when creating a new post. Thanks for any help. | I have written a small plugin exactly for that some time ago. It hooks into <code> 'save_post' </code> and takes the first 20 characters as title if there is no title set already: <code> add_action( 'save_post', 't5_fix_empty_title', 11, 2 ); /** * Fills an empty post title from the first words of the post. * * @param ... | Take excerpt of the content of the post and send it as the title to create new post | wordpress |
My theme currently has a single menu on the left hand sidebar of WP admin. I want to include submenus on that menu. How can I add, for example, a single submenu item to the "Theme Options" menu below? <code> add_menu_page( "My Theme Options", "Theme Options", 'edit_themes', basename(__FILE__), 'my_admin', get_bloginfo(... | To do that, you would use <code> add_submenu_page() </code> . But I would strongly recommend against making submenu pages for Theme options. To begin with, you should be using <code> add_theme_page() </code> for your Theme options page, so that your Theme options page itself is properly placed as an Appearance sub-menu... | Add submenus to Theme options menu | wordpress |
I just installed a WP plugin cron-view I can't find where it is or what it's actually done. When going to the install directions though - http://wordpress.org/extend/plugins/cron-view/installation/ I get: "Upload your post template files (see the Description for details on configuring these), and choose them through th... | After activation, the plugin is available under the Tools menu > What's in Cron? The text telling you to upload template files is from another one of his plugins, custom post template , looks like a little copy / paste error there. Cron View has no template files to move. | When Installing a Plugin Where do I Move Template Files to? | wordpress |
Basically I am coding my own theme, and I would like to have my titles listed on the left hand side, so that on clicking the title, the corresponding body opens up on the right. How can I list these two interlinked items separate from each other, but still have the title reference the right post. The problem I'm antici... | Here is an idea: Use <code> get_posts() </code> to get posts you want. On the right hand side show titles via <code> foreach </code> . use <code> setup_postdata() </code> on right hand side loop to get post content. You can use jquery tabs to show and hide post content or just use jquery. Don't do <code> get_posts() </... | Is there a way to separate wordpress titles from their posts? | wordpress |
EDIT 2: How would I iFrame wp_nav_menu contents while maintaining the styles and script associated with their display? (Please ignore all of the below seemingly confusing context of why someone would want to do this.) EDIT 1: This question is related to WordPress's wp_nav_menu. My client is very interested in sculpting... | To get a working nav menu WordPress needs to be set up complete. My suggestion is to use <code> add_feed() </code> . Ignore the name, you get <code> text/html </code> as output. Let's start with code <code> <?php # -*- coding: utf-8 -*- /* Plugin Name: T5 Iframe Nav Menu Description: Display a nav menu in an iframe.... | WordPress wp_nav_menu within iFrame | wordpress |
So I understand that I can user current_user_can to check the role of the current logged in user. But what I would like to do is show these different fields to the site Admin. So for example the contributor role may have different custom fields than the subscriber. Each role would see their relative fields but the Admi... | I'll post whole code which have to be in functions.php it's legit WP valid code, how it should be done :) This should work, of course you have to put your role name in switch. UPDATED FOR PERFORMANCE: <code> add_action( 'show_user_profile', 'user_fields_for_admin', 10); </code> <code> add_action( 'edit_user_profile', '... | Different fields in My Profile page depending on user role | wordpress |
Well, I think the question might be a bit confusing. But well, I want to get the recent 4 posts, ignoring the first five recent posts. So in short the sixth, seventh, eighth and ninth - most recent posts. | Simple. WordPress provides a function called <code> get_posts() </code> that lets you get posts in any order. Basically, <code> get_posts() </code> will retrieve the 5 most recent posts by default. To get 4 posts, ignoring the 5 most recent, you'd set the <code> numberposts </code> and <code> offset </code> parameters ... | How to get 4 Posts after the 5 most recent ones | wordpress |
I had look at the code but I couldnt see any escaping on funcions like <code> the_title </code> <code> the_content </code> <code> the_excerpt </code> etc. I might not be reading it right. Do I need to escape these functions in theme development like: <code> esc_html ( the_title () ) </code> Edit: as pointed out in the ... | Escaping depends entirely on the context in which you are using the functions. What is safe for displaying inside <code> <h1> </code> tags, is not necessarily safe to display for the <code> value </code> attribute of an input field, and even that wouldn't necessarily be safe as a <code> href </code> attribute val... | Should I escape wordpress functions like the_title, the_excerpt, the_content | wordpress |
i would like to find the source code of the widgets , would you know where to find them? I found the class WP_Widget, but i would like to find, for example, the widget with the last articles. Thanks | The default widgets are defined in <code> wp-includes/default-widgets.php </code> . To find specific code search the Codex or use queryposts.com . The best tool is your IDE (integrated development environment). All IDEs offer a full text search in a set of files. Here a screen shot from Eclipse PDT As you can see it is... | Where to find the source code of a widget? | wordpress |
I want to use the following code <code> the_time('d. F Y', '<p class="article-date">', '</p>'); </code> to show the date of an article (post) wrapped within <code> <p></p> </code> . I also tried <code> echo '<p class="article-date">' . the_time('d. F Y') . '</p>'; </code> but again t... | <code> <p> <?php the_time() ?> </p> </code> It helps with separation of concerns and increases readability of code as well as being consistent with WordPress coding standards and the default coding style. The first method you attempted is completely invalid, <code> the_time() </code> only accepts 1 pa... | the_time() cannot be placed correctly | wordpress |
I am trying to override <code> wp_insert_comment() </code> (wp-includes/comment.php). I added the following lines of code in my <code> functions.php </code> file, located in my theme : <code> add_filter('wp_insert_comment', 'my_insert_comment'); function my_insert_comment($commentdata) { /* Some stuff */ } </code> Here... | You can't override it, because this function is not pluggable and is a part of WP core. All what you can do is to add your hook for action <code> wp_insert_comment </code> , as you've actually done. | How to override wp_insert_comment() | wordpress |
how can I use the in_category for custom post types? here is my code. <code> <?php get_header('shop'); ?> </code> ?> <code> <?php if ( have_posts() ) while ( have_posts() ) : the_post(); global $_product; $_product = new jigoshop_product( $post->ID ); ?> <?php do_action('jigoshop_before_single_product... | Using <code> in_category </code> here is the correct function to use (it doesn't distinguish between post types). The second argument accepted by <code> in_category </code> is the post ID or object - but in this case, can be omitted as we are using it inside the Loop. The first argument is the Category ID (as an intege... | in_category for custom post types | wordpress |
I'm writing a custom function that allows the posts to be sorted based on a custom field. When the user submits the "sort by" form, the meta_key (as well as orderby and order) parameters by which the posts should be sorted is stored in a $_SESSION variable. I'm using the pre_get_posts action to hook into my function. T... | If you change your if statement to use <code> $query->is_main_query() </code> like the example on the <code> is_main_query() </code> codex page , does that resolve the issue? The nav menus are created by a query, so usually this problem stems from the pre_get_posts interfering with the menus query. Hence, I wonder w... | Adding meta_key via pre_get_posts causes navigation to disappear | wordpress |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.