_id
stringlengths
1
6
title
stringlengths
15
150
text
stringlengths
37
32.3k
123270
Prevent Indexing of 404 Page
I'm tryying to prevent search engines from indexing my 404 page which is in a template called 404.php. I do not create an actual page, I simply rely on the php template for my 404 errors. I'm using the code below and it's not working, I'm unsure what the best way to go about this is and I would appreciate help. <?php if(is_single('404.php')): ?> <META NAME="ROBOTS" CONTENT="NOINDEX, NOFOLLOW" /> <?php endif; ?>
99859
Control content before and after custom post type loop
I am trying to create a left nav menu that contains a couple of different taxonomy lists of a custom post type. For example, the left menu might look like this... <h2>New Stuff</h2> <ul> <li>Item 3</li> <li>Item 4</li> </ul> <h2>Old Stuff</h2> <ul> <li>Item 2</li> <li>Item 1</li> </ul> Below is the code I currently have in my sidebars template... <h2>New Stuff</h2> <ul> <?php $args = array( 'post_type' => 'stuff', 'taxonomy' => 'stuff-type', 'term' => 'new-stuff', 'orderby' => 'date', 'order' => 'DESC', 'posts_per_page' =>-1 ); query_posts($args); if ( have_posts() ) : while ( have_posts() ) : the_post(); ?> <li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li> <?php endwhile; ?> <?php else : ?> <?php endif; ?> </ul> <h2>Old Stuff</h2> <ul> <?php $args = array( 'post_type' => 'stuff', 'taxonomy' => 'stuff-type', 'term' => 'old-stuff', 'orderby' => 'date', 'order' => 'DESC', 'posts_per_page' =>-1 ); query_posts($args); if ( have_posts() ) : while ( have_posts() ) : the_post(); ?> <li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li> <?php endwhile; ?> <?php else : ?> <?php endif; ?> </ul> This all works fine expect that I need the h2 and ul tags to not appear if there are no posts assigned to the taxonomy. How can I get the opening h2 title and ul wrappers somehow in the WordPress loop (just before and after), leaving the else/endif statement to print nothing (printing nothing if there are no posts for that taxonomy)?
57663
Compare current post Category in select menu
i have done this many times but not via a form so i am getting a weird issues when trying to assign a "selected" based on the current post term id... Maybe the use of get_the_category and then get_categories creates a conflict? Any one has any idea as to why this might happen? No matter what the selected item is the last one and not the Current post (get the post id via an outside form) category Here is my code: <?php $postId = $_POST['postid']; // the value is recieved properly $currentCategory = get_the_category($postId); // the value is recieved properly $currentCategoryId = $currentCategory[0]->term_id; // the value is assigned properly $categories = get_categories('hide_empty=0'); // the value is recieved properly $optionname = "postcats"; // the value is recieved properly $emptyvalue = ""; // SELECET DROP DOWN TERMS echo '<select name="'.$optionname.'" class="clientList"><option selected="'.$selected.'" value="'.$emptyvalue.'">'.__('Choose a category','sagive').'</option>'; foreach($categories as $category){ // next line seem to not work! if($currentCategoryId == $category->term_id) {$selected = 'selected="selected"';} echo '<option name="'.$category->term_id.'" value="'.$category->term_id.'" '.$selected.'>'.$category->name.'</option>'; } echo '</select>'; ?> . **if i try to echo the $currentCategoryId outside the foreach it works but not inside it.. kinda wierd!** Your help would me most appreciated.
57669
Retrieve featured image
We are building an Android app based on a Wordpress mysql database. We were able to get most of the information from the datase to display on to the app. Now all we have left is to retrieve the posts featured image. Is there a way to have the featured image output a URL? Thanks!
99852
Display Posts with template on a Page
OK, I'm sure some WP pros here will think this is a dumb question, and I'll probably get some flak, but I have actually read plenty of documentation, and I just don't think I'm even going in the right direction, anymore. I am somewhat experienced with PHP, but i have little experience with wordpress. My client bought a WP theme-- and the theme has a built-in template for _posts_ - However, when I used the suggested method `query_posts()` - the template was stripped from the post content when displayed on the page. SO, what methods do I use to include the other parts of the template? I've checked a few files like posts.php and post_template.php -- but it seems like I'm not even going in the right direction. So whatever help anyone can offer would be fantastic-- I think if I got going in the right direction, I could figure out the trickier details, like how to include aspects of the template only once, even though I want to display 5 posts at a time on this page-- But if you know something different has to be done for that, then I REALLY appreciate the help.
122801
Ajax with jQuery UI dialog not working
I am trying to update my custom database table when changes are made in a dialog box. The script for the dialog box and ajax call is as follows - jQuery(document).ready(function($){ $("td > span").click(function(){ var id = $(this).attr('id'); var message = "message"+id; var content = jQuery("#"+message).text(); var $dialog = $("<div></div>").html("<textarea style='width:99%; height:90%' class='popup-content'>"+content+"</textarea>").dialog({ height: 400, width: 400, title: 'My Data', modal: true, autoOpen: false, dialogClass: 'wp-dialog', buttons: { "Save": function(){ $("#"+message).html($(".popup-content").val()); $.ajax({ type: "post", url: script_data.admin_ajax, data: { action: "feedmng_update", feed_id: id } }); } } }); $dialog.dialog("open"); }); }); The above script works all well but for the Ajax part. The above code is a separate javascript file which I even enqueue in my php file. The following is the Ajax call related code to update database having the id passed during the Ajax call - function __construct(){ add_action( 'wp_ajax_feedmng_update', array( &$this, 'feedmng_update' ) ); add_action( 'init', array( &$this, 'feedmng_load_scripts' ) ); } function feedmng_update(){ global $wpdb; $feedid = $_REQUEST["feed_id"]; $wpdb->update( $wpdb->feedmanager, array( 'message' => "New data" ), array( 'id',$feedid ) ); } function feedmng_load_scripts(){ wp_enqueue_script( 'jquery' ); wp_enqueue_script( 'jquery-ui-core' ); wp_enqueue_script( 'jquery-ui-dialog' ); wp_enqueue_style ( 'wp-jquery-ui-dialog' ); wp_register_script( 'feedmng-popup', WP_PLUGIN_URL.'/feed-manager/mypopup.js', array( 'jquery', 'jquery-ui-core', 'jquery-ui-dialog' ) ); wp_enqueue_script( 'feedmng-popup' ); wp_localize_script( 'feedmng-popup', 'script_data', array( 'admin_ajax' => admin_url( 'admin-ajax.php' ) ) ); } **EDIT** Added the following to the script, console shows "Success" success: function(){ console.log("Success"); } My table name is wp_feedmanager and I am trying to update it's 'message' column. But it just wont update ? Any suggestions what should be done ? **For future reference -** The problem was here - The third parameter of update query should be **array( 'id' => $feedid )** Also the EDIT regarding tablename suggested by Milo needs to be included !
99854
Run two concurrent themes in one installation
I'm trying to add a 'blog' to my established and customized wordpress installation. Goal is to have a blog page that runs a child theme of TwentyTwenty, pulling any post of the category "blog-posts" I currently our blog running on a different wordpress installation, but for various reasons, including database unity, I'd like to merge my primary domain (sequoiawaste.com) with my blog.sequoiawaste.com installation, and let visitors browse at sequoiawaste.com/blog Thats not a complicated matter at all, I just did a standard Export/Import. Its the formatting/presentation that I'm struggling with. I would GREATLY prefer to stick with a child theme of TwentyTwenty for the blog, but maintain the custom theme that organizes the rest of the site... It does not seem that this is a common or even remotely encouraged thing to do in the WP community. I've tried a few plugins that claim to override the Theme for Pages or Posts, but they do not respect a child theme what so ever, and I'm not interested in some of TwentyTwenty's less-than-optimal defaults **cough Header/footer** Does anyone have some guidance here? I need to avoid Multisite due to financial reasons (my host charges 10x more for that, and its totally unnecessary given my small audience). Child Themes dont technically work here, because my default parent theme is _not_ TwentyTwenty... and I simply cannot find a plugin that can help properly here. Most can override a single page, but something like /blog/page/2 comes across with no formatting, etc etc. Any suggestions are appreciated!
134193
Do we need to escape data that we receive from theme options?
I'm creating a Wordpress theme that I'm hoping to sell on Themeforest. Now I know much about escaping user inputted data using functions like esc_html, esc_url and so on and I use them in the comments template and few other places in my theme. What I'm not sure about is whether I'm suppose to use these functions on the data that I get from the database that the user inputs using the theme options or not. As it is still user inputted data, except that it goes through the database, before we echo it out. I'm using the Redux Framework to create the theme options for my theme, and I have all the settings in a global variable: $mytheme_options. And to sum up my confusion, if I want to show the logo image, do I do it like this: img src="<?php echo $mytheme_options["logo_url"]; ?>" /> Or Like this: img src="<?php echo esc_url($mytheme_options["logo_url"]); ?>" /> I've search around for this but didn't find any article that discusses about what to do about the user-inputted data that comes from the database. I've also looked into the code of other themes and they don't seem to escape it. But I'm not sure how they insert options in the database, which I think would somehow determine whether to escape that data or not.
156769
global wp_query returning wrong post vars
I am currently filtering the_posts to recreate wordPress' "sticky post" function for custom post types. I also have to make sure that the sticky post is attached to a certain taxonomy term that matches that current query, so I'm trying to grab the query_vars from the $wp_query global in this filter so I can compare the terms attached to each sticky post object to the current queries query vars. I have this working fine on my archive template, where this is the main query, but I have a custom page template that has a listing of two post type archives and it's getting tripped up. When I debug $wp_query it shows that the query_vars attached to that object are for the parent page, and not the current query. I am resetting post_data everywhere I should be, but I just can't seem to get the correct query_vars. I can't really post code snippets for this since there are so many moving parts, and I don't think anyone would really want to go through all of it. Just trying to see if anyone has had a similar issue, or if there is another way to grab the query vars? It looks like the $query variable is not being passed to this function in core.
105638
How to remove slug from hierarchical custom types in 3.5.2
I know that is not suggested and that there is lots of discussion about this argument out there. Unfortunally, after a week of trying and tests, I have not managed to remove the slug from my custom type yet. Here's the situation: ## The url structure I need * post **/blog/my-blog-post** [ok!] * pages **/parent-service/service** [ok!] * portfolio **/portfolio/my-first-work** [ok!] * static **/parent-static-page/static-page** [<<<--- here is the problem] ## My configuration * Wordpress 3.5.2 * Custom type 'static': hierarchical; without any 'rewrite' rule. * Custom type 'portfolio': not hierarchical; 'rewrite' => array( 'with_front'=> false ) * Permalink structure: /blog/%postname%/ * As front page I set the static page 'blog' ## The problem * post **blog/my-blog-post** [ok!] * pages **/websites/dynamic-websites** [ok!] * portfolio **/portfolio/my-first-work** [ok!] * static **/who-i-am/terms** [<<<--- here is the problem] ## What I've tryed ### Nothing At the beginning, as expected, the url of the 'static' post "My test page" is **/blog/static/my-test-page** ### 'rewrite' => array( 'slug'=>'', 'with_front'=>false ) I've removed the front from the url...good! Now I've **/static/my-test-page** ### 'rewrite' => array( 'slug'=>false, 'with_front'=>false ) It doesn't remove the slug. I have **/static/my-test-page** yet. ### 'rewrite' => array( 'slug'=>'/', 'with_front'=>false ) It removes the slug! Now I have **/my-test-page**. Unfortunally **all the pages return me a 404 error**. ### 'Remove slug from custom post type' plugin Even though it works only if my permalink structure is /%postname%, I've tried to install this plugin and change my permalink structure to do a test. It works, but unfortunally **doesn't respect the hierarchical nature** of my 'static' type. ### The tutorial by Joakin Lim It doesn't work. In particular, after adding `function book_rewrite_rule()` it says that my custom type now will be accessible from **/my-test-page** as well as **/static/my-test-page** , but it doesn't work for me. I can access only from **/static/my-test-page**. I've tryed also to apply all the tutorial, also doing some changements and tests, but without success ### The tutorial from vip.wordpress If I change 'event' with 'static' in both functions, I can access my page from **blog/parent-page/my-test-page**. If I add 'rewrite' => ( 'with_front'=>false ) everything brokes and I can access only from **static/parent-page/my-test- page** ### Other solutions and tests Unfortunally, with my actual reputation, I can't link more than two links. But I've tryed also the solution found in ryansechrest.com, shibashake.com and - of course - ALL the questions posted in this portal before. Off course every time I've flushed all the permalinks rules, visiting the setting page, saving the options, changing them twice and save them again, using the `global $wp_rewrite; $wp_rewrite->flush_rules();`. I've tryed lots of combination with the 'rewrite' array and the different solutions above. Have you any suggestion?
52101
Media Library, hook on delete user action
I need to run my function when a user deletes a media file from the media library. Is there a hook I can use? Would appreciate it if someone could please point me to the right direction. Thanks!
52100
Wordpress permanent links not working (the weird way)
I have just moved my dev wordpress to its new home, and something very weird happened: Some, just some, of the links are not working (for example, the domain.com/contact page is not working while other pages are working). They are all pages (and some are categories links as well), some working, some not, no pattern it seems. I wonder if there is something wrong with the host, godaddy (the host) is infamous with this it seems. But usually the whole thing should not work, here we have some work, some dont't. Any idea will greatly help. PS: by not working, I meant I was show godaddy default 404 pages. How does this happen I dont even understand. PS again: dang it, I found out why. I have a file named contact.php, after i renamed it old.contact.php it seems to work now. Weird, I mean the htaccess redirection rules should not match contact/ with contact.php right? Is it just goddady or ? # BEGIN WordPress <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] </IfModule> # END WordPress
52107
Does WP identify plugin by plugin name or plugin_basename?
I see from the activation link, wordpress is using the plugin's dir. Also, when many plugins use add_action to hook on activation, they use add_action('activate_' . plugin_basename(), 'name_activation'); If the plugin dir is word/ , the plugin name is Press, then, this will be: add_action('activate_word', 'press_activation''); So, WP identify the plugin as "word" or "press" ? I know that by using 'activate_word', WP gets to know which file to activate. I also tested that the "Press" got activated and running. But, is there any potential trouble to consider?
141848
Redirection on Custom page
1. I have created login page template and created the login page through wp-admin->pages. here I select the template 'login' 2. Now I need to redirect user on this page if somebody haven't logged in. wp-admin login and this login page are separate. there is no relation if someone logged in wp-admin or not. 3. The code which I am using as follows, FireFox redirect me to error page saying "The page isn't redirecting properly". if ( !is_admin() ) { if(!isset($_COOKIE['login_token']) || $_COOKIE['login_token']=='') { //echo $_COOKIE['login_token']."KKKKKKKRRRRRRRR"; $login_page = home_url('/login/'); // Two things happen here, we make sure we are on the login page // and we also make sure that the request isn't coming from a form // this ensures that our scripts & users can still log in and out. //if( $page_viewed == "wp-login.php" && $_SERVER['REQUEST_METHOD'] == 'GET') { // And away they go... wp_redirect($login_page); exit(); } $username=$_POST['log']; $password=$_POST['pwd']; echo $_COOKIE['login_token']; // try to log into the external service or database with username and password //$ext_auth = try2AuthenticateExternalService($username,$password); //echo "<pre>"; print_r($ext_auth); echo '</pre>'; // if external authentication was successful $ext_auth[0] = 'success'; if($ext_auth[0]=='success') { // find a way to get the user id $uname = explode('@',$username); $user_id = username_exists($uname[0]); // userdata will contain all information about the user //$userdata = get_userdata($user_id); //$user = wp_set_current_user($user_id,$username); // this will actually make the user authenticated as soon as the cookie is in the browser //wp_set_auth_cookie($user_id); $path = parse_url(get_option('siteurl'), PHP_URL_PATH); $host = parse_url(get_option('siteurl'), PHP_URL_HOST); //$expiry = strtotime('+1 month'); $expiry = time() + (60 * 1); setcookie('login_token', $ext_auth[0], $expiry, $path, $host); // the wp_login action is used by a lot of plugins, just decide if you need it do_action('wp_login',$userdata->ID); //determine WordPress user account to impersonate // you can redirect the authenticated user to the "logged-in-page", define('MY_PROFILE_PAGE',1); f.e. first //header("Location:http://executiveboard/audit-blog"); return 'success'; } } }
141849
When to use esc_html and when to use sanitize_text_field?
It seems that they do almost same type of job. So... When should I use `esc_html()` instead of `sanitize_text_field()`?
105633
List posts based on First letter of Posts
I want add a Pagination [A] [B] [C] [D] **[E]** [F] [G] [H] [I] [J] [K] [L] [M] [N] [O] [P] .......[Z] * * * **Easy Post Title** - By Admin on 2013 post content....bla bla bla... **Example Post - Another Test** - By Admin on 2013 post content....bla bla bla... ... ... ... * * * [A] [B] [C] [D] **[E]** [F] [G] [H] [I] [J] [K] [L] [M] [N] [O] [P] .......[Z] Can anyone help - how can i do this on both loop.php and search.php { i want show alphabetic index to search only posts with starting letter = [E] for example. Right now if i search with E it search for any match, title+content+part of title... Thanks in advance
52108
custom menu widget where menu title is a link
I am looking for, like the title of this question indicates, a custom menu in wordpress where the menu title itself is a link. It seems like a very simple thing, but after a lot of searching I've come up with nothing. More explanation: Here is what I have: My Custom Menu Link 1 (goes to page 1) Link 2 (goes to page 2) Link 3 (goes to page 3) Here is what I want: My Custom Menu (goes to w/e page I choose to link it to) Link 1 (goes to page 1) Link 2 (goes to page 2) Link 3 (goes to page 3) Simple, right? So, is there a plugin for this, or do I need to write on?
105635
Fatal error: Out of Memory? (17mb used?)
Fatal error: Out of memory (allocated 47185920) (tried to allocate 1922682 bytes) in /homepages/35/d289582498/htdocs/reeks/wp-includes/post.php on line 2850 I have a Wordpress website, setup with a custom theme. I have approximately 29 posts published; and 2 pages; today I go to create a new post and the above error is resolving? I have just tried adjust my memory limit via the htaccess file and it now looks like below; but I am still getting this error. # BEGIN WordPress <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] </IfModule> <IfModule mod_php5.c> php_value memory_limit 64M </IfModule> # END WordPress **I have ALSO; just tried using a 'Memory Increase' Wordpress plugin - increasing the memory to 100MB and still the above error appears; any suggestions?**
141843
How to show a custom taxonomy using a custom template
I've been playing around the custom taxonomy and custom post types. I've been able to get the post type working fine, with my slug as I need. However, creating a taxonomy page (e.g. taxonomy-????) I receive a 404 error page. I'm sure I did something wrong, and this is possibly due the fact both my slug lines are the same. 'rewrite' => array( 'slug' => 'faqs/archivio' ), However, the custom taxonomy URL is correct in both cases, so this could be due to the fact the page taxonomy-[customtaxonomy].php file, but I have created one. I have also forced WP to refresh the taxonomy so I can't figure out what's the problem. Any help?
105637
Is WordPress' is_user_logged_in() secure?
I've been wondering about this for a while. Is the following `if` statement safe enough? Is it easy to break through the code and get access to the content when not logged in? <?php if ( is_user_logged_in() ) { // SECURE CONTENT } else { // LANDING PAGE } ?>
105636
Not Being Indexed by Search Engines
Is there a specific criteria based on which search engines index/not index your site/blog? If my whole blog (2/3 pages-10-20 posts) is not indexed(WordPress), what can I do? My blog has is not indexed by Google/Bing. Any suggestions.
69642
WP_Http_Cookie destroys cookie value through urldecode()
**Background** : Working on a Widget that uses a remote API using `wp_remote_post` to log into the service, once logged in storing the cookies received for the second request to query data with `wp_remote_get`. **Problem** : The cookies from the first request are stored in the response as WP_Http_Cookie objects and their values are run through `urldecode` as seen in class-http.php. One of the cookies has an original value of `l0xl4+7abTT2St+1UVA` thanks to the `urldecode` this value becomes `l0xl4 7abTT2St 1UVA` in the WP_Http_Cookie object and therefore is not the same. This makes the cookie object unusable as is for the second request. **Workaround** : I came up with a nasty little workaround for this problem: // Replace space with + from cookie value // because WP_Http_Cookie does urldecode( value ) $response['cookies'][0]->value = str_replace(' ', '+', $response['cookies'][0]->value); // Set cookies for the second request $this->cookies = $response['cookies']; **Question** : Does anyone know why there is an `urldecode` instead of a filter in WP_Http_Cookie? Should I file a trac issue?
102941
Remove from array in WP_Query loop
I have a number of pages with a tag of 'word'. For each of these pages I want a btn/Div on the home page linking to that page. This button will display a random word from an array. I want the word on each button to be different so I have picked a random word in the array and then deleted that word. My problem is the word isn't deleted from the array - if I echo the array count on each loop it stays the same. How can I pick a random word form the array and then delete that word. <?php $frontAgrs = array( 'post_type' => 'page', 'tag' => 'word', 'order' => 'ASC' ); $frontLoop = new WP_Query($frontAgrs); if($frontLoop->have_posts()): while($frontLoop->have_posts()): $frontLoop->the_post(); /*----Phrase-------------*/ $phrases = ['Hello Sailor','Acid Test','Bear Garden','Botch A Job','Dark Horse', 'In The Red','Man Up','Pan Out','Quid Pro Quo','Rub It In','Turncoat', 'Yes Man','All Wet','Bag Lady','Bean Feast','Big Wig']; $rand_Num = array_rand($phrases); $rand_phrase = $phrases[$rand_Num]; unset($phrases[$rand_phrase]); echo count($phrases); ?> <?php echo '<div><a href="'.get_permalink($post->ID).'"><p>'.$rand_phrase_value.'</p></a></div>' ?> <?php endwhile; endif; ?> <?php wp_reset_postdata(); ?>
102946
Read more redirection problem
I have tried <?global $more; $more = 0;?> On pages and read more link shows but the full content is not shown. If I click read more it remains on same page. Logically I'm supposed to taken to `index.php`, but why not?
102947
do_shortcode within a shortcode
This may sound a little confusing but I'll try my best to explain. I've made a shortcode that grabs the content of a post (when given the id), it looks like this: $post_id = $id; $queried_post = get_post($post_id); $postcontent = $queried_post->post_content; $title = $queried_post->post_title; I then have another variable which puts a few things together and gets returned: $finaloutput = $title . $postcontent; What I want to do is be able to run shortcodes withing `$postcontent`, so when a post is fetched any shortcodes within that post will display. I tried running `do_shortcode` on the `$postcontent` variable but it caused the page to literally not load at all. Any ideas?
102945
WP Redirect is not working
I am trying to redirect to another URL using this code-- $siteurl= get_site_url(); //echo " This is basic property search.... now redirecting"; //echo "\n\n Redirect URL for property posts=" + $redirecturl; wp_redirect( "http://" . $siteurl . "?post_type=property&search_keyword=" + $search_keyword . "&submit=Search" . "&price-min=" . $price_min . "&price-max=" . $price_max . "&city=" . $address_city . "&state=" . $address_state . "&zip=" . $address_zip . "&beds=" . $beds . "&baths=" . $baths); But this is where the redirection is happening-- http://dimitri.clientdemos.pw/105&submit=Search&price-min=&price-max=&city=&state=&zip=&beds=&baths= What am I doing wrong here? Why is the correct URL not being used for redirection?
60016
How to recover pages from site with only ftp?
I have lost http access to my site and i need to recover pages from it. Is there a way?
143995
getarchiveswhere filter returning correct results, but wrong permalink
possible duplicate of Custom Post Types and archives I'm using `getarchives_where` filter to return custom post type archives in a template. function Cpt_getarchives_where_filter( $where , $r ) { $post_type = 'news-article'; return str_replace( "post_type = 'post'" , "post_type = '$post_type'" , $where ); } And then in my template I've used: add_filter( 'getarchives_where' , 'Cpt_getarchives_where_filter' , 10 , 2 ); wp_get_archives(); remove_filter('getarchives_where' , 'Cpt_getarchives_where_filter' , 10 ); The template returns a list of links with correct counts, but the permalink is incorrect. It returns http://localhost/openminds/2014/03/30/ where it should return: http://localhost/openminds/archive/market-intelligence/news/2014/03/30/ Any suggestions on what could be causing this or how to modify these links is greatly appreciated. Thanks.
130993
list taxonomy terms in current post / current category
i need to display taxonomy terms in a custom post and also in archive / category page of that post type. terms must be from current post or current category http://stackoverflow.com/questions/15502811/display-current-post- custom-taxonomy-in-wordpress code in this thread works for only single post, can i make it work in archive / category page too pls.
143993
How to disable tag url rewriting on homepage (on others it works)?
Wordpress is able to handle posts selection by multiple tags: This url shows all posts from **category fruit** AND (with **tags apple OR orange** ) http://www.example.com/category/fruits/?tag=apple,orange This also works for the main page (posts from all categories) http://www.example.com/?tag=apple,orange * * * BUT when selecting **one tag after another** starting with **apple** : http://www.example.com/?tag=apple Wordpress rewrites the URL to: http://www.example.com/tag/apple/ THIS applies only to **main page** , for categories it won't rewrite. * * * Is it somehow possible to stop the rewriting for the main page?
60013
How to check for images before echo
I have the following code in attempt to check for an image before an echo. The reason for doing so is if there is no image it won't echo anything and there won't be a missing image link put in a post that has no image. However this code does not work and when no image exists a missing image icon is added. Is there another way to solve this. <?php $image = wp_get_attachment_image_src(get_field('post_image1'), 'thumbnail'); ?> <img src="<?php if($image !=false) echo $image[0]; ?>" alt="<?php get_the_title(get_field('post_image1')) ?>" /> <?php $image = wp_get_attachment_image_src(get_field('post_image2'), 'thumbnail'); ?> <img src="<?php if($image !=false) echo $image[0]; ?>" alt="<?php get_the_title(get_field('post_image2')) ?>" />
113140
I want to split this into two functions
This code i will add below is for Custom Fields for Custom Post Type and GMap for Custom Post Type. Currently both are pulled by this function. I want to seperate both. One for Custom Fields and One for Map. Here is the Code: * * * add_action('tmpl_detail_page_custom_fields_collection','detail_fields_colletion'); /* Name : detail_fields_colletion Desc : Return the collection for detail/single page */ function detail_fields_colletion() { global $wpdb,$post,$detail_post_type; $detail_post_type = $post->post_type; if(isset($_REQUEST['pid']) && $_REQUEST['pid']) { $cus_post_type = get_post_type($_REQUEST['pid']); $PostTypeObject = get_post_type_object($cus_post_type); $PostTypeLabelName = $PostTypeObject->labels->name; $single_pos_id = $_REQUEST['pid']; } else { $cus_post_type = get_post_type($post->ID); $PostTypeObject = get_post_type_object($cus_post_type); $PostTypeLabelName = $PostTypeObject->labels->name; $single_pos_id = $post->ID; } $heading_type = fetch_heading_per_post_type($cus_post_type); remove_all_actions('posts_where'); $post_query = null; if(count($heading_type) > 0) { foreach($heading_type as $_heading_type) { $args = array( 'post_type' => 'custom_fields', 'posts_per_page' => -1 , 'post_status' => array('publish'), 'meta_query' => array( 'relation' => 'AND', array( 'key' => 'post_type_'.$cus_post_type.'', 'value' => $cus_post_type, 'compare' => '=', 'type'=> 'text' ), array( 'key' => 'show_on_page', 'value' => array('user_side','both_side'), 'compare' => 'IN' ), array( 'key' => 'is_active', 'value' => '1', 'compare' => '=' ), array( 'key' => 'heading_type', 'value' => $_heading_type, 'compare' => '=' ), array( 'key' => 'show_on_detail', 'value' => '1', 'compare' => '=' ) ), 'meta_key' => 'sort_order', 'orderby' => 'meta_value_num', 'meta_value_num'=>'sort_order', 'order' => 'ASC' ); $post_query = new WP_Query($args); $post_meta_info = $post_query; $suc_post = get_post($single_pos_id); if($post_meta_info->have_posts()) { echo "<div class='grid02 rc_rightcol clearfix'>"; echo "<ul class='list'>"; $i=0; while ($post_meta_info->have_posts()) : $post_meta_info->the_post(); $field_type = get_post_meta($post->ID,"ctype",true); if($i==0) { if($post->post_name!='post_excerpt' && $post->post_name!='post_content' && $post->post_name!='post_title' && $post->post_name!='post_images' && $post->post_name!='post_category') { if($_heading_type == "[#taxonomy_name#]"){ echo "<li><h2>";_e(ucfirst($PostTypeLabelName),DOMAIN);echo ' '; _e("Information",DOMAIN);echo "</h2></li>"; }else{ echo "<li><h2>".$_heading_type."</h2></li>"; } } $i++; } if(get_post_meta($single_pos_id,$post->post_name,true)) { if(get_post_meta($post->ID,"ctype",true) == 'multicheckbox') { $_value = ""; foreach(get_post_meta($single_pos_id,$post->post_name,true) as $value) { $_value .= $value.","; } echo "<li class='".$post->post_name."'><p>".$post->post_title." : </p> <p> ".substr($_value,0,-1)."</p></li>"; }else if($field_type =='radio' || $field_type =='select'){ $options = explode(',',get_post_meta($post->ID,"option_values",true)); $options_title = explode(',',get_post_meta($post->ID,"option_title",true)); for($i=0; $i<= count($options); $i++){ $val = $options[$i]; if(trim($val) == trim(get_post_meta($single_pos_id,$post->post_name,true))){ $val_label = $options_title[$i]; } } if($val_label ==''){ $val_label = get_post_meta($single_pos_id,$post->post_name,true); } // if title not set then display the value echo "<li><p>".$post->post_title." : </p> <p> ".$val_label."</p></li>"; } else { if(get_post_meta($post->ID,'ctype',true) == 'upload') { echo "<li class='".$post->post_name."'><p>".$post->post_title." : </p> <p> Click here to download File <a href=".get_post_meta($single_pos_id,$post->post_name,true).">Download</a></p></li>"; } else { echo "<li class='".$post->post_name."'><p>".$post->post_title." : </p> <p> ".get_post_meta($single_pos_id,$post->post_name,true)."</p></li>"; } } } if($post->post_name == 'post_excerpt' && $suc_post->post_excerpt!='') { $suc_post_excerpt = $suc_post->post_excerpt; ?> <li> <div class="row"> <div class="twelve columns"> <div class="title_space"> <div class="title-container"> <h1><?php _e('Post Excerpt',DOMAIN);?></h1> <div class="clearfix"></div> </div> <?php echo $suc_post_excerpt;?> </div> </div> </div> </li> <?php } if(get_post_meta($post->ID,"ctype",true) == 'geo_map') { $add_str = get_post_meta($single_pos_id,'address',true); $geo_latitude = get_post_meta($single_pos_id,'geo_latitude',true); $geo_longitude = get_post_meta($single_pos_id,'geo_longitude',true); $map_view = get_post_meta($single_pos_id,'map_view',true); } endwhile;wp_reset_query(); echo "</ul>"; echo "</div>"; } } } else { $args = array( 'post_type' => 'custom_fields', 'posts_per_page' => -1 , 'post_status' => array('publish'), 'meta_query' => array( 'relation' => 'AND', array( 'key' => 'post_type_'.$cus_post_type.'', 'value' => $cus_post_type, 'compare' => '=', 'type'=> 'text' ), array( 'key' => 'is_active', 'value' => '1', 'compare' => '=' ), array( 'key' => 'show_on_detail', 'value' => '1', 'compare' => '=' ) ), 'meta_key' => 'sort_order', 'orderby' => 'meta_value', 'order' => 'ASC' ); $post_query = new WP_Query($args); $post_meta_info = $post_query; $suc_post = get_post($single_pos_id); if($post_meta_info->have_posts()) { $i=0; /*Display the post_detail gheading only one time also with if any custom field create. */ while ($post_meta_info->have_posts()) : $post_meta_info->the_post(); if($i==0) if($post->post_name != 'post_excerpt' && $post->post_name != 'post_content' && $post->post_name != 'post_title' && $post->post_name != 'post_images' && $post->post_name != 'post_category') { echo '<div class="title-container clearfix">'; //echo '<h1>'.POST_DETAIL.'</h1>'; $CustomFieldHeading = apply_filters('CustomFieldsHeadingTitle',POST_DETAIL); if(function_exists('icl_register_string')){ icl_register_string(DOMAIN,$CustomFieldHeading,$CustomFieldHeading); } if(function_exists('icl_t')){ $CustomFieldHeading1 = icl_t(DOMAIN,$CustomFieldHeading,$CustomFieldHeading); }else{ $CustomFieldHeading1 = __($CustomFieldHeading,DOMAIN); } echo '<h3>'.$CustomFieldHeading1.'</h3>'; echo '</div>'; $i++; } endwhile;wp_reset_query(); //Finish this while loop for display POST_DETAIL ?> <?php echo "<div class='grid02 rc_rightcol clearfix'>"; echo "<ul class='list'>"; if($_heading_type!="") echo "<h3>".$_heading_type."</h3>"; while ($post_meta_info->have_posts()) : $post_meta_info->the_post(); if(get_post_meta($single_pos_id,$post->post_name,true)) { if(get_post_meta($post->ID,"ctype",true) == 'multicheckbox') { foreach(get_post_meta($single_pos_id,$post->post_name,true) as $value) { $_value .= $value.","; } echo "<li><p class='tevolution_field_title'>".$post->post_title.": </p> <p class='tevolution_field_value'> ".substr($_value,0,-1)."</p></li>"; } else { echo "<li><p class='tevolution_field_title'>".$post->post_title.": </p> <p class='tevolution_field_value'> ".get_post_meta($single_pos_id,$post->post_name,true)."</p></li>"; } } if($post->post_name == 'post_excerpt' && $suc_post->post_excerpt!="") { $suc_post_excerpt = $suc_post->post_excerpt; ?> <li> <div class="row"> <div class="twelve columns"> <div class="title_space"> <div class="title-container"> <h1><?php _e('Post Excerpt');?></h1> <div class="clearfix"></div> </div> <?php echo $suc_post_excerpt;?> </div> </div> </div> </li> <?php } if(get_post_meta($post->ID,"ctype",true) == 'geo_map') { $add_str = get_post_meta($single_pos_id,'address',true); $geo_latitude = get_post_meta($single_pos_id,'geo_latitude',true); $geo_longitude = get_post_meta($single_pos_id,'geo_longitude',true); } endwhile;wp_reset_query(); echo "</ul>"; echo "</div>"; } } if(isset($suc_post_con)): do_action('templ_before_post_content');/*Add action for before the post content. */?> <div class="row"> <div class="twelve columns"> <div class="title_space"> <div class="title-container"> <h1><?php _e('Post Description', DOMAIN);?></h1> </div> <?php echo $suc_post_con;?> </div> </div> </div> <?php do_action('templ_after_post_content'); /*Add Action for after the post content. */ endif; $tmpdata = get_option('templatic_settings'); $show_map=''; if(isset($tmpdata['map_detail_page']) && $tmpdata['map_detail_page']=='yes') $show_map=$tmpdata['map_detail_page']; if(isset($add_str) && $add_str != '') { ?> <div class="row"> <div class="title_space"> <div class="title-container"> <h1><?php _e('Map',DOMAIN); ?></h1> </div> <p><strong><?php _e('Location : '); echo $add_str;?></strong></p> </div> <?php if($geo_latitude && $geo_longitude ):?> <!-- Location Map--> <div id="location_map"> <div class="google_map" id="detail_google_map_id"> <?php include_once ('google_map_detail.php');?> </div> <!-- google map #end --> </div> <?php endif;?> </div> <?php } } /* EOF */ * * * And i call using <!--Custom field collection do action --> <?php do_action('tmpl_detail_page_custom_fields_collection'); ?> ## in single-places.php Please help me seperate Custom fields from Map and create function for each to call in the single-places.php seperately
113143
Cannot retrieve theme options on index.php
I have a theme for which I am able to retrieve The theme options on the header.php file by declaring a global variable and save the options in a variable. <?php global $options_name; $options = get_option($options_name); //$options returns the theme options when called on header.php but an empty array on index.php ?> I am returned an empty array when I declare the same global variable and store the options in a variable in index.php of the theme files. How can I retrieve the theme options in index.php file, as it works fine in header.php? here is the header.php file: <?php global $option_name; $options = get_option($option_name); ?> <!DOCTYPE PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd> <html xmlns="http://www.w3.org/1999/xhtml" lang="en-US" xml:lang="en-US" prefix="og: http://ogp.me/ns# fb: http://ogp.me/ns/fb#" > <head> <meta charset="<?php bloginfo('charset'); ?>" /> <meta name="viewport" content="width=device-width" /> <title><?php /* * Print the <title> tag based on what is being viewed. */ global $page, $paged; wp_title( '|', true, 'right' ); // Add the blog name. bloginfo( 'name' ); // Add the blog description for the home/front page. $site_description = get_bloginfo( 'description', 'display' ); if ( $site_description && ( is_home() || is_front_page() ) ) echo " | $site_description"; // Add a page number if necessary: if ( $paged >= 2 || $page >= 2 ) echo ' | ' . sprintf( __( 'Page %s', 'PuraVida' ), max( $paged, $page ) ); ?></title> <link rel="stylesheet" type="text/css" href="<?php bloginfo('template_directory'); ?>/style.css" /> <link href='http://fonts.googleapis.com/css?family=Oswald:400,700' rel='stylesheet' type='text/css'> <script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script> <script src="<?php bloginfo('template_directory'); ?>/js/jquery-dropdown.js"></script> <?php wp_head(); ?> </head> <body <?php body_class(); ?>> <header class="wrap"> <div class="logoarea"> <a href="<?php bloginfo('wpurl'); ?>"><img src="<?php echo $options["logo"]; ?>" /></a> </div> <div class="navmenu"> <?php wp_nav_menu( array( 'container_class' => 'menu-header', 'theme_location' => 'primary', 'fallback_cb' => FALSE ) ) ?> </div> </header> And Here is the index.php file: <?php get_header(); ?> <?php get_sidebar(); ?> <div class="clear"></div> <?php get_footer(); ?>
21932
Why does my custom WP role need edit_posts to edit images?
This may be obvious to someone other than myself. I think I remember reading somewhere that an "image" is indeed a form of "post". * I have a custom post type called "listing" * I have a custom WP role of "client" When I'm logged in as the "client", and I launch the media popup, browse to an image, click "show" to open it up, and then click "edit image", I get a -1. Ie. nothing else displays but "-1". I can fix this issue by assigning my custom role the capability of "edit_posts". Why is this? As soon as I do this, I'm plagued with another problem, the "client" user role now has access to posts, comments & tools, which I don't want. Perhaps I haven't set up my custom post type correctly with the capabilities? How can I allow the "client" to edit the images but not have access to posts? $args = array( 'label' => 'Listing', 'description' => '', 'public' => true, 'show_ui' => true, 'show_in_menu' => true, 'show_in_nav_menus' => true, 'map_meta_cap' => true, 'capability_type' => 'listing', 'capabilities' => array( 'edit_post' => 'edit_listing', 'read_post' => 'read_listing', 'delete_post' => 'delete_listing', 'edit_posts' => 'edit_listings', 'edit_others_posts' => 'edit_others_listings', 'publish_posts' => 'publish_listings', 'read_private_posts' => 'read_private_listings', 'delete_posts' => 'delete_listings', 'delete_private_posts' => 'delete_private_listings', 'delete_published_posts' => 'delete_published_listings', 'delete_others_posts' => 'delete_others_listings', 'edit_private_posts' => 'edit_private_listings', 'edit_published_posts' => 'edit_published_listings', ), 'menu_position' => 5, 'hierarchical' => false, 'has_archive' => false, 'rewrite' => array('slug' => 'listing'), 'query_var' => true, 'supports' => array('title'), 'labels' => $labels );
21933
Getting only the URL of the post thumbnail
I wish to do something as simple as the_post_thumbnail('large') but I want the URL of the image only, not the HTML which goes with it. Is that possible ?
21937
Multi-line captions on attachments
How can I change the 'Caption' text input to text area, to allow for multi line captions on media uploads?
99993
WP Super Cache - max-age
Reading the plugin FAQ: http://wordpress.org/extend/plugins/wp-super-cache/installation/ After you have enabled the plugin, look for the file "wp- content/cache/.htaccess". If it's not there you must create it. It should read: # BEGIN supercache <IfModule mod_mime.c> <FilesMatch "\.html\.gz$"> ForceType text/html FileETag None </FilesMatch> AddEncoding gzip .gz AddType text/html .gz </IfModule> <IfModule mod_deflate.c> SetEnvIfNoCase Request_URI \.gz$ no-gzip </IfModule> <IfModule mod_headers.c> Header set Cache-Control 'max-age=3, must-revalidate' </IfModule> <IfModule mod_expires.c> ExpiresActive On ExpiresByType text/html A3 </IfModule> `` # END supercache The Question is why Header set Cache-Control 'max-age=3, must-revalidate' must be 3 seconds? Shouldn't this be much higher? Can i change this value to let's say 604800 ? This is my own scenario: 1. I dont allow comments 2. I don't have dynamic widgets 3. I post every day but i don't bother if my content is shown a few hours after 4. I run an XML import every week - adding about 500 posts in one hour Quote: Most users will not even notice the cache validation requests, but delivering outdated cache files is much more visible. - I am doing this more for SEO purposes - please look at: http://seobyg.com/http-header/cache-control i think it does matter for SEO to have a high max-age - right ?
109831
Editing Theme Files on Wordpress.com-hosted Site
I'm doing some work for a client on her Wordpress.com-hosted site. I'm used to only working on self-hosted WP sites, and I know how to edit the theme files there, but I'm not sure if it is possible to do this on a Wordpress.com-hosted site. I'm trying to change the way that blog posts are displayed when listing posts from a given category, which I would usually do by going into the theme and editing the relevant php file. Is this not possible with this type of site? Thanks!
141168
Wordpress widget title coding
I have a problem with wordpress widget titles, some widgets are not affected by theme custom encoding. Here is the codes; function ecce_widget_title($title){ if( empty( $title ) ) return ' '; else $title = explode(' ', $title,2); $titleNew = '<div class="title_w"><div class="widget-baslik-ilk"><h3>'.$title[0].'</h3></div><h3>'.$title[1].'</h3></div>'; return $titleNew; } add_filter('widget_title', 'ecce_widget_title'); All widget's titles must be look like this; http://i.imgur.com/DNco35l.png But some widget's titles look like this (just text); http://i.imgur.com/WopRHuX.png Where am i doing wrong? :(
117522
Send user activation email when programmatically creating user
I wondered if someone here might be able to help. Basically, I've created a custom registration form that when validated, inserts a user to the user table. function _new_user($data) { // Separate Data $default_newuser = array( 'user_pass' => wp_hash_password( $data['user_pass']), 'user_login' => $data['user_login'], 'user_email' => $data['user_email'], 'first_name' => $data['first_name'], 'last_name' => $data['last_name'], 'role' => 'pending' ); wp_insert_user($default_newuser); } Now, what I need it to do is rather than sent the confirmation e-mail which I know I can do with the following code. wp_new_user_notification($user_id, $data['user_pass']); I want to send a user activation e-mail instead. I've tried a few things but I cant seem to be able to find anything concrete. Hoping someone might have had this problem before.
19976
Allow users to edit home page from WordPress (home.php problems)
I am wondering how do you create a home page with a custom design like banners different layout from other pages while allowing users to edit it. I used to use `home.php` problem is user cannot edit it ... unless they know PHP. An option will be to create shortcodes for each section of the home page eg. `[banner]`, `[services]` or even an empty tag `[latestBlogPosts]` etc. I dont think its correct. Whats the way of accomplishing this? A quick "mockup" below of a typical home page ![enter image description here](http://i.stack.imgur.com/vQlCl.png) Things like latest blog post and portfolio are dynamic from wordpress.
15708
How to add a user defined hyperlink to the "Featured Image" and the_post_thumbnail()
I've enabled my theme with the ability to display the "Featured Image" for the post. However, I'm trying now to determine (1) How to assign a hyperlink to the image and (2) How to call the_post_thumbnail() so that it wraps the hyperlink around the image. I can't find where this is supported in the current release of WP, but I'm thinking that I must just be missing something. <div class="entry"> <?php if(has_post_thumbnail() && get_option('theme_show_featured_image')) the_post_thumbnail('large', array( 'class' => 'alignleft', 'style' => 'margin:0 10px 10px 0;')); ?> <?php the_content('<p class="serif">Read the rest of this page &raquo;</p>'); ?>
6818
Change "Enter Title Here" help text on a custom post type
I have a custom post type created for a directory that will end up being sorted alphabetically. I will be sorting the posts in alphabetical order by title, so I want to make sure that the Title is entered as last name/first name. Is there a way to change that default help text -- "Enter Title Here" -- in my custom post to something else?
102364
Underscores in custom fields
I am somewhat new to WordPress. While trying to perform a WP_Query using meta_query(), I had some trouble because the custom fields created by a plugin had `_` in the beginning of its name. Although I noticed it was stored this way in the database, I had no idea why it was there and thought I had to reference it without the underscore (for the record, that is wrong). Why do some custom fields start with underscores and others don't? What are the underscores used for? Are they mandatory in some circumstances?
102362
Multisite for Multisite?
Is there anyway I can allow users to create their own WordPress multisite network on my multisite network? It will be a premium service and will work much like reseller hosting, where the customer will pay the distributor and the remaining goes to the middleman as profit. Thanks!
102363
Add background image/layout for single page?
I'm seeing that a lot of sites (moz.com,hubspot.com) are using a background image as a layout. How do I add a single background image easily onto WordPress? I also want to add the layout here: http://moz.com/blog onto my blog. How do I do this?
6811
Creating a metabox to upload multiple images
Is it possible to make a meta box that attaches multiple images to a post?
15702
Blog statistics
I run small wordpress blog with 3-5 users. People add/edit/remove and read content all the time... What I want is to be able to see some sort of statistics.... which posts/pages are most popular, most updated, commented... which external links are the ones clicked most times... etc.... is there a plugin (not external service) to achieve that?
55831
Conditional arguments for WP_Query and tax_query depending on if $somevar has a value
I've created a new query for a custom post type of 'courses'. Those results are then to be filtered using tax_query, querying 3 custom taxonomies matching 1 or several term ID's. These are passed from a search page. Here's the code working find up to now: // Lets emulate the posted ID's from the course search widget // with some static term ID's for each custom taxonomy. $search_course_area = array(65, 62); $search_course_level = array(117); //52 for further filtering $search_course_mode = array(54, 56); //Begin a new query $query = new WP_Query( array( //Retreive ALL course posts 'post_type' => 'course', 'posts_per_page' => '-1', //Filter taxonomies by id's passed from course finder widget 'tax_query' => array( //Set the relation condition for the filters in //this case we're using AND as it is explicity set //by the user when searching 'relation' => 'AND', //First check retreive course-area's based on ID array( 'taxonomy' => 'course-area', 'field' => 'id', 'terms' => $search_course_area ), //And again for the second taxonomy array( 'taxonomy' => 'study-levels', 'field' => 'id', 'terms' => $search_course_level ), //Finally check retreive course-level's based on ID array( 'taxonomy' => 'course-mode', 'field' => 'id', 'terms' => $search_course_mode ), ) ) ); The thing I'm a little stuck on, is if an array is passed which is empty, this would obviously break the query and return no results. What would be the cleanest way to tackle this? I could do something like: if (isset($search_course_area)) { echo "array( 'taxonomy' => 'course-area', 'field' => 'id', 'terms' => $search_course_area ),"; }; But I have a feeling that wouldn't be the best way to approach it? Thanks a lot for your time and any help you can give I really appreciate it! Craig
6814
How to get a list of child ids for a named category?
I believe I could do this with either get_categories() or wp_list_categories() and passing a 'child_of' parameter, for example, but that would return a much larger dataset than I need. Is there a direct call that returns the child ids for any category as a simple list (1,2,3,5, etc)?
102368
Add role across network in multisite
I have been trying to add new wordpress roles and capabilities, in a multisite installation, using the code below. The issue is, it only applies to the 'main' site of the multisite, and does not propogate to the subsites. I haven't really found anything in the documentation that covers this. function civicrm_wp_set_capabilities() { global $wp_roles; if (!isset($wp_roles)) { $wp_roles = new WP_Roles(); } //Minimum capabilities (Civicrm permissions) arrays $min_capabilities = array( 'access_civimail_subscribe_unsubscribe_pages' => 1, 'access_all_custom_data' => 1, 'access_uploaded_files' => 1, 'make_online_contributions' => 1, 'profile_create' => 1, 'profile_edit' => 1, 'profile_view' => 1, 'register_for_events' => 1, 'view_event_info' => 1, 'sign_civicrm_petition' => 1, 'view_public_civimail_content' => 1, ); // Assign the Minimum capabilities (Civicrm permissions) to all WP roles foreach ( $wp_roles->role_names as $role => $name ) { $roleObj = $wp_roles->get_role($role); foreach ($min_capabilities as $capability_name => $capability_value) { $roleObj->add_cap($capability_name); } } //Add the 'anonymous_user' role with minimum capabilities. if (!in_array('anonymous_user' , $wp_roles->roles)) { add_role( 'anonymous_user', 'Anonymous User', $min_capabilities ); } }
15707
Where do I save widget code for wordpress?
Pretty simple, I've written a widget and I can't find out for the life of me where to save it?! Using the most recent version of wordpress. Thanks, John.
9757
When using Simple Fields plugin, how do I pull the information out of the database to display on a page?
Pretty much what the question says. I used simple fields, but I'm unsure in WP how to get the information back to display on a page?
9756
Widget to display custom taxonomy tag cloud
How to alter the default widget to display a tag cloud of a custom taxonomy?
107701
Development workflow for Wordpress using git - issues with plugins and bloginfo('wpurl')
I'm going with this git workflow for my current wordpress project which I'm running locally using `MAMP`. It allows me to separate the WP core files from the theme and plugin folders using submodules, which is great. My `wp-config` has some extra entries to tell Wordpress where the core files are and where the theme folders are: if ( !defined('ABSPATH') ) define('ABSPATH', dirname(__FILE__) . '/wordpress/'); define('WP_HOME', 'http://' . $_SERVER['HTTP_HOST'] . '/core'); define('WP_SITEURL', 'http://' . $_SERVER['HTTP_HOST'] . '/core/wordpress'); define('WP_CONTENT_DIR', realpath(ABSPATH . '../wp-content/')); define('WP_CONTENT_URL', WP_HOME . '/wp-content'); define('UPLOADS', '../wp-content/uploads'); My structure from the site root looks like: -wordpress (contains core files) -wp-content -themes -plugins -uploads -wp-config.php So my home url is: `http://localhost:8888/core/` The issues I'm running into all over is with the plugins. Some of them are using `get_bloginfo('wpurl')` to load assets. So an example of that would look like this: http://localhost:8888/core/wordpress/wp-content/plugins/{PLUGIN}/images/{PLUGIN_IMAGE}.png where it should actually be: http://localhost:8888/core/wp-content/plugins/{PLUGIN}/images/{PLUGIN_IMAGE}.png Can I override this somehow without modifying the plugins individually?
9752
Function like in_category for custom taxonomies
I'm trying to display different content depending on the taxonomy that was been selected. For example I have a taxonomy named Type. Inside that taxonomy I have several different children, one is "Photography." I'd like the single of a "Photography" to have a full width instead of it having a sidebar. You can do this in regular Posts by using "if in_category('photography')" but I've spent the past couple hours trying to rig the_terms and the like to function as such. Thanks in advance for the help. -Pete
107705
Search / Filter posts on Title/Content OR Tags
I need to make a custom query to look for posts (CPT) which match a certain keyword but it have to search posts in both the title, the content AND a custom taxonomy terms. I’ve tried with to queries but I just can’t get it to work and I’ve of cause made sure that there are content in wordpress which match the criteria. For clarification I’ll just explain the use case. I got a CPT called **products** The CPT has a custom taxonomy called **details** There are approximately 100 details which all has a name and a description. The **products** itself also have a title, a description (the content) and some other fields. At the product page, I want to have a “filter” function (Not the regular Wordpress search function!). So if I filter the products by the keyword **cool** then it should query the CPT **products** and find the products which contains the word **cool** in either its title, its content or if it is marked with a taxonomy term which contains **cool** in it’s title / description. My two queries I’ve tried looks like this: **Query 1:** //the $s variable is for testing only $s = 'cool'; $query = "SELECT $wpdb->posts.* FROM $wpdb->posts INNER JOIN $wpdb->term_relationships ON ($wpdb->posts.ID = $wpdb->term_relationships.object_id) INNER JOIN $wpdb->term_taxonomy ON ($wpdb->term_relationships.term_taxonomy_id = $wpdb->term_taxonomy.term_taxonomy_id) WHERE $wpdb->posts.post_content LIKE '%$s%' OR $wpdb->posts.post_title LIKE '%$s%' OR $wpdb->terms.name LIKE '%$s%') AND $wpdb->term_taxonomy.taxonomy = ‘details’ AND $wpdb->posts.post_type = ‘products’ AND $wpdb->posts.post_status = ‘publish’ GROUP BY $wpdb->posts.ID ORDER BY $wpdb->posts.post_date DESC"; **Query 2:** //the $s variable is for testing only $s = 'cool'; $query=" SELECT $wpdb->posts.* FROM $wpdb->posts, $wpdb->term_relationships, $wpdb->term_taxonomy, $wpdb->terms WHERE ($wpdb->terms.name LIKE '%$s%' OR $wpdb->posts.post_content LIKE '%$s%' OR $wpdb->posts.post_title LIKE '%$s%') AND $wpdb->posts.ID = $wpdb->term_relationships.object_id AND $wpdb->term_relationships.term_taxonomy_id = $wpdb->term_taxonomy.term_taxonomy_id AND $wpdb->term_taxonomy.term_id = $wpdb->terms.term_id AND $wpdb->posts.post_status = 'publish' AND $wpdb->posts.post_type 'products' ORDER BY $wpdb->posts.post_date DESC I’ve also tried to log Wordpress’ own queries to find out how it queries a keyword filtering with a specific taxonomy selected but I haven’t been able to transfer it proper to my own code. I hope someone can help me and any help or advice is very much appreciated. Cheers, - M
9750
How to setup blog page to render blog posts minus afew categories
I have set my home page to use a static template. So I created a Blog page to use a blog template to render my blog posts. The problem is it just renders the page content. I want it to render blog posts. Minus that of category "portfolio" & "WIP". Do I need to create a custom `query_posts`? what might it look like. To simulate what I get by default if my home page is set to latest posts. I will also need pagination to work.
107709
Why won't Wordpress on localhost find updates?
I've got Wordpress running on WAMP. For some reason, when I check for updates to the core and to my plugins, it tells me that everything is up to date, even though I know that I am one version behind on the core and on three plugins. Why am I not picking up these updates? I checked file permissions, and they're all good. Tried disabling all plugins. No difference. Also, I tried to re-install my current version of the Wordpress core, and got the following output; Downloading update from http://wordpress.org/wordpress-3.5.1-no-content.zip… Download failed. Installation Failed I get no other feedback. Any ideas what is going on? An almost identical version on the live server is showing the updates just fine. Update: I haven't gotten any answer that solve this problem. Useful information would be what domains or subdomains Wordpress needs to connect to in order to check for and download updates. That way I could debug the connection to those domains. Update: I still haven't gotten any solutions. I suspect it has something to do with Apache not being able to connect to outside servers, but I have no idea how to solve that.
98759
how to set up wp in folder within static website?
In my server I have the following file structure: www/ index.html js/.. css/.. img/.. index.html ... blog/ .htaccess index.php wordpress/ .htaccess wp-config.php ... Basically, www/ with some static files and the blog/ directory where I keep the wordpress files (so that if I want to login I have to go to www.mysite.com/blog/wordpress/wp-admin.php) I have no problem login in, I have no problem displaying the front page, but when I try to access one of the posts or categories I am redirected to www.mysite.com/index.php and get the following error message: Not Found The requested URL /index.php was not found on this server. Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request. I don't think it's an .htaccess problem, because both .htaccess files are there and I don't have any issues with permalinks while browsing the site locally... Any ideas on what could this be? <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] </IfModule> # BEGIN W3TC Browser Cache <IfModule mod_deflate.c> <IfModule mod_setenvif.c> BrowserMatch ^Mozilla/4 gzip-only-text/html BrowserMatch ^Mozilla/4\.0[678] no-gzip BrowserMatch \bMSIE !no-gzip !gzip-only-text/html BrowserMatch \bMSI[E] !no-gzip !gzip-only-text/html </IfModule> <IfModule mod_headers.c> Header append Vary User-Agent env=!dont-vary </IfModule> AddOutputFilterByType DEFLATE text/css text/x-component application/x-javascript application/javascript text/javascript text/x-js text/html text/richtext image/svg+xml text/plain text/xsd text/xsl text/xml image/x-icon application/json <IfModule mod_mime.c> # DEFLATE by extension AddOutputFilter DEFLATE js css htm html xml </IfModule> </IfModule> <FilesMatch "\.(css|htc|js|js2|js3|js4|CSS|HTC|JS|JS2|JS3|JS4)$"> FileETag None <IfModule mod_headers.c> Header unset ETag </IfModule> </FilesMatch> <FilesMatch "\.(html|htm|rtf|rtx|svg|svgz|txt|xsd|xsl|xml|HTML|HTM|RTF|RTX|SVG|SVGZ|TXT|XSD|XSL|XML)$"> FileETag None <IfModule mod_headers.c> Header unset ETag </IfModule> </FilesMatch> <FilesMatch "\.(asf|asx|wax|wmv|wmx|avi|bmp|class|divx|doc|docx|eot|exe|gif|gz|gzip|ico|jpg|jpeg|jpe|json|mdb|mid|midi|mov|qt|mp3|m4a|mp4|m4v|mpeg|mpg|mpe|mpp|otf|odb|odc|odf|odg|odp|ods|odt|ogg|pdf|png|pot|pps|ppt|pptx|ra|ram|svg|svgz|swf|tar|tif|tiff|ttf|ttc|wav|wma|wri|xla|xls|xlsx|xlt|xlw|zip|ASF|ASX|WAX|WMV|WMX|AVI|BMP|CLASS|DIVX|DOC|DOCX|EOT|EXE|GIF|GZ|GZIP|ICO|JPG|JPEG|JPE|JSON|MDB|MID|MIDI|MOV|QT|MP3|M4A|MP4|M4V|MPEG|MPG|MPE|MPP|OTF|ODB|ODC|ODF|ODG|ODP|ODS|ODT|OGG|PDF|PNG|POT|PPS|PPT|PPTX|RA|RAM|SVG|SVGZ|SWF|TAR|TIF|TIFF|TTF|TTC|WAV|WMA|WRI|XLA|XLS|XLSX|XLT|XLW|ZIP)$"> FileETag None <IfModule mod_headers.c> Header unset ETag </IfModule> </FilesMatch> # END W3TC Browser Cache # BEGIN W3TC Page Cache core <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteCond %{HTTP:Accept-Encoding} gzip RewriteRule .* - [E=W3TC_ENC:_gzip] RewriteCond %{REQUEST_METHOD} !=POST RewriteCond %{QUERY_STRING} ="" RewriteCond %{REQUEST_URI} \/$ RewriteCond %{HTTP_COOKIE} !(comment_author|wp\-postpass|w3tc_logged_out|wordpress_logged_in|wptouch_switch_toggle) [NC] RewriteCond %{HTTP_USER_AGENT} !(W3\ Total\ Cache/0\.9\.2\.9) [NC] RewriteCond "%{DOCUMENT_ROOT}/wordpress/wp-content/cache/page_enhanced/%{HTTP_HOST}/%{REQUEST_URI}/_index.html%{ENV:W3TC_ENC}" -f RewriteRule .* "/wordpress/wp-content/cache/page_enhanced/%{HTTP_HOST}/%{REQUEST_URI}/_index.html%{ENV:W3TC_ENC}" [L] </IfModule> # END W3TC Page Cache core
37304
How do I set a custom page template for a custom post type?
I need to set a custom template for a custom post type with standard wordpress functionality like this: Creating_Your_Own_Page_Templates I found these: 1 - custom post template , 2 - single post template , but its not working for a custom post type and this works only for built-in wordpress posts.
24144
Adding a custom "Add Custom Field" button to Custom Meta boxes
Did I use custom enough in the title? Here is a quick explanation of what I am doing. I am creating a genealogy site and I have a custom post type called "Ancestor" In this post type there is quite a bit of information that is going into custom fields. To make it more user friendly, I've created a few custom meta boxes to organize the data. None of the fields in those meta boxes need to be unique. No one will have more than one birth date, etc. But the next custom meta box I need to tackle is the "Parents / Siblings" box. I don't want to create a meta box with 15 custom fields IDed as sibling1, sibling2... I'd like to make use of the "Add Custom Field" button that lets you dynamically add additional custom fields. So people could add as many or as few sibling fields as they need. I've created the meta boxes using the method at http://www.deluxeblogtips.com/p/meta-box-script-for-wordpress.html Any info or shove in the right direction to adding a "New Sibling Field" button would be greatly appreciated.
37307
WordPress Phone Verification
Is there a way to check verified members phone numbers by sending code to their mobile phones just like Facebook does? This would be very handy to stop spammers and allows only one user per phone number.
24143
TinyMCE invalid nested list markup
Today I upgraded Wordpress to 3.2.1 and noticed that the nested list markup seems to be invalid. This is the code it's producing: <ul> <li>parent list item 1</li> <ul> <li>child list item 1</li> </ul> <li>parent list item 2</li> </ul> Instead it should look like this: <ul> <li>parent list item 1 <ul> <li>child list item 1</li> </ul> </li> <li>parent list item 2</li> </ul> Anybody else having this problem or have any idea what might be causing this?
24140
I cannot include a file in my plugin settings page
I'm trying to create a settings page. If I print things within index, I can see it. If I try to include it, I can't see anything, neither errors. add_options_page('My Plugin', 'My Plugin', 'manage_options', 'my-plugin', array('MyPluginSettings', 'index')); my settings: class MyPluginSettings { public function index() { /* I can echo or print here and it works fine ... * But i can't require a file here ... nothing happens */ require('existing/path/to/a/file.php'); } } ?> What's wrong? Thanks.
24148
Alternate stylesheet only works with absolute address for link?
I am trying to add a stylesheet when users are accessing the blog section of my site from and iPad. The first snippet of code works, however, I don't want to use the absolute path. I want to use wordpress's function. function ipad_css() { if( preg_match('/ipad/i',$_SERVER['HTTP_USER_AGENT'])) {?> <link rel="stylesheet" type="text/css" href="http://website/wp-content/themes/my_theme/ipad.css" media="screen" /> <?php } } add_action('init','ipad_css'); This doesn't seem to work: function ipad_css() { if( preg_match('/ipad/i',$_SERVER['HTTP_USER_AGENT'])) {?> <link rel="stylesheet" type="text/css" href="<?php bloginfo('template_directory'); ?>/ipad.css" media="screen" /> <?php } } add_action('init','ipad_css'); I'm confused as to why it won't work. I have trying `stylesheet_url` as well with no luck.
24149
Custom query looking at multiple custom fields and properly sorting
For the past two weeks I've been looking for a way to create a query in wordpress that returns all custom post types where a meta_key "mytype-expired" is NOT set to "yes" and then order the results by a second meta_key called "mytype-sort-order" with the highest number value coming first. If no value exists in the "mytype-sort-order" meta_key field, I want these posts to be displayed order by date (most recently added first), and all of these should be below posts that do have a value. **For example, these set of test posts** : **Post 1** (from July 1st, mytype-sort-order value not set), **Post 2** (from July 2nd, mytype-sort-order value not set), **Post 3** (from July 3rd, mytype- sort-order value not set), **Post 4** (from July 4th, mytype-sort-order value = 95), **Post 5** (from July 5th, mytype-sort-order value = 90), **Post 6** (from July 6th, mytype-sort-order value not set), **Post 7** (from July 7th, expired="yes"). **should be returned as follows** : 1. **Post 4** (from July 4th, mytype-sort-order value = 95) 2. **Post 5** (from July 5th, mytype-sort-order value = 90) 3. **Post 6** (from July 6th, mytype-sort-order value not set) 4. **Post 3** (from July 3rd, mytype-sort-order value not set) 5. **Post 2** (from July 2nd, mytype-sort-order value not set) 6. **Post 1** (from July 1st, mytype-sort-order value not set) ( **Post 7** not displayed because it's expired) I explained my current approach of trying to use meta-query here here, but I found anything new or made any progress myself, and with no responses to my first question I'm wondering if there's another way I could accomplish this. I've been able to not return expired posts, and order by "mytype-sort-order" meta_value_num OR order by date. The problem I keep running into is I **can't order by BOTH "mytype-sort-order" meta_value_num AND date** Even though I've done a lot with wordpress, my experience with creating custom queries is limited. I'm totally stuck and would REALLY appreciate some ideas. Thanks!
137580
WordPress loop to pull 4 pages/posts by ID
Im trying to create a wordpress loop which pulls out 4 specific pages/posts by ID (excepts to display a teaser). The main issue is they are located in 3 different post types: 'post', 'training', 'page'. So far I have rewrote this code 3 times, its nearly there but not quite right. <?php $ids = array(2101,3754,4760,2572); query_posts(array( 'post_type' => array( 'post', 'training', 'page' ), 'post__in' => $ids, 'posts_per_page' => 1) ); if (have_posts()) : ?> Can anyone give me a pointer into what is going wrong?
116225
modify facebook like button to also write to database
I've tried out some solutions to store the facebook like counts of my wordpress posts inside my database. I've been doing that by making a HTTP Get request at http://graph.facebook.com/ at pulling in the likes from there. I can't work with that anymore though. Now my question: Is it possible, to modify the facebook like button, so that by clicking it, it does **1.** Doing what every fb-like-button does (+1) **2.** Write the value 1 (or how often it was clicked alltogether) to a custom field into the wp_postmeta for the post (in my own database).? This way I wouldn't be dependent on pulling in the like count from facebook graph anymore. Is that even possible and how would I be doing that?
112231
Featured Image If Else Condition
I have my banner background set to the URL of the featured image. <div id='xpro_shell_text' > <?php if (has_post_thumbnail( $post->ID ) ): ?> <?php $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'single-post-thumbnail' ); ?> <div id="xpro_shell_content_header" class='content_about_us_header white' style="background:url('<?php echo $image[0]; ?>') no-repeat;"> <div id='xpro_shell_content_header_blurb'> <h1 class='greenHeader cufon_reg'> <?php the_title(); ?> </h1> <p> <?php $message=get_post_meta($post->ID, "myBlurb", true); if (get_post_meta($post->ID, "myBlurb", true)) { echo ($message); } ?> </p> </div> </div> <?php endif; ?> <!--end xpro_shell_content_wrapper_top --> </div> I want a default banner background set if i didn't put a Featured image. How can do that?
142961
Injecting a javascript banner code right before & after wordpress navigation menu
I am trying to develop a plugin to inject a javascript banner code right before and after the wordpress navigation menu but I am unable to find any solution to this problem. Does anyone have any idea? I cannot append to a Div ID either since every wordpress theme uses different div id and class for navigation menu. Thanks Edit: Banner code is adsense javascript code. Wordpress does have wp_nav_menu functionality and i want to inject javascript before and after wp_nav_menu.
59951
How can I add/update post meta in a admin menu page?
I wanted to create a plugin to batch manage posts' custom field data. I know I can add post meta by add a meta box in post edit screen and use **add_action('save_post','function_to_update_meta')** to trigger add meta functions. But I don't know how to trigger the **add_post_meta** function in a admin menu page (such as a custom admin menu). How to do that? Thank you in advance!
59950
Generating dynamic Tabs with multiple query post loop
I am trying to generate a dynamic tab based navigating with query post my code is like this <div class="tabbable"> <ul class="nav nav-tabs"> <?php $my_query = new WP_Query(array( 'showposts' => 5, 'orderby' => 'rand', 'category_name' => 'Recipes' )); $x = 0; while ($my_query->have_posts()) : $my_query->the_post(); $x++; $category = get_the_category(); ?> <?php if ($x == 1) { echo '<li class="active">'; } else {echo '<li>';} ?> <a href="#tab<?php echo $x; ?>" data-toggle="tab"><?php echo $category[0]->cat_name; ?></a></li> <?php endwhile;?> </ul> <div class="tab-content"> <div class="tab-pane active" id="tab1"> <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. .</p> </div> <div class="tab-pane" id="tab2"> <p>Ut consectetur libero nec nulla ullamcorper lobortis pulvinar libero viverra.</p> </div> <div class="tab-pane" id="tab3"> <p>Vivamus eget velit at mauris blandit consequat vel sed ipsum.</p> </div> </div> </div> this is all ok and working fine, the problem is that above code can repeat any specific category. for example it can show cat1 cat2 cat3 cat1 cat2 this is what I dont want, I need any category not duplicating again. how to over come this problem? just to keep in mind that in second stage I will be using rewind_post() to get the data from above categories so I want to keep the loop inline Thank you ok I have update my code as following <div class="tabbable"> <ul class="nav nav-tabs"> <?php $my_query = new WP_Query(array( 'showposts' => 3, 'orderby' => 'rand', 'category_name' => 'Recipes' )); while ($my_query->have_posts()) : $my_query->the_post(); $x = $my_query->current_post + 1; //use this to count instead $categories = get_the_category(); foreach($categories as $category) { if ($x == 1) { echo '<li class="active">'; } else {echo '<li>';} ?> <a href="#tab<?php echo $x; ?>" data-toggle="tab"><?php echo $category->cat_name; ?></a></li> <?php } endwhile; ?> </ul> now, how do I show 4 recipes from each categories in the tab contents section
59953
Build index page from custom fields
Im starting to delve deeper into Wordpress custom fields and wanting to replicate this page in Wordpress: http://www.clubsact.com.au/corporate/index.php So my site is not tightly structured to a parent/child relationship, I have created a custom field 'Partner_Level' and based on the partner level entered by the author the function will write out the Feature Image associated with the post and create my index page. Though I cant even seem to get my query working within a function. If I follow the instructions on this page: http://css- tricks.com/snippets/wordpress/custom-loop-based-on-custom-fields/ writing straight to my template, all is good. So Im assuming I don't have something configured correctly, but at a lose as to what. Functions.php function the_partners($cpLevel) { // This query grabs all fields with Metadata, matches $querydetails = " SELECT wposts.* FROM $wpdb->posts wposts, $wpdb->postmeta wpostmeta WHERE wposts.ID = wpostmeta.post_id AND wpostmeta.meta_key = 'Partner_Level' AND wpostmeta.meta_value = '$cpLevel' AND wposts.post_status = 'publish' AND wposts.post_type = 'page' ORDER BY wposts.post_date DESC "; $pageposts = $wpdb->get_results($querydetails, OBJECT); if ($pageposts) { echo "Got em"; } } page_corp.php if (have_posts()) : while (have_posts()) : the_post(); <h1><?php the_title(); ?></h1> the_partners('Gold'); endwhile; endif; In the page, Im simply expecting "Got em" to be printed to the screen, though Im getting a blank. Cheers, Phil
18530
Plugin Hook When New Author Added
Is there a way to add a hook for a plugin when a new author is added by the administrator? I would like to be able to add that user to my plugin database table. Thank you.
18531
Is there a Wordpress Plugin that allows voting "does this coupon work" on specific links like Retailmenot
I am looking for a way/plugin to allow visitors to vote on specific links (does this coupon work/does this coupon not work) like Retailmenot. I can only think of the Wordpress Plugin: Wordpress Pods. I was hoping to find an easier implementation.
137182
meta_query compare='!=' with multiple custom fields
a post has the following custom fields: 'my_custom_field' => 1 'my_custom_field' => 2 'my_custom_field' => 3 I now want to query all posts that do NOT contain the value 2 for 'my_custom_field'. I'm trying this: $args = Array('posts_per_page' => -1, 'post_type' => 'page', 'meta_query' => array( array( 'key' => 'my_custom_field', 'value' => 2, 'compare' => '!=' ) ) ); However, this is still returning my sample post, as my sample post has a field of 'my_custom_field' with a value other than 2 (1 and 3). I somehow need to change my query to say "Exclude posts that have at least one field of 'my_custom_field' with the value of 2". Can anyone help me? Thanks!
137180
Storing FTP details in wp-config.php
I'd like to hear about the security concerns for storing FTP details in wp- config.php on a shared server. It doesn't 'feel' safe to me. I'm using ManageWP to control sites on a shared server and have to input the FTP details manually for each update.
96331
How can i hide content if not friend in Buddypress?
How can I hide some specific contents or div or other stuff depending on being friend or not in buddypress ?? I tried to use the `bp_is_user_friends()` function but it did not work !
33755
How to prevent custom fields from being cleared during a bulk edit?
In my function for saving custom field values I add a few checks to prevent the values from being cleared during an autosave or a quick edit. add_action('save_post', 'save_my_post'); function save_my_post($post_id) { // Stop WP from clearing custom fields on autosave, // and also during ajax requests (e.g. quick edit). if ((defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) || (defined('DOING_AJAX') && DOING_AJAX)) return; // Clean, validate and save custom fields $myfield = ( ! isset($_POST['myfield'])) ? '' : strval($_POST['myfield']); update_post_meta($post_id, 'myfield', $myfield); } It appears, though, that the custom fields are still cleared in the case of a bulk edit. The `DOING_AUTOSAVE` and `DOING_AJAX` checks don't apply to bulk edits. I realize that you could simply not call `update_post_meta` if the applicable `$_POST` variables are not set. That wouldn't work in the case of checkboxes, though. Ideally, a simple check to determine whether we're in a bulk edit or not would do the job. Ideas?
137184
Most efficient way to insert a post outside WordPress?
I need to insert a post via `PHP` outside the Wordpress environment (but on the same server) and I'm looking for the most efficient way to do this. I was thinking about 2 solutions: 1) Using XML-RPC, as explained here 2) Load the WordPress core requiring `wp-load.php` and then using `wp_insert_post()` Wich one uses less resources? I just need to insert a new post into the database and I don't need any support for plugins, theming, etc. There is a more _hackish_ way to do this? Thank you!
137185
Tab order of post admin page
When I edit my post and update, I edit a textarea and hit a `Tab` key, then `Update` button will be activated and press `Enter` to admit the change. But in another environment if I press `tab`, then `preview` button is activated. Why is this difference of tab order happens? And which tab order is right?
136857
What kind of security does wp_handle_upload() provide?
According to the docs, `wp_handle_upload()`, will: > Handle PHP uploads in WordPress, sanitizing file names, checking extensions > for mime type, and moving the file to the appropriate directory within the > uploads directory. I'm working on a site with image uploads and `wp_handle_upload()` works splendidly, but I want to know what kind of security it provides. I am checking for file extentions and MIME types before passing along images to `wp_handle_upload()`, but I know that file extentions and MIME types are easy to fake. If someone were to rename file.exe to file.jpg, will `wp_handle_upload()` detect that? What other kinds of security can I expect built into WP in regards to file uploading?
136856
Where can I find linked fonts in my theme?
I get 404 error because of absent of fonts in my theme ( .ttf , .wof). In my opinion the only solution for this is to delete the request from my them, but I cant find the request string. I've looked through all .php files from my editor but I couldn't find any `.ttf` or file even.
147191
I have this error when i update plugin
> **Warning:** `call_user_func_array()` expects parameter 1 to be a valid > callback, function 'register_style' not found or invalid function name in > /home/kreditt3/public_html/wp-includes/plugin.php on line 470 > > **Warning:** `call_user_func_array()` expects parameter 1 to be a valid > callback, function 'enqueue_style' not found or invalid function name in > /home/kreditt3/public_html/wp-includes/plugin.php on line 470 In my Website www.kredit-toyota.com I've tried to delete plugin that I already update but that doesn't help. Can anybody assist me to sort this out?
142341
comment files and s
I am building a custom template and would like to incorporate comments and replies using the standard WordPress core. What files and scripts do I need? I copied a comments.php file but the replies aren't working. Thanks for your help.
142342
Logout hyperlink within a sub-menu
I have the following secondary navigation menu on my website which has been built using the native _WordPress Appearance > Menus_ feature: ![secondary navigation menu](http://i.stack.imgur.com/uVVl4.png) * * * I am also using the following lines of code in my **functions.php** file to remove and add the ' _Login / Register_ ' and ' _Logout_ ' hyperlinks depending on the access privileges of the user: // Add a Login hyperlink to the secondary navigation menu if the user is logged-out function wpa_remove_menu_item( $items, $menu, $args ) { if( is_admin() || ! is_user_logged_in() ) return $items; foreach ( $items as $key => $item ) { if ( 'Login / Register' == $item->title ) unset( $items[$key] ); } return $items; } add_filter( 'wp_get_nav_menu_items', 'wpa_remove_menu_item', 10, 3 ); // Remove the Logout hyperlink from the secondary navigation menu when the user is logged-in function wpa_add_menu_item( $items, $menu, $args ) { if( is_user_logged_in() ) return $items; foreach ( $items as $key => $item ) { if ( 'Logout' == $item->title ) unset( $items[$key] ); } return $items; } add_filter( 'wp_get_nav_menu_items', 'wpa_add_menu_item', 10, 3 ); Which is output like so: ![enter image description here](http://i.stack.imgur.com/kfgYU.png) ![enter image description here](http://i.stack.imgur.com/NCfxI.png) * * * The _Logout_ menu item is using the following hyperlink: ![enter image description here](http://i.stack.imgur.com/iYKg4.png) How can I replace this URL so that when the user selects the _Logout_ item in the secondary navigation menu, it does not redirect them to a confirmation screen... ![enter image description here](http://i.stack.imgur.com/HrGhb.png) and is still positioned within the same hierarchy (within the ' _My Account_ ' parent menu of the ' _Secondary Header_ ', not at the start or end of the entire menu)? ![enter image description here](http://i.stack.imgur.com/jOs2p.png) Thank you.
136850
Display posts from category in page
I am trying to use a shortcode to display a loop of posts from a category. I have the shortcode working but it is only displaying the actually category names within the custom post type and not the actual posts. Below are the basics: Custom Post type is "business" Taxonomy is "business_taxonomy" Category made within the CMS is "dfa" The shortcode code is add_shortcode( 'list-posts', 'rmcc_post_listing_parameters_shortcode' ); function rmcc_post_listing_parameters_shortcode( $atts ) { ob_start(); // define attributes and their defaults extract( shortcode_atts( array ( 'type' => '', 'order' => 'date', 'orderby' => 'title', 'posts' => -1, 'category' => '', ), $atts ) ); // define query parameters based on attributes $options = array( 'post_type' => $type, 'order' => $order, 'orderby' => $orderby, 'posts_per_page' => $posts, 'category_name' => $category, ); $query = new WP_Query( $options ); // run the loop based on the query if ( $query->have_posts() ) { ?> <h5><?php the_title() ?></h5> <?php $myvariable = ob_get_clean(); return $myvariable; } } so in the page I should put `[list-posts type="business" category="dfa"]` but nothing shows. If I use just `[list-posts type="business"]` it just lists the category names in the custom post type not the actual posts titles.
142967
How can I pass value to function in add_menu_page?
I was use to pass value to function for the below menu. add_menu_page('Competition Manager 2013-2014', '2013-2014', 'manage_options', 'manager_2013_2014', 'manager_2013_2014', plugins_url( 'competition-manager/images/cup.png' ), 81 );
136859
WordPress URL Rewrite for dynamic and customized URL
I'm working on a website in WordPress where I have to show AP News from external Database and not from the WordPress DB. I have created few shortcodes for this, which are working absolutely fine. I have created a separate page to show news details called "details". Here is my URL. > > http://www.example.com/news/details?ID=f50ccf32a5cd4169af6522e8903d0207&type=world&subtype=africa Where, News = Category, Details = WP Page and ID = id of the News In specific requirement I need to have a URL like shown Below. > > http://www.example.com/news/world/f50ccf32a5cd4169af6522e8903d0207/Pistorius- > investigators-meet-Apple-over-iPhone.html If we go for above mentioned URL, WordPress will try to find post with name "pistorius-investigators-meet-apple-over-iphone" in our WordPress site, which really does not exist. We fetch it from an external database. Is there any way I can manipulate my URL to SEO friendly URL ?
138987
Taxonomy rewrite pagination 404
I have rewritten my taxonomy url to the name of my posts type 'filter'. Because I have done this, my pagination does not work anymore on the url: http://www.website.com/filter/term-name/ So if I visit http://www.website.com/filter/term-name/page/2 I get a 404 I think this is because Wordpress sees filter now as the post type and the taxonomy. If I change `'slug' => 'filter'`, to for example `'slug' => 'test'` it works fine. Does anyone know how I can say to Wordpress that 'filter' is in this case the taxonomy. $args = array( 'labels' => $labels, 'hierarchical' => true, 'public' => true, 'show_ui' => true, 'show_admin_column' => true, 'show_in_nav_menus' => true, 'show_tagcloud' => true, 'rewrite' => array( 'slug' => 'filter', 'with_front' => false ), ); register_taxonomy( 'service', 'filter', $args ); Any suggestion to why this is not working?
138986
WP_Customize_Image_Control is not doing very much
I am trying to add a logo option. The section and the option shows up under Appearance - Customize as expected. It offers me to upload an image. I do that. The image gets uploaded, but the option "Header logo image" below is not affected. It just offers me to upload an image again. I would expect it to offer me to choose from the Media library. And I also expect it to save the value, i.e. the image I uploaded. Can anyone see if there is something wrong in the code here? (Other options I have added works fine.) $wp_customize->add_section('logo_section', array( 'title' => __( 'Logo', 'ourcomments_s1'), 'description' => __( 'Display a custom logo?', 'ourcomments_s1'), 'priority' => 25, )); $wp_customize->add_setting( 'extra_logo', array( 'default' => '', // 'transport' => 'postMessage', )); $wp_customize->add_control( new WP_Customize_Image_Control( $wp_customize, 'extra_logo', array( 'label' => __( 'Header logo image', 'ourcomments_s1'), 'section' => 'logo_section', 'settings' => 'extra_logo', // 'context' => 'what is it?', )));
138983
how to use get_field_name in external ajax handler
I am loading new form fields from Ajax when I click on radio button in my custom widget. In Ajax callback handler, I need to use get_field_name and get_field_id widget class methods. get_field_name method is return in WP_Widget class. So I try to get the instant of that class. But I unable to do that. So please someone help me how to use it in external class. function wp_ajax_suport(){ add_action('wp_ajax_my_func', 'my_func'); add_action('wp_ajax_nopriv_my_func', 'my_func'); } add_action( 'init', 'wp_ajax_suport' ); function my_func(){ <input type="text" name="<?php $this->get_field_name('name'); ?>"> }
138982
How to create custom tables in WordPress using my own plugin?
I am new in WordPress plugin development. This is my core PHP and HTML code **create-table.html** <form method="post" action="function.php"> <input type="text" name="table_name"> <input type="submit" name="create"> </form> **function.php** if(isset($_POST['create']) { $table-name=$_POST['table_name']; //create table query header("location: add_table_attribute.php"); } I want to use this same process in my WordPress plugin development. Please any one help me. Thanks in advance.
94337
Inserting large amounts of data into a custom table during plugin install
I am working on a WordPress plugin that creates several new tables into the database. It also loads some default data into the tables from CSV files. Most of these are small and loading the data works fine. One, however, is a zip code database meant to be loaded with just over 43,000 rows of data. The first time I tried to do exactly what I did for the tables with significantly smaller amounts of data to be inserted. WordPress responded with, "Plugin could not be activated because it triggered a fatal error." After checking the database I saw that it got through just over 1,000 zip codes before it stopped. So I took the first 1,500 lines from that CSV and broke it into 2 CSV files (750 lines each). I used the code below to loop through loading the two CSV files to test if I could just do this in what would be an incredibly slow solution, but at least something that worked. It turned out that it was still only able to get through 1099 zip codes before stopping. Does anyone have a solution for inserting very large amounts of data into a table from a WordPress plugin? Thanks in advance to anyone who tries to help me here. Here is an example line from the zips CSV: %1%;%00544%;%NY%;%HOLTSVILLE%;%-73.047623%;%40.813296%;%0% Here is the create table function: function zip_table_create() { global $wpdb; $table_name = $wpdb->prefix . "zip"; $sql = "CREATE TABLE $table_name ( `zip_id` bigint(20) NOT NULL AUTO_INCREMENT, `zip` char(5) DEFAULT NULL, `state` char(2) NOT NULL DEFAULT '', `name` char(40) DEFAULT NULL, `lng` double NOT NULL DEFAULT '0', `lat` double NOT NULL DEFAULT '0', `population` int(10) unsigned NOT NULL DEFAULT '0', PRIMARY KEY (`zip_id`) );"; dbDelta($sql); // Check to see if any records are stored in table // If not, load default data from CSV $zip = $wpdb->get_row("SELECT * FROM $table_name WHERE zip_id = 1"); if ($zip == null) { for ($z=1; $z<3; $z++) { $csvpath = plugin_dir_path(__FILE__); $csvpath = $csvpath."csv/zips".$z.".csv"; $csv_array = csv2array($csvpath, ";", "%"); for ($x=0; $x < count($csv_array); $x++) { $wpdb->insert( $table_name, array( 'zip_id' => $csv_array[$x][0], 'zip' => $csv_array[$x][1], 'state' => $csv_array[$x][2], 'name' => $csv_array[$x][3], 'lng' => $csv_array[$x][4], 'lat' => $csv_array[$x][5], 'population' => $csv_array[$x][6] ) ); } } } } Here is the csv2array function called in the create function: function csv2array($file, $delimiter, $enclosure) { if (($handle = fopen($file, "r")) !== FALSE) { $i = 0; while (($lineArray = fgetcsv($handle, 4000, $delimiter, $enclosure)) !== FALSE) { for ($j=0; $j<count($lineArray); $j++) { $data2DArray[$i][$j] = $lineArray[$j]; } $i++; } fclose($handle); } return $data2DArray; }
144144
wp-login returns blocked
I'm working on a site where i let users sign-up and login from the front-end. But a random problem is making my head spin. On some occasions the users can't log in. After typing username and password the page just returns "Blocked" in the upper left corner. The url to mu site: http://www.karsten-tietje.dk/bolig The site is still in test phase, so I have created several users from my computer (ip) and I don't know if thats coursing the problem. But it has also happened on other computers. This is a huge problem for me as i can't locate the problem. And to make things more complicated it doesn't happen all the time. it seems rather random. I'm using s2members plugin and turned off the bruteforce option. Any suggestions on how to fix this problem?
157245
Installing plugins and using complex folder structure with child theme in WordPress
I'm creating a new WP website based on a template, and I've created the child theme for this template. It is working without any problem. I understand the basics for a child theme as adding my `style.css`, `function.php`, etc. I need to get a better understanding on the following points: * For plugins installation, will I install it using the child theme, or install in the parent theme? And will it be in `/wp-content/plugins` or do I need to create another folder and add some function to it to make it work. * If I have a file inside more than one folder in the parent theme (example `/parenttheme/includes/php/anotherfolder/example.php`) and I want to modify the `example.php` file, do I need to create and match all this structure in the child theme only?, or do I need to add more function to make it work.
138989
App Development for facebook
I would like to know how to connect between wp and Facebook. Is there any way to connect both of them and I can easily use Fb Api in WordPress?
137457
Get published posts and pages?
I'm working on a plugin to use gettext in posts and pages content. I'm trying to get all published posts and pages in order scan them for translatable strings, but I cannot figure out how to do it. This is what I'm trying: $pages = $wpdb->query('SELECT * FROM wp_posts WHERE post_status = "publish"'); foreach ( $pages as $post ) { print_r($post); }
67378
Categories from front-end, checkbox selection doesn't work
I'm using the plugin Post from site, which sets up a WP front end writer. I changed some line of code because I need to select categories with checkboxes and not with a multiple select (as it was originally in the plugin). Unfortunately it doesn't work: there is a checkbox in the front end writer, now, but checking boxes just does nothing: the post is saved without categories. Here's the code which handles the taxonomy selection: public function get_taxonomy_list( $taxonomy ){ $terms = get_terms($taxonomy, array( 'hide_empty' => 0 )); if (!$terms || empty($terms)) return ''; //preg_match_all('/\s*<input class="(\S*)" value="(\S*)" type="checkbox">(.*)<\/input>\s*/', $terms, $matches, PREG_SET_ORDER); $out = apply_filters( 'pfs_taxonomy_label', "<label for='terms_$taxonomy'>Seleziona i corsi</label>", $taxonomy ); foreach ($terms as $term){ if (is_taxonomy_hierarchical($taxonomy)) $out .= "<input class='{$term->term_taxonomy_id}' type='checkbox' value='{$term->term_taxonomy_id}' name='{$term->term_taxonomy_id}' /> {$term->name}<br />"; else $out .= "<input class='{$term->term_taxonomy_id}' type='checkbox' value='{$term->name}' name='{$term->name}' /> {$term->name}"; } $out .= "<br />\n"; return apply_filters("pfs_{$taxonomy}_list",$out); } and here's the code which saves the post and the taxonomy (which I didn't change): $postarr['tax_input'] = (array_key_exists('terms',$pfs_data)) ? $pfs_data['terms'] : array(); $post_id = wp_insert_post($postarr);