question
stringlengths
0
34.8k
answer
stringlengths
0
28.3k
title
stringlengths
7
150
forum_tag
stringclasses
12 values
I have this snippet built from a couple of sources, it works great and if the user is not an admin it hides the page with an id of 243 from being seen in the edit pages section.... <code> add_action( 'pre_get_posts' ,'exclude_pages' ); function exclude_pages( $query ) { if( !is_admin() ) return $query; global $pagenow;...
Get the page by its title, then use its ID: <code> add_action('pre_get_posts', 'exclude_pages'); function exclude_pages($query) { if(! is_admin()) return $query; global $pagenow; if ('edit.php' === $pagenow &amp;&amp; (get_query_var('post_type') &amp;&amp; 'page' === get_query_var('post_type'))) { // Get the page by it...
Exclude page by title for non admins
wordpress
I have created the custom post type with the taxonomy product-categories. I have installed wpml and added the menu with the custom category. When the menu created using the custom post type category with taxonomy is clicked . Then the WPML language selector in the header is not displaying the language list. Please guid...
The default language selector is pretty crap TBH. I created this function using jQuery, you will have to amend to fit your template. <code> function language_selector(){ $languages = icl_get_languages('skip_missing=0&amp;orderby=code'); $current_lang = ICL_LANGUAGE_CODE; if(!empty($languages)) { ?&gt; &lt;div id="langu...
Taxonomy page wpml dropdown not working
wordpress
I modified the default Wordpress registration page to include a role and also payment fields. I am adding a Gold Member feature the my website, which requires payment. I'd like it that after this user makes a payment and it is approved, he gets redirected back to the home page. I'm using the registration_errors filter ...
You can use <code> wp_redirect </code> function ( Codex ) at any point where you want to redirect the user: <code> wp_redirect( home_url() ); exit; </code>
Redirect User to custom URL after registering
wordpress
I have profiled my blog with the P3 Plugin and it pointed out that Yoast SEO slows down the site a bit. I then found out that the biggest performance penalty is paid when you "force rewrite" the titles[1], which I am doing. Now I do have quite an aggressive caching turned on with WP Super Cache. Does it still matter if...
Now I do have quite an aggressive caching turned on with WP Super Cache. Does it still matter if I force-rewrite the titles then? Or in my case it doesn't change a thing since pages are pre-generated and served as static content? Yes it does matter because you are not serving cached content 100% of the time and you als...
P3 Profiler and Yoast SEO plugin
wordpress
I'm fairly new to Wordpress. I have users that create profiles on my site and one of the sections is their bio. How can I take this information and display it on lets say a "users profile page". Thanks
WordPress already comes with the <code> author </code> page/functionality. Let's say you have the author <code> john </code> on your site <code> www.example.com </code> , then you'd see his author page at <code> www.example.com/author/john </code> . If you want to customize this, you have to tweak (or maybe even create...
How to show a users bio on a page
wordpress
I've got always the same problem. If I program a multisite for multilanguage purposes, I cannot find a way to not change the page links in every language. I mean, suppose I've got a page named 'Activity' in the english version. Then got the Italian version, and the same page is called 'Attività'. If I've got a manually...
I've found out that another answer could be to just use the is_page_template tag. Since I'm preatty sure that the NAME of the php template file that needs custom css and/or js will be the same through all the languages (both using the multisite way or things like WPML), I can say <code> if(is_page_template('that-page.p...
unique identifier for the same pages in a multilanguage/site context
wordpress
I have a code in my functions.php that gives me a count of how many favorites a post has got. <code> function wpfp_get_current_count() { global $wpdb; $current_post = get_the_ID(); $query = "SELECT post_id, meta_value, post_status FROM $wpdb-&gt;postmeta"; $query .= " LEFT JOIN $wpdb-&gt;posts ON post_id=$wpdb-&gt;post...
You can simply do it by adding 300 when displaying count as shown in following code: <code> &lt;?php echo 'TOTAL POST VIEWS: ' .(intval(wpfp_get_current_count()) + 300); ?&gt; </code> and instead of echoing that values in function return it as shown in following code: <code> function wpfp_get_current_count() { global $...
How to do simple addition to increase favorites count of my wordpress posts
wordpress
I read the Codex and some other tutorials describing the process of creating a new table for WordPress. I thing that the steps are pretty straightforward; however, I'm encountering a small problem. I am developing a theme (not a plugin) and I am creating some features which require a new WordPress table. All the tutori...
As mentioned, <code> after_switch_theme </code> should be a pretty good choice. Your table create/update function will only run when you switch themes, which should be roughly like activating a plugin. If you use <code> dbDelta </code> to create and/or update the table there should be no issue with table creation. From...
Hook to be used when creating a database table
wordpress
I want to change default image sizes when user activates my theme so that the default medium image width is exactly the width of page content (for pages with sidebar) and the large image size fits nicely on full-width templates. Is it considered a bad practice?
Best practice would be to implement your own post_thumbnails. Then, add those sizes as options in the Add Media dialog. Here is a nice write up on that.
Is it a good practice to change media settings on theme activation?
wordpress
I wanted to know if this is possible. I have gone through a lot of threads on the internet for this one and there does not seem to be one good solution. I run a business website based on wordpress and now there is this peculiar requirement wherein I need a hack/code to pull and display one single image ( from among the...
Function to retrieve "landscape" oriented image <code> function wpse_96012_landscape_image() { /* global post object holding info about the current post */ global $post; /* grab all images attached to the current post */ $attached_images = get_children( array( 'post_parent' =&gt; $post-&gt;ID, 'post_type' =&gt; 'attach...
Is it possible to pull and display a single landscape oriented image
wordpress
After I upgraded multisite system from 3.5 to 3.5.1, I started having a weird encoding problem - all <code> &amp;nbsp </code> are rendered as <code> Â&amp;nbsp </code> . All of my pages (as well as the DB entries) are UTF-8 encoded. All the meta tags on the pages are (automatically) set to <code> &lt;meta http-equiv="C...
I pinpointed the bug to the User Access Manager 1.2.2 (network-wide) - once disabled, everything went back to normal. I'm still not sure what exactly was causing the problem.
Multisite Â&nbsp wrong encoding problem
wordpress
I am trying to retrieve the category name of a WooCommerce product displayed in a WordPress loop and use it as the class for an <code> li </code> (also inside the loop). I've tried this: <code> &lt;div id="isocontent" class="products"&gt; &lt;ul&gt; &lt;?php while (have_posts()) : the_post(); ?&gt; &lt;li class="&lt;?p...
I'm guessing you haven't set or called the $product object, so it can't access any information in it. Try inserting <code> global $product </code> just before your while loop. If that doesn't work, try doing a <code> print_r($product-&gt;get_categories() </code> outside of your html for debugging. Without the rest of y...
woocommerce retriving category name as div class?
wordpress
I am trying to set up code to submit a post to StumbleUpon, from my Rothmania site. The code reads <code> href="http://www.stumbleupon.com/submit?url=&lt;?php the_permalink(); ?&gt;&amp;title=&lt;?php the_title(); ?&gt;" alt="" title=""&gt; </code> and when on a single post view, it pulls the info just fine, offering t...
The problem is that the functions <code> the_title() </code> , <code> the_ID() </code> etc. access the current post, which is the last post after the query has been handled completely. Put the following either in a text widget, wrapped in <code> &lt;?php </code> and <code> ?&gt; </code> , while having PHP execution ena...
Permalink target for recent post
wordpress
I'm trying to loop a function that will let users create a few custom posts, but I have a problem with the function name. Here is an example: How can I write this: <code> function register_cpt_1_mdframework_price(){ </code> … like this: <code> function $myvar(){ </code> This is how I solved it, but it's neither nice no...
<code> &lt;?php $numcpost = of_get_option('how_many_custom_posts'); do { add_action( 'init', 'register_cpt_mdframework_price', $numcpost ); --$numcpost; } while ( $numcpost &gt; 0 ); function register_cpt_mdframework_price( $numcpost ) { $singcpost = of_get_option('custom_posts_name_s_n'.$numcpost.''); $plurcpost = of_...
How to use a variable as a function name?
wordpress
I have this php code I am using to list all post (titles) with the taxonomy categories names, and its working fine however I will like to break it up and avoid using echo within the php code so that I can insert some more code. Here's the code I have that works -- <code> &lt;?php $custom_terms = get_terms('videoscatego...
You have an extra "}", there must be two such braces for two for each loops. Also you need to have endif; statement at end after endwhile. Parsing error may be due to extra "}". Please try below code and let us know if it works. <code> &lt;?php $custom_terms = get_terms('videoscategory'); $other_custom_terms = get_term...
How to break up php code to avoid echo
wordpress
I have a custom metabox that have 2 options: URL and a text box called "testimonial". The URL box is working great(when i put some text in this field on admin, the text appears on site), but the testimonial box(same proposal) dont works. What is wrong or what is missing? <code> &lt;?php add_action('admin_init', 'portfo...
Your above code should be working as is. There is however one logical error at the end of your saving function - you make the saving of both fields dependent on whether <code> $_POST['_url'] </code> is set. I suppose that is not intentional. You likely want something along the lines of: <code> if ( isset( $_POST['_url'...
Custom Metabox additional item
wordpress
How can i display movies added by an editor in profile page, i mention that the user (editors) have capabilities to add movies. I shoud use a querry? with args? I mention that the post_type is "post" - for movies ////// "trailers" - for trailers I want to get movies and trailers on the profile user page. How can i do t...
how can i retrive all the movies, i retrive only the amount set in Administrtor setings. How can i retrive the pages too Assuming that <code> $current_user-&gt;ID </code> is now correct, and it seems from your comment that it is. <code> $recentPosts = new WP_Query(); $recentPosts-&gt;query( array( 'author' =&gt; $curre...
How can i display movies in profile page, added by an user?
wordpress
I have few custom field assigned for each post, like: "Club" with value "club1" "Date" with value "date1" and so on... Now, I want to display from all the custom fields just those 2 " club" and "date". This is my markup : <code> &lt;div class="meta-container"&gt;&lt;?php the_meta(); ?&gt;&lt;/div&gt; </code> The proble...
You should use <code> get_post_meta() </code> twice (Ref to your stackexchange-url ("other question")): <code> &lt;?php echo get_post_meta( get_the_ID(), 'club', true ); echo '&lt;br /&gt;'; echo get_post_meta( get_the_ID(), 'date', true ); ?&gt; </code>
display specific custom fields
wordpress
i created 4 header and 4 footer widgets using a site spesific plugin, the reason been that when i change themes, i keep all of my widgets. i created two files, one for the header widgets and one for the footer widgets. what i need to do now is to add these to the header and footer files. at this stage i'm putting the f...
Actually including that code in your theme template files is the only surefire way to include those widgets in various themes. It's also the best to get them where you want them. Alternatively, you could accomplish this using hooks, but that relies on your themes actually calling the hook, and in the proper location. T...
Adding widgets to header and footer from plugin
wordpress
I make my <code> custom post </code> and the name of that custom post is <code> FAQ </code> . so now i want to show the <code> categories </code> of that <code> post </code> . The code i am using for this is <code> &lt;?php wp_list_categories('orderby=name&amp;include=3,5'); ?&gt; </code> But this not showing the post ...
Instead of wp_list_categories('orderby=name&amp;include=3,5'); use get_categories function shown in following code to get categories from custom post type. <code> &lt;?php get_categories('post=faq&amp;orderby=name&amp;include=3,5'); ?&gt; </code> For more information visit this page .
How can i show categories of custom post
wordpress
I have a static homepage with a custom template I.E hompage.php the blog loop is set to a static page named blogg, it uses the index.php page as a template, there a collection of other pages using the index.php as the default template so i am reluctant to change it. is there anyway to stop the blogg page from using ind...
Please consult the Template Hierarchy , and ensure that you are using the correct names for template files. <code> index.php </code> should be left as the default fallback for all other template files The site front page template file name is <code> front-page.php </code> . You need to rename your <code> homepage.php <...
stop blog page from using index.php?
wordpress
Is there a place from where I can get a list of all existing Wordpress plugins located in http://wordpress.org/extend/plugins/ I am trying to test my website for vulnerabilities and need such list. Thanks
http://plugins.svn.wordpress.org/ Good luck. It's a very long list and Otto normally becomes very angry if someone try to scrape the complete SVN-Repo.
List of all existing Wordpress plugins
wordpress
I'm trying to remove a menu item and tried several approaches, but have not had any luck. It was created from a FAQ plugin. If I use this line: <code> remove_menu_page( 'edit.php?post_type=question' ); </code> It will remove the main menu, however I only want to remove two sub-menu items contained inside that <code> ed...
<code> function remove_submenu() { remove_submenu_page( 'edit.php', 'edit-tags.php?taxonomy=faq-topic&amp;post_type=question' ); remove_submenu_page( 'edit.php', 'edit-tags.php?taxonomy=faq-tags&amp;post_type=question' ); } add_action( 'admin_menu', 'remove_submenu', 999 ); </code> Please read the Codex . <code> remove...
Remove a menu item created by a plugin
wordpress
I have a few Wordpress sites and all are down: An unexpected condition was encountered while the server was attempting to fulfill the request. Error code: 500 When I look at the apache log, there are errors (for different sites): <code> [Mon Apr 15 04:00:28 2013] [error] [client ...] PHP Parse error: syntax error, unex...
The correct line number for this variable in the most recent WordPress version are 207 and 209. So I guess something has mangled your files. It is impossible to answer what exactly happened without seeing that code. Look for new user accounts, and re-upload all WordPress files from the source .
unexpected '$mm' (T_VARIABLE) in wp-includes/functions.php
wordpress
By default WordPress pushes out a whole array of pages I don’t want or need - archive, author, blog, monthly, recent posts, categories, comments, attachment, taxenomies, search, search results, and probably a few others I’ve missed. Most of the time I’m building regular broshure websites with no need for anything excep...
You could redirect anything that's not a page or admin to home via the <code> parse_query </code> action: <code> function wpa_parse_query( $query ){ if( !is_admin() &amp;&amp; !$query-&gt;is_page ) wp_redirect( home_url() ); } add_action( 'parse_query', 'wpa_parse_query' ); </code> If it's not an admin screen or a quer...
How do I remove unwanted pages like archive, search, etc.?
wordpress
Or in any of the other 11 Wordpress tables. I also need to store: submission date, name, contact number in the same table. What approach would be best? A custom table or using a standard table?
If it's information that logically belongs to a post/page - you store it in <code> postmeta </code> (with <code> update_post_meta </code> function). If it's something that pertains to a user - <code> usermeta </code> table is for you. More still, there's Settings API in case you have a plugin that needs to persist any ...
Is it possible to store visitors IPs in wp_postmeta table?
wordpress
On a CPT page I am checking to see if the user is logged in; if they are, I'm checking to see if they have a meta entry which is <code> 'session-' </code> + the current page's stub. If they do, I increment the value by one. I thought this was all working fine, but I've just noticed that it's actually incrementing two s...
Are you by chance using Firefox to test your page? If so its prefetching function combined with WordPress <code> rel='next' </code> could be the culprit. Check your page source for those <code> rel </code> tags, and see if Firebug registers an extra GET request to the page specified in the <code> href </code> attribute...
Possible bug: update_user_meta is updating two unique meta entries
wordpress
I have this class for my posts: <code> &lt;?php post_class( 'entry-image' ); ?&gt; </code> I want to add the category names to get isotope work, i followed this guide http://www.acegoulet.com/2012/03/isotope-and-wordpress-how-i-did-it/ and i used this code to get category names: <code> $post_cats = get_the_category(); ...
You have to pass the values, not <code> echo </code> them. So something like this should work: <code> $post_cats = get_the_category(); $slugs = wp_list_pluck( $post_cats, 'slug' ); post_class( join( ' ', $slugs ); </code>
How to get category names in post_class?
wordpress
I'm trying to find out why any template different than index.php doesn't work. I've created a category-news.php file (also tried with category-4.php and mostly all alternatives), but when opening this url , I see a white page and checking the source code, I see the php code as HTML comments . Any idea to what could cau...
It was indeed an encoding issue. Opening with Notepad++ (I've managed to open it from a PC), I've realized that the file was encoded as UCS-2 something (I don't remember exactly if Big or Little Endian). I have no idea why this happened and how to avoid that in the future, as I've simply created this file from an exist...
PHP code rendered in HTML
wordpress
According to Codex we can perform <code> current_user_can </code> checks for certain <code> post_ID </code> , but I fail to find any bit of info how to set a capability explicitly for that <code> post_ID </code> . A follow up question - how to set custom capability (for ex. <code> download_doc </code> ) of the same typ...
As far as I know, you can not (easily) set up a custom capability for a certain post/page ID. What is described in the Codex, are the so-called meta capabilities (a set of predefined capabilities with additional arguments/information). A (not-that-easy) way is to write your own <code> my_add_cap </code> , <code> my_cur...
User capability per post
wordpress
I would like to add a new custom hierarchical taxonomy (or 3 custom taxonomies... dependent your answer) which contain the location by: City + States&amp;territories + Country. for example: Orlando + Florida + United States Monroeville + Pennsylvania + United States Noyabrsk + Yamalo-Nenets Autonomous Okrug + Russia In...
Yes implement it as a heirarchical taxonomy. Have your countries as the top level terms, then states, then cities. Your URL structure will naturally reflect this. I would advise against /city/state/country, as it is illogical and counter intuitive, and doesn't make for a good heirarchy ( so bad SEO too ). On your front...
Implement location at wordpress post via custom taxonomies?
wordpress
I currently have a code where, in my category.php, it checks if the specific category has subcategories, and if it does, show them using wp_list_categories. I'd love to have these wp_list_categories to show thumbnails, so I created a new walker, but I cannot figure out how to show thumbnails. I'd be fine with having it...
There's a great plugin called Taxonomy Images . It lets you set one image per category that you can then access in all sorts of ways. It's a little funky in that it uses some custom filters to return the images, but the documentation is pretty good and you should be able to figure it out. == UPDATE == Here's a quick ex...
Show thumbnail for category?
wordpress
I'm using the Jetpack plugin's Publicize module to push out post links to Facebook and Twitter. This works fine through the normal website, but not when I write and publish a post through the Android app. I'm wondering if there's any way to get it to do so.
At this time, there's no way other than logging in to the backend of your site from your mobile device. This currently doesn't work on the iOS WordPress app either.
Jetpack Publicize and Android
wordpress
I have this code that picks a random testimonial post. <code> &lt;?php $quote_args = array( 'post_type' =&gt; 'post', 'category' =&gt; 'quote', 'orderby' =&gt; 'rand', 'posts_per_page' =&gt; 1 ); $quote = new WP_Query($quote_args); if($quote-&gt;have_posts()): while($quote-&gt;have_posts()): $quote-&gt;the_post(); ?&gt...
There's no such parameter as <code> category </code> for <code> WP_Query </code> , so WP is ignoring it. You should use <code> category_name </code> , where the value is the slug of the category.
WP_Query calls all posts?
wordpress
In my testing environment, I've got one hundred plugins. I'm more interested in seeing first the Active plugins than the complete list ( <code> All </code> ). How can I change the default screen for the Plugins menu item?
There are two options, modify the menu link <code> href </code> attribute or redirect the main screen. Modify menu Alter the global variable <code> $submenu </code> . This method works for Single and Multisite. Problem: the submenu item <code> Installed Plugins </code> doesn't show in bold. <code> add_action( 'admin_he...
How to set Active plugins as the default screen?
wordpress
I was wondering whether it is possible to completely disable a function that is called in a parent theme's <code> functions.php </code> and if so, how? (Of course without deleting the function. Rather by adding something to <code> functions.php </code> of the child theme.)
Only under some circumstances. If the parent theme's functions are wrapped in <code> function_exists </code> conditionals then you should be able to replace them. For example: <code> // Parent if (!function_exists('p_wpse_95799')) { function p_wpse_95799() { // } } </code> If the child theme defines a function named <c...
Is it possible to disable a function of a parent theme?
wordpress
My parent theme generates the following class in <code> body </code> : <code> style-cupcake </code> . I don't want that. The best way to get rid of this is by adding my own functions in a <code> functions.php </code> file in my child theme, right? I tried this (a solution I found on WPSE) but it does not seem to work. ...
If you want to apply a filter to the same content another function has filtered, change the priority argument (which should have been named _execution_order_) to a higher number. So … <code> add_filter( 'body_class', 'my_body_class', 11, 2 ); </code> … will make sure <code> my_body_class() </code> will be called after ...
Remove class that has been added by parent theme
wordpress
I am creating a Custom Post Type using <code> register_post_type </code> . After running the function a new menu item appears in the Admin Panel. Under this item there are menu items for <code> new_item </code> and <code> all_items </code> . Is there a way to get read of the these two options considering that I created...
You can manipulate the global variable <code> $submenu </code> and remove them. In normal circumstances, the index key values are <code> 5 </code> (All items) and <code> 10 </code> (New item). In this example, the post type is <code> portfolio </code> : <code> add_action( 'admin_init', 'remove_cpt_submenus_wpse_95797' ...
Remove default subpages from Custom Post Menu
wordpress
I'm creating a theme framework and using a class to initiate all basic function of the theme (adding theme support, menus, etc). I've got stuck when I tried to enqueue the scripts and styles though: I'm using <code> add_action( 'init', array(&amp;$this, 'EnqueueScrits'), 10, 1); </code> and <code> do_action( 'init', $e...
The <code> init </code> action... is one of many WordPress core action hooks . Hence it does not require, i.e. should not be accompanied by, a manual <code> do_action </code> call. You only need to manually run <code> do_action </code> for custom, previously non-existent, action hooks. Further, <code> init </code> is n...
Using several add_action with parameters inside a class
wordpress
I'm scheduling a job in wp cron: <code> add_action('my_cron_hook', 'my_cron_action'); wp_schedule_event( time(), 'interval1', 'my_cron_hook' ); function my_cron_action(){ //do something } </code> The variable interval1 is set by the admin in another part of the code. Also, there is a switch that lets the admin enable o...
As described in wp_schedule_event first parameter is <code> $timestamp </code> - the first time that you want the event to occur. So just add interval to $timestamp. I think it should be like <code> wp_schedule_event( time() + $delay, 'interval1', 'my_cron_hook' ); </code> And set <code> $delay </code> as miliseconds b...
How to make wp cron job not fire immediately?
wordpress
Trying to get a front end post form to work with my custom post type. It posting to the post type but the 2 custom taxonomies and the tag field aren't posting/saving. Here is my CPT. <code> add_action('init', 'portfolio_register'); function portfolio_register() { $labels = array( 'name' =&gt; _x('User Lists', 'post typ...
I see two problems with your code: First You named your custom taxonomy <code> type </code> which is a Reserved Term Second You are trying to insert your taxonomy terms using <code> 'post_category' </code> which wont get the job done. What you can do is either create a `'tax_input' => array(' in your new post array e.g...
Front end post form won't post categories to custom post type
wordpress
I have a plugin that creates tables and one of them is failing and I feel like it's due to either my syntax or the fact that I'm trying to create a column with datatype DATE and not TIMESTAMP (only one that I can make work). Can someone look at my syntax below and tell me what is wrong? <code> $table = $wpdb-&gt;prefix...
Well, after looking at the other tables I had created successfully, only difference was the <code> description </code> column. Apparently WordPress or MySQL doesn't like that as a column name and somehow has it reserved. So, after renaming it, the table was created fine. Hope this helps someone else in the same boat.
Create Table Failed Column Date DateType
wordpress
I have my permalink format set to <code> /%category%/%postname%/ </code> and I have two posts with the same permalink slug, but in different categories. Ideally, the two permalinks should look like this: <code> http://example.com/category-1/post-title/ http://example.com/category-2/post-title/ </code> But when I publis...
The best method is to find another way to structure your URLs that doesn't break unique slugs. Even though you may not have any plans to do so now, you may need to change the URL structure of the site down the road in such a way that having duplicate slugs would break the site. Furthermore, there may be unforeseen seco...
Allow duplicate permalink slugs for posts in different categories
wordpress
Is there a way in which I can output some code in the header and choose it's location? some where like wp function add_admin_menu (where you can choose the placement).
Okay, here is a working example of what you (might) want to do. Put the following in your <code> functions.php </code> : <code> add_action('wp_head', 'my_jquery_code', 999999999); function my_jquery_code() { $jquery_code = &lt;&lt;&lt;JQUERY &lt;script&gt; // jQuery code goes here... &lt;/script&gt; JQUERY; echo $jquer...
output specific location in the header
wordpress
I'm building a payment gateway plugin for woocommerce which requires sending an XML request via <code> cURL </code> , encrypted with private key. I'm using the following code: <code> $xml_request ='&lt;?xml version="1.0" encoding="utf-8"?&gt;'; $test_URL = 'https://my-gateway.com'; // Here is where I change the file pa...
Based on @Mamaduka comment; the following changes resolve it: Use <code> plugin_dir_path() </code> to get the filesystem directory path: <code> $certfile = plugin_dir_path(__FILE__) . '/clientcert.pem'; $keyfile = plugin_dir_path(__FILE__) . '/clientkey.key'; </code> Then remove <code> getcwd() </code> . If you want to...
Passing .pem and .key files in cURL doesn't work in WordPress
wordpress
After reading the following suggestions from stackexchange-url ("Jan Fabry") regarding URL rewrite and the author slug I took the challenge in combining both solution in one. stackexchange-url ("Change author base slug for different roles") stackexchange-url ("Change the author slug from user name to nickname") Goal: T...
Edit: previous answer not working. Following solution does not provide sanitized nicknames, but should do the trick: <code> $nn = urldecode($query_vars['author_name'] ); $author_id = $wpdb-&gt;get_var( $wpdb-&gt;prepare( "SELECT user_id FROM {$wpdb-&gt;usermeta} WHERE meta_key='nickname' AND meta_value = %s", $nn ) ); ...
How to modify author base slug with groups and slug to use nice_nickname?
wordpress
I'm trying to figure out how to display the date that a post was last updated outside of the loop. I'm able to display the published date using <code> get_the_time() </code> but there doesn't seem to be a "loopless" function to get the date of the last update. Does anyone know hot to do this?
It is unclear if you are looking for the last updated post or for the last updated date for some particular post. The answer by @PatJ assumes the former. To do the latter: <code> $qry = new WP_Query(array('p'=&gt;1)); var_dump($qry-&gt;posts[0]-&gt;post_modified); </code> Or... <code> $date = $wpdb-&gt;get_var("SELECT ...
Get date of last update outside of loop
wordpress
Please look and help me how to solve this I want look like: Here But my code show: On Chrome On mozilla Website link Here
Is the dropdown symbol a webfont? becuase it is not getting loaded. There's a 404 error <code> Failed to load resource: the server responded with a status of 404 (Not Found) </code>
How to solve dropdown menu problem
wordpress
So I am trying to make it so that you can load a class from a child theme, theme or plugin using the following: <code> class AisisCore_Loader_AutoLoader{ protected static $_instance; protected static $_directories; public function get_instance(){ if(null == self::$_instance){ self::$_instance = new self(); } self::$_di...
when faced something similar I found a solution that works if your framework resides inside a plugin (so it seems). If your main plugin file (one that is recognized by WordPress as the plugin file) is in, e.g. <code> /plugin/Aisis/ </code> you can put this path in a constant, eg. <code> define('AISISPATH', dirname(__FI...
Am I not understanding plugins?
wordpress
I have exactly the same issue as stackexchange-url ("this closed question") and want to resolve it. In the comment section it asks the OP to add "Bug Information". Where do I get bug information from so I can add it to my question on this stack. I am new to WordPress (if thats not obvious) I am using WordPress 3.5.1 an...
Add <code> define('WP_DEBUG', true); </code> to your site's <code> wp-config.php </code> . That will cause errors, warnings, and notices (non-fatal warnings) to print to the screen. Those are the "debug information" so frequently requested. It is not advisable to have this enabled on a production (publicly accessible) ...
Where do I get "Bug Information" to add to a question?
wordpress
I've been doing some research into custom post statuses and scheduling posts and I had a question: I was wondering if it were possible to schedule a post to got from <code> future </code> to a custom post status instead of <code> publish </code> ? Main reason I'm asking is that I have a custom post type called <code> s...
Here is one idea: You could try to use the <code> future_to_publish </code> action to change the post status: <code> add_action('future_to_publish', 'set_status_online_wpse_95701'); function set_status_online_wpse_95701( $post ) { if ( $post &amp;&amp; $post-&gt;post_type==="stream"){ $post-&gt;post_status="online"; //...
Schedule future post to custom post status instead of publish?
wordpress
I've got a special query on my homepage that returns posts from a custom taxonomy. I'm trying to apply this filter for it. <code> add_filter( 'post_limits', 'my_post_limits' ); function my_post_limits( $limit ) { if ( is_home() ) { return 'LIMIT 0, 3'; } return $limit; } </code> However, this is also applied to my othe...
You should consider using the <code> posts_per_page </code> parameter as suggested by @Tamil. But in general you can also remove the filters you add. In your case you could remove it after your <code> WP_Query() </code> with <code> add_filter( 'post_limits', 'my_post_limits' ); $slider_query = new WP_Query( $args ) rem...
How to apply filter inside a single wp_query?
wordpress
I have been developing a woocommerce store. Now I have a requirement from client which I can't figure out how to do... The problem is we can use variable product in woocommerce, it's simple but what I need is to use conditional logic for variable products. Let's be more specific. Our product is a Ear Ring. Which may ha...
Woocommerce offers a plugin called gravity forms add on which uses gravity forms to add forms to your product page(note: if you don't already have gravity forms, you will need to purchase it for this to work). Gravity forms allows you to set conditional logic for the (options)dropdowns you create. I.E. show "this" opti...
Use conditional logic for woocommerce variable product
wordpress
I have followed a tutorial on how to upload images using Wordpress' 3.5 media uploader. All is well. I would just like to change the text of the actual upload button "Insert Into Post" to something like.. "Insert Image". I'm also trying to do this as a plugin option so it can be dynamic. Any help on getting this to wor...
Figured it out using a different method. Help from here . <code> $.fn.oeUpload = function(options) { // Set default options var defaults = { 'preview' : '.preview-upload', 'text' : '.text-upload', 'button' : '.button-upload', 'name' : 'Choose Image' }; var options = $.extend(defaults, options); var uploader; $(options....
Extend 3.5 media uploader plugin to change button name
wordpress
Let's say I disabled "DISABLE_WP_CRON" in wp-config.php Is it OK to run wp-cron.php twice overlapping? I've noticed sometimes wp-cron.php needs several minutes. I'd give it a full hour but the blogger I work with does a lot of scheduling through the day, she's very busy. Like say I have it running every 10 mins with a ...
How wp-cron.php behaves depends on how you execute it. If you execute it by HTTP request with 'doing_wp_cron' in the GET string, it will check if another wp-cron process has set a lock and exit if it has. By default, this is how WordPress executes it. It is easily done in crontab like so: <code> */10 * * * * /usr/bin/w...
Is it safe to run wp-cron.php twice if the first instance takes too long?
wordpress
Does anyone have an idea why my home_url() function gets the URL of the current page instead of the site address? (The site runs locally using MAMP.)
Since you didn't post actual code in your question, I can only speculate. However, a common problem is that, when calling <code> home_url() </code> , it is not echoed . The value of the function is returned , rather than echoed , so it must be explicitly echoed by the code. I'm guessing you have something like this: <c...
home_url(); showing current page instead of site address
wordpress
This wordpress site I'm touching up has a page hierarchy which is responsible for the urls. Basically the urls look like page1/subpage/subsubpage etc. The problem is, this site is for a recurring competition and therefore the urls are like 2011/results 2012/results 2013/results Which wordpress in turn makes 2011/result...
I use the Custom Permalinks plugin for Wordpress. With it, you can choose the permalink of each post/page individually. It is great for situations like yours where you want to fine tune the URLs in some corner cases.
Wordpress plugin for nicer looking slugs? Have multiple pages named the same but they get different slugs
wordpress
On a platform with many Editors, the problem that I am experiencing is that two editors proofread the same post simultaneously (and disregarding the warning notice about someone else currently editing the post). Is there a solution where I can restrict access to a post if it is currently being edited by a different use...
The warning notice gets dispatched by the function <code> wp_check_post_lock </code> . The following redirects the user back to the post listing screen if someone else is editing it. <code> add_action( 'load-post.php', 'redirect_locked_post_wpse_95718' ); function redirect_locked_post_wpse_95718() { if( isset($_GET['po...
Restrict access to post if it is currently being edited
wordpress
I am going to make a script that requires a scheduled run time. What is the best way to do this in Wordpress? Or maybe this can be done through some PHP method? I'm having a hard time finding even a clear place to start on this. Forgive the vague tag. "chron, scheduled" and other helpful tags were rejected by system an...
WordPress "cron" jobs are database entries that are run on a set schedule, rather than true Linux cron jobs. While WordPress cron jobs are relatively reliable, they do require someone to hit the site in order to check if they need to run. Meaning, if you have a very low traffic site, you may want to set up an actual cr...
Setting Up Scheduled Tasks (For Scripts to Run)
wordpress
I have a custom field to select a category (custom taxonomy) and then I will display a list of all of its child-categories. This works fine when I return the custom field as "term_id." HOWEVER. I would like to also get the slug from this selected category (the parent) so I can link to its category page (I don't think I...
It sounds like you're looking for the <code> get_term_link() </code> function. Your code will look something like this: <code> &lt;?php $catid = get_sub_field('selected_category'); $term_link = get_term_link( intval( $catid ), 'product_cat' ); ?&gt; &lt;h4&gt;&lt;a href="&lt;?php echo esc_url( $term_link ); ?&gt;"&gt;&...
Get ID and slug from taxonomy object
wordpress
I'm trying to get the count of published posts in a custom post type for the current user (to display on a profile page). I found this here on the forums: <code> &lt;?php global $wp_query; $curauth = $wp_query-&gt;get_queried_object(); $post_count = $wpdb-&gt;get_var("SELECT COUNT(*) FROM $wpdb-&gt;posts WHERE post_aut...
OK, after more Googleing, this seems to work without having to use MySQL and dive into the database directly: <code> &lt;?php $authorid = get_current_user_id(); query_posts(array( 'post_type' =&gt; 'user_video', 'author' =&gt; $authorid, ) ); $count = 0; while (have_posts()) : the_post(); $count++; endwhile; echo $coun...
Get count of custom post type created by current user
wordpress
I've created a custom post type and on the admin page for that post type I want an image displayed that can act as a guide for the users uploading images. Is there a function that I can use to insert an image into the admin for just that custom post type. (I have tried to Google this but all the results seem to be rela...
You could add a custom help Simple example taken from here <code> function mqw_example_contextual_help( $contextual_help, $screen_id) { # Uncomment this to see actual screen # echo 'Screen ID = '.$screen_id.'&lt;br /&gt;'; switch( $screen_id ) { case 'mycustompostname' : //Your custom post name //Just to modify text of...
Add a 'guide' image to custom post type admin page
wordpress
I have a Wordpress site and would like to track the basic statistics for the site; visitor numbers, visitor numbers for specific pages on the site, download statistics etc. For that purpose, I have installed the "Google Analytics for Wordpress"-plugin ( http://wordpress.org/extend/plugins/google-analytics-for-wordpress...
I solved the problem, and the download statistics now works in Google Analytics. Using the plugin mentioned above, download statistics are readily available, but it didn't work out for me until now. This was because I had made all the links for downloadable files on my site with relative paths - for instance with <code...
Download statistics for Wordpress site?
wordpress
<code> &lt;?php // Add Shortcode function blog_shortcode( $atts ) { // Attributes extract( shortcode_atts( array( 'id' =&gt; '', ), $atts ) ); // Code if (has_post_thumbnail()) { $url = wp_get_attachment_url( get_post_thumbnail_id( $id ) ); } if ( isset( $id ) ) { return '&lt;img src="' . $url . '"/&gt;&lt;a href="' . ...
You are assigning the attachment URL to your <code> $url </code> variable: <code> $url = wp_get_attachment_url( get_post_thumbnail_id( $id ) ); </code> then passing that same variable back to <code> wp_get_attachment_url </code> : <code> return '&lt;img src="' . wp_get_attachment_url( $url ) . '"/&gt;&lt;a href="' . ge...
Shortcode for a link and thumbnail
wordpress
I want to show one randomly picked testimonial on a page. Each testimonial is a post with a category of 'quote'. Each post has a custom field named 'who' with a name. I'm trying to use this code. <code> &lt;div id="introBottom" class="group"&gt; &lt;?php $quote_args = array( 'post_type' =&gt; 'post', 'category' =&gt; '...
Assuming - you saved the post in the "quote" type - you actually set and save a "who" meta for those post - you forgot to paste the close section of the loop, as s_ha_dum stated, your code should work. Like this <code> &lt;div id="introBottom" class="group"&gt; &lt;?php $quote_args = array( 'post_type' =&gt; 'post', 'c...
Randomly pick one testimonial post
wordpress
Recently I installed plugin called Delete-Revision and noticed that every post has registered few post IDs. I usually use save drafts and update post a few times when I write a post. Here's the screenshot http://i.stack.imgur.com/0pqgx.png . As you see I have 53 posts and Wordpress already registered 646 post IDs. How ...
You can stop WP creating revisions by adding the following to your wp-config.php: <code> define('WP_POST_REVISIONS', false ); </code> You can replace <code> false </code> with an integer if you just want to restrict the number a maximum number of revisions. If you check the plugin directory you'll find several that wil...
unused post IDs
wordpress
Observe the following code: <code> &lt;ul&gt; &lt;?php wpsc_start_category_query(array('category_group'=&gt;get_option('wpsc_default_category'),'show_thumbnails'=&gt;get_option('show_category_thumbnails'))); ?&gt; &lt;li&gt; &lt;div&gt; &lt;div class="image"&gt;&lt;?php wpsc_print_category_image(); ?&gt;&lt;/div&gt; &l...
The wpsc_start_category_query() function basically calls the native WP get_terms() functions that is used to make a wp query: $category_list = get_terms('wpsc_product_category','hide_empty=0&amp;parent='.$category_id); Since WPEC uses custom post types you can just build your own queries easily, here using http://codex...
Limit the number of results from wpsc_start_category_query
wordpress
Is it possible to set up a "dummy" page - just a page title that appears in the page listing, and a page that is not editable and doesn't have a slug? This is more of a hypothetical question, as I don't know where to start with code or determine the best way to go. I'd like to have the option to set up such a parent/ch...
OK here is my attempt, it is pretty hacky and in the end I was not able to remove the link/color of the parent item, but the parent link will not work.. so it kinda works. First create a CPT with the following params set: <code> $args = array( 'hierarchical' =&gt; true, 'public' =&gt; false, 'show_ui' =&gt; true, 'show...
Create a "Dummy" parent page for a hierarchy in page listing?
wordpress
I am using the admin role and 2 custom roles. On the author.php i want to be able to place the role of that user. I am using this to pull the role out in text <code> $curauth = $wp_query-&gt;get_queried_object(); $user_id = $curauth-&gt;ID; $user = new WP_User( $user_id ); if ( !empty( $user-&gt;roles ) &amp;&amp; is_a...
As an alternative to "current_user_can" WordPress provides " user_can " which will take a User object or ID as a parameter. Combining your top code and the bottom code with the new function it would look like this: <code> $author_user = $wp_query-&gt;get_queried_object(); // the queried object in 'author.php' should be...
Get Authors Role
wordpress
I need to display the total revenue of all orders for my products depending on if the logged-in user is the author of the product or not. I can't use the Quantity field as a multiplier either because of the Gravity Forms add-on for Woocommerce processes it in to a meta_key/value field, same goes for the product ID refe...
Got it solved. Probably not the most efficient way but it works! <code> SELECT product_id, meta_value FROM ( SELECT order_meta.order_item_id, order_meta.meta_value AS 'product_id' FROM wp_woocommerce_order_itemmeta AS order_meta LEFT JOIN wp_woocommerce_order_items AS order_items ON order_meta.order_item_id = order_ite...
Woocommerce: Grab total revenue of a product over all orders
wordpress
Custom keywords don't get linked if words end with this letters : ä, ö, å It works if those letters are inbetween. any idea how to fix this? Custom Keywords : meäts, www.google.com - works tillhört, www.rediff.com - works Elektrobitissä, www.git.com - does not work tillhrtö, www.rediff.com - does not work So out of the...
The author is using string functions for single-byte encodings: <code> $url = substr($line, $lastDelimiterPos + 1 ); $keywords = substr($line, 0, $lastDelimiterPos); </code> But in WordPress everything is encoded in UTF-8, a multi-byte encoding. So each time you have a character in your keywords that needs more than on...
SEO smart plugin not working for words ending with ä, ö, å
wordpress
I just want to remove calendar widget from the dashboard. How can I do that?
It's easy to remove a default widget from WordPress. Just add this to your functions.php file: <code> function remove_calendar_widget() { unregister_widget('WP_Widget_Calendar'); } add_action( 'widgets_init', 'remove_calendar_widget' ); </code> See more here: http://codex.wordpress.org/Function_Reference/unregister_wid...
How to remove calendar widget?
wordpress
I'm moving edit post dashboard to front end. So here is a case, I have to queries, one for product attachments and other for ALL. Now, I want to exclude product attachments from ALL attachments query here is an example how to exclude post thumbnail from WordPress Codex: <code> &lt;?php $args = array( 'post_type' =&gt; ...
Strange but it works with same principle I was trying to. Maybe I had some grammer error. Here is a code if somebody will need it in future as there was nothing in search result: <code> // get product media library $mediaArgs = array( 'post_type' =&gt; 'attachment', 'post_mime_type' =&gt; 'image', 'numberposts' =&gt; -...
Exclude an array
wordpress
For example if its <code> 'is_front_page' </code> I want to hide a div. If its not the <code> 'is_front_page' </code> i want to show the div. How can i achieve this? I am not sure on how I can achieve this. Any assistance would be great. Thanks
This is really not enough information, so I have to guess. A) The div is part of the content Use PHP, check for front-page, and if not, handle the div: <code> &lt;?php if (! is_front_page()) : ?&gt; &lt;div /&gt; &lt;?php endif; ?&gt; </code> B) The div is located somewhere else on the page Give the div an ID and use j...
How can I show/hide HTML elements if the page is_front_page
wordpress
I have a page called "People" with a custom template that takes in a variable called name: example.com/people/?name=FirstLast What I want is this: example.com/people/FristLast I know I need to use the add_rewrite_rule and add_rewrite_tag calls but I'm not sure how to achieve my desired result. I've tried this but I get...
You need to use your page id of "People" page. If i assume it is 12 then this will do, <code> add_rewrite_rule('^people/([^/]*)/?','index.php?page_id=12&amp;name=$matches[1]','top'); </code>
What is the proper way to use add_rewrite_rule to remove the (question mark)?
wordpress
I have a website made with wordpress which includes recipes. Now I would like to add the "photo" <code> hrecipe </code> Microformat tag in order to have a thumbnail on Google searches ( hrecipe photo tag ) My recipes pictures come from the featured image section. How can I now add <code> itemprop="photo" </code> to the...
Use the filter <code> post_thumbnail_html </code> . The callback takes 5 parameters, the first ( <code> $html </code> ) is the one that's returned and that we modify, and the others can be helpful to build the modification. <code> add_filter( 'post_thumbnail_html', 'add_tag_to_featured_wpse_95469', 10, 5 ); function ad...
hrecipe microformat tag to "featured image"
wordpress
I'm looking for some theme or plugin examples that showcase ways in which to enhance the usability of editing shortcodes and/or custom html objects that have been inserted into the editor. I know that its possible to apply runtime styles to elements (nextpage and image rollovers are a couple examples) and I'm looking f...
Have a look at my Gridster Plugin , it replaces every shortcode <code> [gridster id="" title=""] </code> with a visual replacement, like you know from the [gallery]-Shortcode. To change parameters of the current shortcode, you're able to click a button and a tinyMCE modal will let you change anything within a user-frie...
Hacking TinyMCE for better usability (shortcodes and html)
wordpress
I found this code, which apparently gets the category ID from the category slug: <code> $category = get_category_by_slug('category-name'); $id = $category-&gt;term_id; </code> But when I try to implement it into the following code, it doesn't work: <code> &lt;?php //list terms in a custom taxonomy using wp_list_categor...
You can't use <code> get_category_by_slug() </code> with a custom taxonomy. You need to use <code> get_term_by() </code> . <code> $category = get_term_by( 'slug', 'military', 'product_cat' ); </code>
Get category ID from category slug (not working)
wordpress
I have a particular CPT post that has a dash (-) in its title. I copy this title in a variable <code> $var </code> using <code> get_the_title() </code> then I create a custom field somewhere else with a value equal to <code> $var </code> : <code> add_post_meta($my_post_id, 'some_name', $var); </code> Problem: in the cu...
<code> get_the_title() </code> is treated with <code> wptexturize() </code> by default. That changes the dash. To fix it remove the filter and reapply it if it was really set: <code> $wptexturize = remove_filter( 'the_title', 'wptexturize' ); $title = get_the_title(); if ( $wptexturize ) add_filter( 'the_title', 'wptex...
Remove wrong dashes from get_the_title()
wordpress
I'm trying to print out all the posts within every taxonomy for a custom post type called <code> product </code> (jigoshop products). So i get all of the taxonomies using <code> $cats = get_terms('product_cat'); </code> , then i loop through them all, and get all the posts that is within the taxonomy. The problem is, i...
tax_query takes an array of tax query arguments arrays (it takes an array of arrays) but you are using only single array. The correct code is as following. <code> $uposts = get_posts(array( 'post_type' =&gt; 'product', 'numberposts' =&gt; -1, 'tax_query' =&gt; array(array( 'taxonomy' =&gt; $cat-&gt;taxonomy, 'field' =&...
tax_query in get_posts() not working?
wordpress
I have tried to make a theme options page (starting with a sample theme options page from themeshaper) and I want to check if a comma separated list of categories is valid. Remove duplicates, remove non-existing categories, but it doesn't work. :( It is deleting the last value if I check with empty(): <code> function t...
In the following code, <code> $i </code> is not going to be your category ID. <code> foreach($slidercats_array AS $i =&gt; $value) { $cat = get_category($i); // cat_ID if ( empty( $cat ) ) unset($slidercats_array[$i]); } </code> At least I don't see how it could be. If you <code> explode </code> a string the keys in th...
How to check if a categoryID exists in a theme options page
wordpress
I have this category <code> exclude_cat </code> with id 39 I want to exclude it from the home. So I use for <code> WP_Query </code> args like this: <code> $args = array ( 'category__not_in' =&gt; array( 39 ), //exclude ID ); </code> Works. But now I want to only exclude it if is the only category on the post. So exclud...
I end up with this to exclude the mama category: <code> /** * filter home and blog pages for mama category * exclude posts that have that category unless they have more categories * @param string $where * @return string */ function filter_mama_cat( $where) { // get the term to exclude $term = get_term_by('slug', 'mama'...
WP_query exclude a category unless it has more then one catagory
wordpress
I want to associate certain users by means of a custom key stored in the user_meta for both users. There may be more than one-one relationships, so it'll be in an array. If 2 users have the same key in this _mm_group_membership array, they're part of the group. Now since meta_value queries are restricted to simple comp...
First of all, I believe your syntax is incorrect. Should be: <code> $group = '_mm_group_membership'; // key should be a string </code> Secondly, did you try using <code> $u-&gt;get </code> ? Here's what the doc says : If fields is set to all_with_meta, it will return an array of WP_User objects. So yes, if you specifie...
Test if key is in user_meta array
wordpress
I'm wondering how to create differents <code> wp_mail_from </code> and <code> wp_mail_from_name </code> for specific actions that use the built-in mail system in Wordpress. For example, when a new comment comes, notify the user using this: <code> function comments_new_mail_from($old) {return 'comments@example.com';} fu...
There are two ways: Inspect the original value, and if it specific for this case return a specific new value. Chain the filters: register the mail filter only on specific hooks. So you have to find a hook that happens before <code> wp_mail() </code> is called. Simple example, not tested, just a guide: <code> // change ...
Different wp_mail_from and wp_mail_from_name for specific situations
wordpress
I have built a Wordpress plugin that allows the user to export all pages, with their levels and urls, to a csv file. The problem I have is that I keep getting error messages when trying to export the csv file: Warning: Cannot modify header information - headers already sent I have checked the config &amp; functions fil...
Move your download/output code into admin_init hook. This hook is called before anything is output. It should work. <code> &lt;?php /* Plugin Name: Your Site's Functionality Plugin Description: All of the important functionality of your site belongs in this. Version: 0.1 License: GPL Author: Your Name Author URI: youru...
Headers already sent error with CSV export plugin
wordpress
When signed into my blog, this graphic is up on top. I know it shows visitor pattern over 48 hours, but does anyone know what the number represents? I searched on the WP site, and am not finding this.
When you sign in, You can see tiny site stats chart(displayed in above screenshot) in your toolbar called a Sparkline. The number in Sparkline represents the highest number of visitors visited in 48 hours of day. You can find more information in wordpress.com Stats Support . I have copy pasted the content below from th...
What does this number represent in JetPack stats?
wordpress
I have this line of code : <code> $registration_date = get_the_time('F j, Y').' at '.get_the_time('g:i a'); </code> I just ran this on my BlueHost hosted website and it returned : January 29, 2013 at 12:54 pm However, on the same site I can see in the dashboard that post publication dates are correct.
get_the_time() function returns the time of the current post within loop. If you want to display today's date then use date function of core php.
Wrong date returned by get_the_time
wordpress
I have a bit of a complicated menu structure that I am trying to figure out the best way to do this. I have a top nav that has 4 SECTIONS. Each Section has upto 2 levels deep. Also, I have a SUB Nav that is based on what section you are in and displays as a drill down showing what page you are own. For example, say I c...
also got UberMenu from code canyon that works perfect for the top menu, I can just use the conditional widgets on the right.
Wordpress Flyout Menus
wordpress
When running the following code : <code> $voucher = 'MK0186'; $is_in_database = $wpdb-&gt;get_results( "SELECT * FROM my_codes_table WHERE code =" . $voucher ); </code> I get : WordPress database error: [Unknown column 'MK0186' in 'where clause']. I don't understand why.
The WPDB prepare method is what you're after, as this will prep your data for passing to a query and also ensure data matches the type its intended to be whilst also handling quoting where necessary at the same time. Fixing your code could be a matter of.. <code> $voucher = 'MK0186'; $is_in_database = $wpdb-&gt;get_res...
PHP variable in WordPress database query
wordpress
On my category page (not single.php) I'd like to have the recent posts from that category in the sidebar, it also needs to be dynamic. I'm already doing something similar on single.php, but I can't think how to do it on the category.php page. <code> &lt;div class="related"&gt; &lt;?php $related = get_posts( array( 'cat...
Here's how I'd get the 20 (at most) most recent posts in the <code> category.php </code> page: <code> &lt;?php $max_posts = 20; $cat_ID = get_cat_ID ( single_cat_title( '', false ) ); $args = array( 'category' =&gt; $cat_ID, 'numberposts' =&gt; $max_posts, ); $myposts = get_posts( $args ); foreach( $myposts as $post ) ...
Recent posts in current category?
wordpress
I've recently bought the WP Directory Portal theme from ThemeForest. Since the theme doesn't do frontend posting of custom post types, I've resulted to using WP User Frontend Pro. There's a problem hooking into the custom post type meta though. When I check PHPmyAdmin, I find the following field: _ait-dir-item in wp_po...
That data is serialised PHP, if you pass in a PHP structure it will be serialised into a string. When you pull it back out, it's de-serialised automatically, e.g.: <code> $post_id = current post ID..... $data = get_post_meta( $post_id, '', true ); </code> To see the structure in a human readable form, use something lik...
My theme saves their custom post type's metadata as a serialized array, how to access the keys?
wordpress
I am working on my first plugin. I've got a custom post type, with a meta box which has 4 fields which uses update_post_meta, &amp; these work 100% fine. I have then tried to create a meta box that has repeatable fields, when the user clicks 'add new field'. I want users to be able to add as many fields as they like. M...
To add a meta box to multiple post types, one <code> add_meta_box </code> per post type is needed. In this example, instead of duplicating the same code, a <code> foreach </code> is used. More post types can be added to the array and the meta box will be added in all of them: <code> add_action( 'add_meta_boxes', 'add_c...
Meta boxes not showing on custom post type. Blank page?
wordpress
When you are at the comments menu in wp-admin you only see 20 comments at the time, so if you want to delete alla comments you can ONLY mark the 20 comments you see on current page. It dosent mark comments that are on the next page. Found a solution but dont know where to look for it In WP-admin -> Screen layout there ...
You can use <code> add_filter('edit_comments_per_page', 'return_999'); function return_999(){ return 999; } </code> since the user options are filtered in the <code> WP_List_Table::get_items_per_page() </code> class method : <code> /** * Get number of items to display on a single page * * @since 3.1.0 * @access protect...
Wp admin - Set default value to 999 in comments
wordpress
I am using wordpress 3.5.1 and lately there seems to be a recurring problem with the save draft function where it seems like the draft was saved (i.e the wheel finishes spinning without an error message) but alas, all edits are lost. This happens both in the regular editor as well as in the distraction free wring space...
In wordpress root directory,open file wp-config.php,and find this code: <code> define('WP_DEBUG', true); </code> and just set the value to false somehow like this: <code> define('WP_DEBUG', false); </code> so that all errors will display,hope this can be helpful to u! and also the best way is to resintall wordpress if ...
How to debug | Some times the "Save Draft" button seems to spin but does not actually save
wordpress
I'd like to create a specific template for specific category (not for single product). Is it possible and how to do it? Thanks,
You can create specific template for specific category using taxonomy-product_cat.php template. For more information visit this page .
Woocommerce - Specific template for product category?
wordpress
Hey I'm trying to make all .doc/docx .xls/xlsx files open in office online. This would mean that every link to a .doc <code> http://mywebsite.com/wp-content/uploads.link.doc </code> would have to instead point to the office online preview link <code> https://view.officeapps.live.com/op/view.aspx?src=http://mywebsite.co...
I'm not sure this question is WordPress -related. It sounds like it might be handled via <code> .htaccess </code> redirect, or a browser extension. That said: you could try to use the <code> wp_get_attachment_url </code> filter, that is applied to the URL returned by <code> wp_get_attachment_url() </code> . For example...
open all .docs in word online
wordpress
I would like to retrieve multi-dimensional arrays (that have been created with metaboxes), &amp; display them on the front end of a website using shortcodes. My Question: How do I retrieve multi-dimensional arrays from the wp_postmeta table, &amp; display them in a shortcode? Do I use <code> extract </code> ? Thank-you...
When you save an array as post meta, WordPress will serialize it to a string and save that string. Let’s take a simple array: <code> array ( 1 =&gt; array ( 'url' =&gt; '/', 'title' =&gt; 'Home' ), 3 =&gt; array ( 'url' =&gt; 'stackexchange-url 'title' =&gt; 'WordPress Stack Exchange' ), 4 =&gt; array ( 'url' =&gt; 'ht...
How do I retrieve multi-dimensional arrays from the wp_postmeta table, & display on a website?
wordpress
Currently my posts display the total count of comments (i.e both replies and sub-comments). I want to display only the number of reply count in my index.php (and not comments for a reply) for each post i.e. where comment_parent = 0 I have tried different codes but no luck. What's the best way to acheive this?
Based on stackexchange-url ("this answer") I suggest the following code: <code> // the theme's functions.php /** * Get the number of top level comments for a post. * * @param int $post_id * @return int */ function wpse_95242_top_level_comments_for_post( $post_id = NULL ) { if ( NULL === $post_id ) $post_id = get_the_ID...
display only parent replies count in index.php
wordpress
The below code is used to pull in my Tweets and post them as individual blog posts on my Wordpress site. I would like to add a "Follow me on Twitter link" after the tweet when it is displayed in the main body of the post. How would I do this? So for example, it want it to look like: Title - Truncated Tweet Body - Tweet...
In the <code> insert_posts </code> function, before the line <code> $post_id = wp_insert_post( $post ); </code> add the following (and suit to your needs): Link to Twitter User Page <code> $post['post_content'] .= '&lt;a href="http://twitter.com/__USERNAME__"&gt;' .'Follow me on Twitter' .'&lt;/a&gt;'; </code> and/or L...
Adding a custom line of text to php code
wordpress
With comment pagination, Google doesn't index the older pages and comments become essentially lost to searches. Is there a way to let search engines crawl paginated comments, perhaps by generating a sitemap file that includes all paginated comments?
The reason of why Google doesn't index paginated comments is because of an issue with the <code> canonical URL </code> in your header. You can learn more about the reason behind this in a comprehensive stackexchange-url ("question that I posted earlier"). There is an excellent solution posted there for paginated post p...
How to let crawlers search paginated comments?
wordpress