question
stringlengths
0
34.8k
answer
stringlengths
0
28.3k
title
stringlengths
7
150
forum_tag
stringclasses
12 values
I'm trying to use <code> wp_redirect() </code> to redirect searches to a format that I have established in <code> .htaccess </code> . Unfortunately, I'm running into some problems doing this. I need to redirect search to a series of folders, and then append the remaining parameters to then end of the URL, the end resul...
*haha* That one is actually pretty funny. You literally did shoot yourself in the foot. Have a look at the source-code link-template.php line 1922 says: <code> if ( ! empty( $path ) &amp;&amp; is_string( $path ) &amp;&amp; strpos( $path, '..' ) === false ) </code> The last condition <code> strpos( $path, '..' ) </code>...
Using wp_redirect and .htaccess to re-route searches (and pass along the remaining GET vars)
wordpress
I'm having some issues adding multiple loops. I have a custom post type (locations) that uses a single page template (single-locations.php). I'm trying to add additional loops to this template that will display (x) number of posts from different categories (regular post categories) depending on what custom post type id...
It sounds like what you are trying to do is make a kind-of "related posts" feature for your "Locations" single post display based on the category. You don't need to be checking to see if the post is in the "Locations" post type. You are using <code> single-locations.php </code> unless you site is broken only "Locations...
Multiple Loops On Custom Post Type Template?
wordpress
Pagination seems to work fine... I have 21 posts... and it will go to 3 pages... however... every page shows 10 posts and the same content as the first page.... <code> &lt;?php $temp = $wp_query; $wp_query= null; $args = array( 'post_type' =&gt; 'a-reports', 'post_status' =&gt; 'publish' ); $wp_query = new WP_Query( $a...
In order to get pagination working with secondary Loops, you have to pass the <code> $paged </code> parameter to <code> WP_Query </code> , other wise the query does not know which set of posts to load and will load the first set, page 1, every time. I got it to work by adding <code> 'paged' =&gt; $paged </code> inside ...
next_posts_link returns same content of 1st page
wordpress
I successfully created my theme options page using this framework: https://github.com/devinsays/options-framework-theme The problems Is that when, for example, I try to load the Option: 'logo_image' <code> global $options; var_dump($options); /* dumps NULL */ </code> and <code> foreach ($options as $value) { if (get_se...
If you've done everything correctly during the setup, then you should be able to load the logo_image option like this: <code> $my_theme_prefix_option = of_get_option('logo_image'); </code>
Wordpress theme options framework, I can't read them in my templates
wordpress
I have a wordpress page. In that wordpress page, user will have access to the following Window to <code> Publish </code> their Post in to the webpage. If the user enters an URL in any of the three filed I have marked in red above, my php code will look in to those URLs and determine if they are spam or not. Therefore, ...
You should never ever modify WordPress Core files. WordPress has an Plugin API ( http://codex.wordpress.org/Plugin_API ) that allows you to modify WordPress to your liking without changing Core code. In your case, the solution is to check the contents of the custom meta box fields before they are saved via the save_pos...
How to edit php code in WordPress Post file?
wordpress
I've got a search form on my page, which works perfectly fine when I enter the text and press enter, however it doesn't submit anything when <code> .submit-search </code> button is clicked, why is that? note: <code> value="2" </code> is there for specific use. <code> &lt;form action="&lt;?php echo home_url(); ?&gt;" cl...
I suggest you use <code> &lt;input type="submit" /&gt; </code> or <code> &lt;button type="submit" /&gt; </code> . <code> &lt;input type="button" /&gt; </code> is valid but doesn't submit the form by default (without you adding any ajax/js magic to it.
Why is this search form not submitting when button is clicked?
wordpress
I'm working on a site where there are multiple content types in addition to the built-in ones (see list below). I'd like to establish the ability to mark related content in any direction, from any content type to any other. The content types are: <code> post </code> <code> page </code> <code> topic </code> (from bbpres...
Why not do... <code> $my_post_types = array( 'post', 'page', 'topic', 'case', 'note', 'question', 'therapy_guideline' ); p2p_register_connection_type( array( 'name' =&gt; 'my_post_relationships', 'from' =&gt; $my_post_types, 'to' =&gt; $my_post_types, 'sortable' =&gt; 'any', 'reciprocal' =&gt; false, 'cardinality' =&gt...
Creating relationships between multiple content types
wordpress
I have some script that works on my dev server but not on my staging server: <code> add_action('wp_head','get_gz_info',30); function get_gz_info(){ ?&gt; &lt;script type="text/javascript" &gt; jQuery(document).ready(function($) { var modal = {action:'modal_action'}; var ajaxurl = '&lt;?php echo admin_url('admin-ajax.ph...
The person who setup the staging server placed and .htaccess in the admin side that prevented the site from accessing files in the wp-admin area.
Why is ajax working on one server and not the next?
wordpress
What function can be used to update a post's post date and time to the current date &amp; time?
Call <code> wp_update_post() </code> with a special value for <code> 'post_date' </code> and <code> 'post_date_gmt' </code> : <code> $time = current_time('mysql'); wp_update_post( array ( 'ID' =&gt; 123, // ID of the post to update 'post_date' =&gt; $time, 'post_date_gmt' =&gt; get_gmt_from_date( $time ) ) ); </code>
Changing the post date and time with function
wordpress
I would like a sub-menu in which the user visits a page, post, or category (in this example, "info") and is then displayed a list of children categories/pages. Not a dropdown menu, but a menu that appears only when the user is already in the parent category. I need a code which continues to display the parent's childre...
Funny, I just ran into this same conundrum a few months back... Background I found it quite bizarre that Wordpress applies all manner of CSS classes to menu-items in order to distinguish the current item and its ancestors, but then completely ignores the sub-menus and their relationship with the current item. I wanted ...
Building a Sub-menu: Display Parent Category/Page's Children When Viewing Children
wordpress
To cut out a few steps and make it easier for authors, I have included a custom field for authors to enter details (may include HTML). I want to add the custom field to a shortcode in the theme. From multiple sources, I have a few sets of code, but the custom field is not displaying: <code> &lt;?php if ( get_field('tes...
removed printf <code> &lt;?php if ( get_post_meta($post-&gt;ID, 'test_field', true) ) { echo do_shortcode('[shortcode]'. get_post_meta($post-&gt;ID, "test_field", true) . '[/shortcode]'); } ?&gt; </code>
How to include custom field in shortcode (do_shortcode) in theme file
wordpress
i wanted to make an offline copy of my live website on my pc so i installed xamp and installed on it wordpress and exported the database and took a copy of files on fttp and after i have done eveything and i wanted to make open my live website to edit something it gives me a blank page when i open <code> "www.sitename....
i found the problem there was space in function.php
wordpress login blank screen
wordpress
How can I access the loop that displays all the custom posts in a custom post type's <code> edit.php </code> page? Is there some sort of hook for this? I want to do some condition checking on the data that is being pulled during the loop and it doesn't seem like WP offers any obvious solution.
Yes there is some sort of hook for this: manage_posts_custom_column Pseudo code: <code> function my_cpt_custom_column( $column ) { global $post; if ( 'my_cpt' == get_post_type( $post ) ) { switch ( $column ) { case 'title': // do stuff with $post-&gt;post_title echo $post-&gt;post_title; break; case 'some-other-heading...
How to loop through custom posts in admin edit screen
wordpress
I have created an options page in my WordPress theme that allows the user to input a url/upload an image to an input field. The field has the name headerimage_options[image] and when it is populated it can be saved and outputted in the theme with the following code: <code> &lt;?php echo esc_url( $headerimage_options['i...
Instead of echoing out these images, just store them as strings inside an array and choose one of the array items at random. <code> &lt;?php $headerimage_options = get_option('headerimage_options' ); $images = array(); $images[] = '&lt;img title="'.get_bloginfo('name').'" src="'.esc_url( $headerimage_options['image'] )...
Display random image url from list of input values
wordpress
I just built up a beta environment for testing my new Wordpress site. I didn't migrate the database; I did my own installation again and ported over my theme (it's a simple theme) to my new instance. Everything is working great, except for the one custom post type that I am using. Here is the relevant code from <code> ...
One problem is that your <code> 'capability_type' </code> parameter <code> 'community' </code> doesn't match your <code> 'capabilities' </code> array values. From the Codex : capability_type (string or array) (optional) The string to use to build the read, edit, and delete capabilities. May be passed as an array to all...
Custom post type isn't working
wordpress
Normally wordpress will auto-update fine without a fuss, but now throws the old ftp credentials form up in my grill. I haven't changed any permissions in between updates, even running <code> chmod </code> and <code> chown </code> recursively to be sure, but still wordpress wants the ftp. Out of the few wordpress instal...
If you're pretty sure about that the file owner of wordpress folder is as same as that one who runs apache. (use <code> ps aux|grep 'httpd' </code> or <code> ps aux|grep 'apache' </code> ) Here is a lousy solution for you: <code> function force_use_direct_fs($method,$args){ if($method != 'direct') $method = 'direct'; r...
Can't Auto-Update, but permissions are good?
wordpress
I have a theme with an options page. And on that page there are 1083 options. I've noticed that the last 13 are not saving. They were saving at one point, but after I added new options above them, they stopped working. I suspected that I may have run up against some kind of option limit or limit on the array so to test...
The limit is probably not WordPress specific, but caused by PHP. max_input_vars </code> might be set to 1000 , so not all fields might reach WordPress. You can stackexchange-url ("store 4,294,967,295 or 4GB (232 – 1) characters") in one option, so I don’t think this is your problem. If it is, you should consider a sepa...
Is there a limit to the number of options you can store in one settings field of wp_options?
wordpress
I am trying to put in an SVG inside my post, but it seems WordPress removes the content. e.g. <code> &lt;svg xmlns="http://www.w3.org/2000/svg" version="1.1" height="190"&gt; &lt;polygon points="100,10 40,180 190,60 10,60 160,180" style="fill:lime;stroke:purple;stroke-width:5;fill-rule:evenodd;"&gt; &lt;/svg&gt; </code...
According to this post , if you put all the svg block in one line , it will be rendered. This should work: <code> &lt;svg xmlns="http://www.w3.org/2000/svg" version="1.1" height="190"&gt; &lt;polygon points="100,10 40,180 190,60 10,60 160,180" style="fill:lime;stroke:purple;stroke-width:5;fill-rule:evenodd;"&gt; &lt;/s...
How do I use inline SVG in WordPress
wordpress
I would like to exclude the word "class" from being matched to the search term "lass". On a site I'm helping manage, the search term "lass" is quite prominent. Unfortunately, that matches the common usage of "class" within the content of many, many WP posts, returning plenty of irrelevant results. However, I still want...
You might try to use the <code> posts_search </code> filter as elegantly suggested by @Kaiser in the first link you provided. Here is one idea: <code> function filter_search($sql){ global $wpdb; if( strpos(get_query_var("s"),"lass") !== false AND strpos(get_query_var("s"),"class") === false ){ $sql .= " AND {$wpdb-&gt;...
How to exclude the word "class" from being matched in search?
wordpress
I have written a funtion to get post image attachments, is there any way of ordering these images such that the first is always the post_thumbnail? Code below Thanks John <code> function oliver_single_gallery_thumbs() { global $post; $args = array( 'post_parent' =&gt; $post-&gt;ID, // For the current post 'post_type' =...
First, exclude the featured image (= post thumbnail) from the query, then set up the posts array as combination of the featured image and the other images. Put this directly below <code> $args = ... </code> and above <code> $attachments = ... </code> : <code> if (has_post_thumbnail($post-&gt;ID)) { $featured_image = ge...
Retrieve Image Attachments Getting Post Thumbnail Image First
wordpress
I created a custom taxonomy and i want to disable the taxonomy to show on the admin bar below my custom post type. How do i disable it?. The reason i want to disable is because the user is not allowed to add a category.
Did you have a look in the Codex? The option your are searching for is ' <code> public </code> ' Just add it as an argument in your call to <code> register_taxonomy() </code> like this: <code> $args = array( 'public' =&gt; false, ... [your-other-arguments] ... ); register_taxonomy( 'genre', array( 'book' ), $args ); </...
Disable custom taxonomy on admin bar
wordpress
Problem description I'm searching for a way to add a settings section/settings fields to the <code> ~/wp-admin/options-discussion.php </code> page exactly where Core calls &hellip; <code> do_settings_sections('discussion'); </code> How to When I register the setting and add the settings field, nothing appears: <code> f...
You have to call <code> add_settings_section() </code> first, pass a unique ID and assign it to the page (poor name) <code> discussion </code> : <code> add_settings_section( 'ads_id', 'Extra Settings', 'ads_description', 'discussion' ); </code> Then register a callback to save your field(s) … <code> // Register a callb...
Add settings fields on options discussion admin page
wordpress
I originally had this query on a posts category page: <code> &lt;?php $page_query = new WP_Query('post_type=post&amp;cat=145'); ?&gt; </code> Which worked, but it only displayed the first 4 posts. So I wanted to display all the posts from the category, as well as change the posts per page limit, as well as set the orde...
You are passing the <code> cat </code> parameter twice-- the second time is empty. <code> $page_query = new WP_Query( 'post_type=post&amp;cat=145'. '&amp;posts_per_page=-1&amp;cat' . // &lt;-- here '&amp;orderby=date&amp;order=asc' ); </code> Maybe it is just me, but I find those query-string-like parameters hard to re...
Multiple post queries -category,posts per page,orderby
wordpress
Not sure this is a question suitable for this forum, but I'll try: I think it is pretty convenient targeting elements in css/jQuery for a specific page by using the page-id-{ID} generated by body_class() in a template. But this gets problematic when developing on a local dev machine and then transfering to a staging se...
You could use slugs instead of IDs. Taken from the Starkers theme (add it to your functions.php): <code> add_filter( 'body_class', 'add_slug_to_body_class' ); function add_slug_to_body_class( $classes ) { global $post; if( is_home() ) { $key = array_search( 'blog', $classes ); if($key &gt; -1) { unset( $classes[$key] )...
Using page-id-{ID} from body_class() in local dev, versus live staging
wordpress
I'm writing a plugin to edit my profile page. How can I save data of an input field to the database and then display it? This is my code. The first part is the display in HTML: <code> &lt;form method ="POST"&gt; &lt;div id= 'dynamic_input_groups'&gt; &lt;input type='text' name='group[]' id='group[]' class="regular-text...
Don't use <code> update_usermeta </code> , it is deprecated, <code> update_user_meta </code> is the one to use. You get the previously saved value out with <code> get_user_meta </code> . <code> &lt;input type='text' name='group[]' id='group[]' class="regular-text" value="&lt;?php echo esc_attr( get_user_meta( $user-&gt...
How to save data of an input field to an array
wordpress
I am building WordPress admin plugin. In which I have a metabox with 10 checkboxes (It can be more than that). At below there is submit button. My requirement is: (A) open a lightbox when some one clicks on submit button. (B) In this lightbox I want to show all selected checkbox values with checkboxes. (C) Again, On th...
Before anything... to get a good answer, you need to provide a good question. Code examples would help a lot. You can use jQuery to accomplish what you need. Suppose your checkboxes are in a list. You can assign an ID to the list UL. You can use jQuery to run through every element in that list and see if the checkboxes...
Lightbox on wordpress post page
wordpress
I am having trouble with Woocommerce product details and order details relationship. I'm not able to find the product ID of a related order ID on the View Orders page of the Woocommerce theme. I simply want to get the product content and permalink etc on View Orders page. I tried searching in <code> wp_postmeta </code>...
you can get the order items of an order by <code> $order = new WC_Order( $order_id ); $items = $order-&gt;get_items(); </code> then if you loop through them, you can get all the relevant data: <code> foreach ( $items as $item ) { $product_name = $item['name']; $product_id = $item['product_id']; $product_variation_id = ...
Get Product id from order id in Woocommerce
wordpress
I set up two select boxes in one meta field by putting two arrays inside the 'options' array of my callback. The HTML is outputting fine, but the meta is not being saved to the database... Here is a pic of the meta box setup (for whatever random reason that make me think it would be helpful): ...aaaaaaaaaaaaaaaaaaand h...
In your save code, the value of <code> $field['id'] </code> is <code> event_timeframe </code> , which does not exist in <code> $_POST </code> , so your options will never save. You need to dig down into your <code> options </code> array to get to <code> timestart </code> and <code> timeend </code> : <code> // loop thro...
unable to save post meta on single field with multiple selects
wordpress
I have some script that is loading in the admin. I only need it to load on the new post and edit posts screens. What is the best way to do this?
Check the page and enqueue your script accordingly: <code> global $pagenow; if (! empty($pagenow) &amp;&amp; ('post-new.php' === $pagenow || 'post.php' === $pagenow )) add_action('admin_enqueue_scripts', 'enqueue_my_scripts'); function enqueue_my_scripts() { wp_enqueue_script(...); } // function enqueue_my_scripts </co...
How do I only load js on the post-new.php and post.php pages in admin?
wordpress
Using a child of Twenty Twelve, I've been adding color to all the major containers (#main, #content, #secondary, etc.) using <code> #arbitrary-id { background-color: #dedede; } </code> This works for everything but body. I should be more clear: it changed the body background color until I messed with the background col...
It sounds like you just need to remove support for the custom background color . <code> remove_theme_support( 'custom-background' ); </code> You will probably need to hook it to get it to run after the parent <code> functions.php </code> <code> function disable_bg_wpse_97248() { remove_theme_support( 'custom-background...
I can't change the body background-color through style.css
wordpress
I am working on a site at the moment where I need to save several different types of meta data for a custom post type. At present I have a text input that is saving with no problem but am struggling to get a select field to do the same. This is the function that outputs the select field: <code> function kwi_department_...
Ok, I've solved the issue myself. Turns out I had the <code> name="_department" </code> attribute duplicated in another field that was conflicting with my select field. My select saves just fine now I've edited that.
Why is my select meta data not saving?
wordpress
I am having some trouble with the Twitter Widget Pro Plugin - for some reason in internet explorer if the first tweet has a link, it will make the link its own list item and add a bunch of extra padding above it. I have tried using different twitter feeds, changing around the widget settings but haven't had any luck fi...
The mark-up surrounding the widget is malformed. IE isn't handling this as well as other browsers. <code> &lt;h1&gt;Twitter&lt;/h1&gt;&lt;h2&gt;&lt;a href="http://twitter.com"&gt;Follow&lt;/h2&gt; &lt;div&gt;&lt;h2&gt;&lt;span class='twitterwidget twitterwidget-title'&gt; </code> Note the opening anchor tag before "Fol...
Internet Explorer seperating lists differently in Twitter Widget Pro than all other browsers
wordpress
In my plugin, I have a list of titles and permalinks in the options table. It's updated every time my custom post type is saved. Since I'm saving permalinks the option data can become bad if the user changes their permalink structure. I need a action that I can hook into that happens whenever the permalink structure is...
The action is <code> update_option_permalink_structure </code> . You get the old and the new value as parameters. <code> add_action( 'update_option_permalink_structure' , 'my_custom_function', 10, 2 ); function my_custom_function( $oldvalue, $_newvalue ) { // do something } </code> There are also the actions <code> upd...
Is there an action for when permalinks are rebuilt?
wordpress
Short Version: Custom menu with a custom post type that supports a custom taxonomy. The custom post type works, the menu for it works and stays open. The custom taxonomy works, but the sidebar menu doesn't stay open. I need to make the category keep the submenu open, as it does natively (when not placed in another menu...
I could not find a built-in way to accomplish this solution, but I have created a workaround I realized, if the menu won't stay open, why not open it myself? I created the following two functions, which are easy enough to understand. They need to be called in a javascript file which is loaded via admin script (see the ...
Custom dashboard menu does not stay open for the custom Taxonomy within it
wordpress
Before asking for help I would like to clarify that I don't have advanced skills on PHP. What I want to achieve is to display different messages for every period of time that I set (I need this to LOOP every day) . After reading this -> http://codex.wordpress.org/Function_Reference/current_time I tried to check: <code>...
You would just need to format the time that is returned by current_time() with the php date() function like this: <code> $my_time = date('G', current_time('timestamp')); </code> The param 'G' tells the function you just want to have the hour part (0 to 23) of the date. Have a look here: http://www.php.net/manual/en/fun...
Echo Messages By Checking current_time()
wordpress
I'm currently using this little jQuery toggle snippet to show/hide child categories using the wp_list_categories function; <code> $('.sidebar ul.children').hide(); // Start by hiding child categories $(".sidebar li.parent-item").hover(function () { $(".sidebar ul.children").slideToggle("slow"); </code> But currently ho...
Use <code> $(".sidebar li.parent-item").hover(function () { $(this).find("ul.children").slideToggle("slow"); }); </code>
Make this jQuery toggle snippet target each list item individually
wordpress
I want to check if user is logged in and if have created a page. If so, option 1 is shown. This all works fine. But how to display page title+link of page created by that user between {page title with link to page} See the code below I tested it with no results. As used in the code below, nothing special is showing, on...
To list all pages with title and permalink from one user you need <code> $wpdb-&gt;get_results() </code> . The following code is based on this answer: stackexchange-url ("How to count current user's pages?") First, we move the counter into a separate helper function; we might need it later again: <code> /** * Get all p...
How to display page title+link of page created by user
wordpress
I started to use contact 7 plugin and I'm having a slider and some effects on other images when i activate the plugin they stop working this is the web page <code> http://www.digitalways.com.sa/ </code> I don't understand what it do! if it stops the javascript or css files but I searched in the files if it has the same...
i found the solution i just added all scripts together
contact 7 plugin stops some pages from working properly
wordpress
Well, let me get to the point, im trying to Display a specific category using the Wp favorites posts plugin this is what im adding <code> $category_id = get_cat_ID('news'); </code> but it doesn't seem to work it shows all category's on favorite posts instead of a certain specific category. this is what im messing aroun...
This should do what you want: <code> $have_favorite_posts = false; $favorite_post_ids = wpfp_get_users_favorites(); $cat = get_category_by_slug('news')-&gt;cat_ID; // or if you want to use the category name (as tried in your code) // $cat = get_cat_ID('News'); if (! empty($favorite_post_ids)) { $fp_query = new WP_Query...
Wp favorites posts by specific category?
wordpress
I realize how clumsy and inefficient this query is but SQL is not my strong point. I use the following query to pull the latest 8 events from a custom post type called Event Posts. However, I also need to include in those 8 posts any posts which have been stickied. Because of some very complicated client needs which ex...
Sticky posts are kept in a serialize array in an option in <code> $wpdb-&gt;options </code> with the <code> option_name </code> of <code> sticky_posts </code> . So you will need to pull that option and add an <code> OR </code> to the query. <code> $sticky = get_option('sticky_posts'); $qry = "... OR {$wpdb-&gt;posts}.I...
How do I query for posts by custom meta and those that have been stickied?
wordpress
Is it possible to keep dashboard screen options (for instance, not showing custom fields) across computers?
They do work across many computers, as long as you're logged in with the same username. If they don't, try clearing your browser cache.
Screen options on a different computer
wordpress
I made a custom post type called 'portfolio' but I want to change it to 'projects'. What would be the exact steps I need to take in order to safely change the name and prevent the custom post type posts from disappearing in the dashboard? Note: There are already posts in <code> portfolio </code> so I can't just switch ...
If you have no posts in your portfolio yet. It would be really simple. Rename everything with "Portfolio" into "Projects". You will lose nothing and change the name. Edit : Try use this plugin http://wordpress.org/extend/plugins/ptypeconverter/ to export the current posts safely and import it into your new custom post ...
How do I safely change the name of a custom post type?
wordpress
I registered a few custom sidebars, and the corresponding code in my version of TwentyTwelve theme now looks like this: <code> register_sidebar( array( 'name' =&gt; __( 'Sidebar #1', 'twentytwelve' ), 'id' =&gt; 'sidebar-1', 'description' =&gt; __( 'Appears on posts and pages except the optional Front Page template, wh...
Instead of calling <code> get_sidebar() </code> call <code> get_sidebar( 'somethingelse' ); </code> . It will attempt to load <code> sidebar-somethingelse.php </code> and if that doesn’t exist it will load <code> sidebar.php </code> . You can then modify the <code> sidebar-somethingelse.php </code> to load a different ...
Add #sidebar-2 to a custom page template
wordpress
I run a horror related blog. Google is upset with me for displaying adsense in a sidebar widget for one specific post number (4603) that contains an article about an 18+ topic. How can I disable the widgets for a specific id?
I'd recommend the plugin Widget Logic to handle all your needs. You can just add logical tags to the individual widgets on the sidebar. http://wordpress.org/extend/plugins/widget-logic/
Disable widgets on specific posts
wordpress
W3 Total Cache isn't compatible with WPTouch. Is there a way to get the benefits of W3 Total Cache without using the plugin?
Did you already try adding all the mobile user agents to the "Rejected user agents" list in w3tc? I use this list for this purpose (not created by me and certainly not complete but enough for my purpose): iphone ipod ipad aspen incognito webmate android dream cupcake froyo blackberry9500 blackberry9520 blackberry9530 b...
W3 Total Cache benefits without using plugin?
wordpress
I am lazy loading some images with URLs which are added via custom fields. The lazy load plugin I'm using requires a place-holder image in the <code> src </code> attribute and the actual image in data-original. http://www.appelsiini.net/projects/lazyload I need the image height and width as well, so I've been using <co...
You cannot use <code> bloginfo() </code> while your are outputting using <code> echo </code> because bloginfo it self also out puts string using <code> echo </code> . Below will work for you, you also have extra double quote which i have removed.... <code> &lt;?php $attch_id_1 = pn_get_attachment_id_from_url(get_post_m...
bloginfo('template_directory') img src
wordpress
I am working on a theme with a front page that will have two loop sections. The first will loop three posts from a Custom Post Type (ill-portfolio), the second will loop three blog posts. In both instances I want the posts to be generated in a <code> &lt;ul&gt; </code> . I am also using the Advanced Custom Fields plugi...
While using query_post(), you can reset the query at the end by using <code> &lt;?php query_posts('post_type=ill-portfolio&amp;posts_per_page=3'); . . . &lt;?php endwhile; endif;?&gt; &lt;?php // Reset Query wp_reset_query(); ?&gt; </code>
Custom Loop and Standard Blog Loop Issue
wordpress
I am writing a plugin where I need to pre-load some data in the custom tables that I create upon Activation. My inserts have run fine thus far until I attempt to insert a record with a DATE datatype. Can someone please tell me what I have wrong here? Database Table Definition: <code> $sql = "CREATE TABLE IF NOT EXISTS ...
<code> date </code> does not take a human readable string. It takes a Unix timestamp . You need to convert that human date to a timestamp with <code> strtotime </code> . <code> 'begin_date' =&gt; date('Y-m-d', strtotime('2012-08-14')), </code> Of course, there is really no need to convert a YEAR-MONTH-DAY date into a t...
How-To: wpdb Insert Record With Date
wordpress
When you have a menu for say pages, it's easy to highlight your current page, since WP puts a class on it. But what I have is a sidebar with the 20 latest posts in a loop and a separate main content area for the normal page loop and single page/category page etc. My sidebar loop looks like this. <code> &lt;ul&gt; &lt;?...
The simplest thing would be to add a class to the link that contains the post ID. <code> &lt;a href="&lt;?php the_permalink() ?&gt;" class="post-&lt;?php echo get_the_ID(); ?&gt;"&gt; </code> You can then write a custom CSS function, put it in functions.php and hook to the wp_head. This function only serves to echo the...
Highlight post in sidebar on single page
wordpress
I have used the following code to make a slideshow of the featured image of a category.I want to show the title of the post when hovering on the image. But I don't know how to do it. Anyone please help. Code in functions.php <code> register_post_type( 'featured_content' ); add_action( 'init', 'get_the_js' ); function g...
Alternative approach: <code> &lt;li class="cycle-item slide-&lt;?php echo $i; ?&gt;"&gt; &lt;span class="featured-title"&gt;&lt;?php the_title(); ?&gt;&lt;/span&gt; &lt;a href="&lt;?php the_permalink();?&gt;"&gt;&lt;?php the_post_thumbnail('featured'); ?&gt;&lt;/a&gt; &lt;/li&gt; </code> then hide the span with CSS, sh...
Title on hovering on the featured image
wordpress
Is it possible to do this? I already know about get current_user_can(), which does not work like I need. I'd like to be able to use an array if there are multiple roles. <code> // Check roles to only add fields to necessary users function check_role( $user ) { $user_role = get_user_role($user-&gt;ID); if($user_role == ...
On the profile page exists a global variable <code> $profileuser </code> . The member <code> $profileuser-&gt;roles </code> is an array of all roles for that user. <code> &lt;?php # -*- coding: utf-8 -*- // Plugin Name: personal_options add_action( 'personal_options', 'print_user_roles'); function print_user_roles() { ...
Add user settings to specific roles
wordpress
I am using this plugin, which creates a gallery of posts, fetching a thumbnail and the titles of the posts displayed in it. I have enabled Custom Fields , and have created (and filled in values) a field for the posts I want displayed in the gallery. I know that I have to put <code> &lt;?php the_meta(); ?&gt; </code> wi...
You should be able to pass the name of the custom field in the shortcode: <code> [cgview title="fieldname"] </code> Not tested; I just took a look at the source code (and now my eyes hurt).
Display meta data from a custom field within plugin Category Grid View Gallery
wordpress
It looks like social login plugins (such as Wordpress Social Login, OneAll etc.) do not create users in the original wp-database as regular registration from Admin dashboard. Hence it is not possible to add or get user-meta-data from current user the 'normal way'. Question is: How to get user-meta from Social Login reg...
You do not specify a plugin you are using. But if a user login with a OAuth (used by the mosts social plattforms), then he cannot be logged in in WordPress. Why? A user needs a username and password to login. OAuth (and other methods) do not provide a password. They only answers with Yes, this user is authorized or No,...
How to get user-meta from Social Login registered users?
wordpress
Is it easily possible to edit links in the <code> WP_Admin_Bar </code> global <code> $wp_admin_bar </code> instance?
Yes I recently ran into the situation where I wanted to change the profile link in the user-info section of the admin bar. The problem is that you can only get all nodes, add and remove them. Not edit. And you also cannot modify the <code> $wp_admin_bar-&gt;nodes </code> property due it is private. When easily removing...
Edit specific nodes in WP_Admin_Bar
wordpress
I am trying to figure out how exactly I can add a button to the top of the theme customizer. The spot I am talking about is where the "close" and "save" buttons are. The ones that are above everything else and directly above the preview panel. Would this have to be done through a modification of the core WP files or ca...
If you take a look at the source code of this part … <code> do_action( 'customize_controls_print_styles' ); do_action( 'customize_controls_print_scripts' ); ?&gt; &lt;/head&gt; &lt;body class="&lt;?php echo esc_attr( $body_class ); ?&gt;"&gt; &lt;div class="wp-full-overlay expanded"&gt; &lt;form id="customize-controls"...
How to add button to top of theme customizer?
wordpress
I'm in the process of trying to style a checkout page in Woocommerce and need the login form to be visible all the time when the user is not logged in rather than initially hidden then toggled on and off. What I have discovered is that the login form is generated by Woocommerce's <code> woocommerce_login_form </code> f...
If you use a custom theme, you can create your own <code> shop/form-login.php </code> , and Woocommerce will use that. Then you can change the class names or add custom JavaScript. Upgrades for the core are still possible.
Disable auto hide of the login form on Woocommerce's checkout page
wordpress
In HTML5 you can use placeholders in your forms to name fields or guide the users. I would like to use this in Jetpack forms but it seems it doesn't support it. You can add a default value like <code> default="Your name" </code> , but the user will then have to delete this text before writing. With placeholders the fie...
You can do this by means of jQuery (which means this is rather a jQuery/JavaScript question). Put the following in one of your (already included) JS files, or create a new JS file and enqueue it, or hard-code it in between <code> &lt;script&gt;...&lt;/script&gt; </code> tags: <code> jQuery(document).ready(function($) {...
Placeholders in Jetpack Contact Form
wordpress
I have been looking through the theme customization API documentation and google to simply find out the names of the control types already built in to the theme customizer. More specifically I am looking for what the name is of a simple button. I have tried using the type button and input and I am getting nowhere makin...
Have a look in the source: http://core.trac.wordpress.org/browser/trunk/wp-includes/class-wp-customize-control.php Basic control types: text checkbox radio select dropdown-pages Also some advanced control types ( as-described by Otto ): WP_Customize_Color_Control - extends the built in WP_Customize_Control class. It ad...
List of all theme customizer control types?
wordpress
I use the birdtips theme and it formats the post date as <code> $birdtips_posted = date(__('Y. F j.', 'birdtips'), strtotime(get_the_time("Y-m-d"))); </code> where Y. F j. is already rewritten to reflect my language. As far as I understand, __ is the translation function, but how can I tell Wordpress that I use Hungari...
Use <code> date_i18n() </code> : <code> date_i18n( 'Y. F j.', strtotime( get_the_time( "Y-m-d" ) ) ); </code> From the function’s description: Retrieve the date in localized format, based on timestamp. If the locale specifies the locale month and weekday, then the locale will take over the format for the date. If it is...
month name translation
wordpress
I'm using the following code to create a widget to select a post from a dropdown - which works fine in the backend, but I can't figure out how to display this on the frontend... <code> &lt;?php class RandomPostWidget extends WP_Widget { function RandomPostWidget() { $widget_ops = array('classname' =&gt; 'RandomPostWidg...
<code> $instance['page_id'] </code> should be the post ID of the selected post. So … <code> function widget($args, $instance) { $post = get_post( $instance['page_id'] ); echo $post-&gt;post_content; // you should add the common filters here var_dump( $post ); // more data } </code> … should be a good start. To save the...
Widget Development - Displaying dropdown content
wordpress
I'm a wordpress newbie and I have annoying problem. I have a few custom post types (capability_type=post). Two of them i created with "Custom Post Types" plugin and when i put its categories in navigation menu they are working well. When clicked it gets current-menu-item. The problem is with one of the other post type ...
Solved! The problem was in the plugins settings ... To fix this problem go to: Events (Left Admin Sidebar) -> Settings -> Pages -> Event Categories and set " Override with Formats? " to NO Thats it ... I hope this information to be useful for others, and save them a lot of time, which they coud use for a walk, drinking...
current-menu-item not working with custom post type
wordpress
I am creating a plugin for post.php page where user can select (one or more) blogs and copy the post content,title,author,categories everything in selected blogs. The copied post would be the child of original post and now the original post would be parent post. I want to know that is there any WP function which can di...
To copy a post from one blog to another you can do something like this: <code> function copy_post_to_blog($post_id, $target_blog_id) { $post = get_post($post_id, ARRAY_A); // get the original post $post['ID'] = ''; // empty id field, to tell wordpress that this will be a new post switch_to_blog($target_blog_id); // swi...
Copy posts from one blog to another in multisite environment
wordpress
I'm using the German version of WordPress and in wp_editor the two tabs for "visual" and "html" are named "visuell" and "text". I would like to change the "text" tab to "html". Do you know how I can achieve that? Here is a screenshot to show you exactly which tab I am talking about. http://s1.directupload.net/images/13...
Filter <code> gettext_with_context </code> and change the name here: <code> &lt;?php # -*- coding: utf-8 -*- /* Plugin Name: Rename 'Text' editor to 'HTML' */ add_filter( 'gettext_with_context', 'change_editor_name_to_html', 10, 4 ); function change_editor_name_to_html( $translated, $text, $context, $domain ) { if ( 'd...
Change the name of the wp_editor tab "html/text"
wordpress
I am using a Page Links To plugin that allows me to link the post title to an external web page, rather than to the content of the post. And I link some of the post titles to external pages, and others – to pdf files, stored in the uploads folder of my site. I want to add a little pdf icon to those post titles that are...
There is no need to add anything via WordPress, you can simple add the following rule to your CSS file: <code> a[href$='.pdf'] {} </code> This will target all links pointing to a URI ending in .pdf. This works in all modern browsers and from IE7 upwards.
Add a class to post title if a link ends with a certain extension
wordpress
I want to exclude a category from showing in a function, but cannot figure out how to do it for my specific code as below. I want to make it so that any post that is in the "featured" category, does not display - but all other posts do. <code> $args = array( 'posts_per_page' =&gt; 4, 'category_name' =&gt; 'featured'); ...
To exclude a category, you need to know its ID. You can then exclude it like this (please not the minus before the ID): <code> $args = array( 'posts_per_page' =&gt; 4, 'cat' =&gt; -the_category_id_to_put_in); </code> The WP Query class reference has more information if you need it: http://codex.wordpress.org/Class_Refe...
Exclude category
wordpress
I'm trying to see the structure of an array, but when I try to <code> echo </code> the array, all it says is 'array'. Please can someone explain how I can see the structure of an array? <code> add_shortcode('book', 'ac_post_meta_shortcode' ); function ac_post_meta_shortcode() { $mpdata = get_post_meta( 31, 'custom_repe...
I suspect you just want to see the content of the array for dev purposes, in which case s_ha_dum's suggestions of <code> print_r( $mpdata ) </code> or <code> var_dump( $mpdata ) </code> should suffice. To output the content of the array as a string (assuming it is not multi-dimensional) you could just <code> echo implo...
echo is just displaying the word 'array', rather than the array
wordpress
I have an "About Us" page on my site with some child pages. I have created a "History" custom post type, where the rewrite slug is 'history'. I use archive-cpt_history.php as the template file for that CPT. Everything works exactly as its configured, I can go to website.com/history/ to see my CPT loop in all its glory....
In your register post type arguments, set <code> rewrite </code> to <code> true </code> and <code> has_archive </code> to the path you want for the archive page ( without leading slash): <code> 'rewrite' =&gt; true, 'has_archive' =&gt; 'about-us/history' </code> As for the redirection, rather than getting all the way t...
Specify a Page as the parent to the CPT Archive
wordpress
I've got a weird situation whereby I sometimes can't log in as clicking on a link (or going directly) to /wp-login.php shows me a blank page with the words 'Not Permitted'. If I go to the /wp-login.php page directly from that 'Not Permitted' page, then I can log in using my details. If I try and log out again though, I...
I made an answer out of this now to give a more detailed write-up to your question. As the botnet is so large and the attack is happening with so much IPs (some providers say they have seen > 90.000 different addresses) it makes no sense anymore to start blocking single IPs (using plugins like Limit Login Attempts or f...
Wordpress error on log out 'Not Permitted' and can't log out
wordpress
I would like to take a stored array, from the meta_value <code> $custom_repeatable </code> and just display the line <code> 'hamsters repeat one' </code> , but the following code doesn't display it how I'd like. Here is the code: <code> add_shortcode('clowns', 'this_is_attempt_two'); function this_is_attempt_two() { $m...
Your array of post meta is here: <code> $makethishappen = get_post_meta(31, $custom_repeatable, true); </code> The value you're after is here: <code> $custom_repeatable = $makethishappen['custom_repeatable']; </code> That value is stored as a serialized array; to get at its value, you have to unserialize it. <code> $un...
How do I just display the part of the array that I want to?
wordpress
I have a theme which has a page to display a keyword taxonomy called <code> taxonomy-keyword.php </code> . From this page I instantiate a sort of ViewModel called <code> KeywordPage </code> . It looks like this: <code> namespace MyTheme\ViewModels; class KeywordPage { __construct() { wp_enqueue_script( 'keywordpage_scr...
Your constructor runs on the request from which you make the AJAX request, but not within the request that processes that AJAX request. The request that initially loads the page, and the AJAX request are two separate requests with no preservation of state between the two. This is not unique to WordPress, this is how AJ...
Why can wordpress not find the actions I add in my constructor?
wordpress
I am using the following wordpress theme, which is pretty cool btw.: http://demo.s5themes.com/?theme=simplecorp Now the site has a custom Theme Options build in, where you can specify all the content inside the Dashboard(eg. For the contact page, you fill in your details on the dashboard theme editor. Now my issue is t...
<code> &lt;?php the_content(); ?&gt; </code> That's the function that displays everything you saved in Pages - > Contact Page. You just need to move that anywhere you would like. Just keep in mind the_content() must be between the while loop for it to work. <code> &lt;?php if (have_posts()) : while (have_posts()) : the...
Wordpress theme: Add page content to the bottom of the Contact form
wordpress
how can i change function in general-template.php without affecting this core file on this: <code> if ( ! is_user_logged_in() ) { if ( get_option('users_can_register') ) $link = $before . '&lt;a href="' . site_url('wp-login.php?action=register', 'login') . '"&gt;' . __('Register') . '&lt;/a&gt;' . $after; </code> to th...
Use the following filter named <code> register </code> : <code> add_filter( 'register', 'wpse_96892_register_link' ); function wpse_96892_register_link( $link ) { if ( is_user_logged_in() ) return $link; return str_replace( // search array ( site_url('wp-login.php?action=register', 'login'), __('Register') ), // replac...
changing function wp_register
wordpress
I have the following code to look up the longitude and latitude based off of a custom field upon saving the post. My address fields (street_1, city and state) are separate. I have searched and thought that I could put the values from these separate meta keys into an array and pass them to the URL. I have the state valu...
There is no need to put them into an array. According to google's documentation you should just separate out the various pieces of the address in the url like a standard (U.S.) formatted address. <code> // Example taken from google's docs: $state = 'CA'; $street = 'Mountain View'; $address = '1600 Amphitheatre Parkway'...
Get specific custom field keys from a post and put into an array
wordpress
So I pulled a site down to my local machine to do some work on it. Copied the files, find/replace on the database to update the url, added a host. Everything worked fine until I changed the permalink settings. Now every page uses the index.php template in my theme folder instead of the page.php. Of course it works fine...
Okay. I got it working now. Turns out it was one or both of my custom taxonomies I had added on with my custom content type. I knew it had to do with my custom content types or taxonomies because, if I took them out and reset the permalinks, everything worked fine. The names for these two taxonomies where type and year...
Mamp pro permalink issues. Pages keep reverting to index.php
wordpress
I have a custom post type 'courses', with a course description as post_content, and number of attachments I also have a custom post type 'course units', linked to the courses with a custom field 'course-id' I created a template file for the course dashboard, showing a list of the units, and a couple of links - to the c...
You may use template redirect action to check if there is parameter set for description and based on that you can show desired template. <code> &lt;?php add_action('template_redirect', 'course_template_redirect', 1); function course_template_redirect() { global $wp_query; if($wp_query-&gt;post_type=='courses' and $_REQ...
implement separate templates for 1 post type
wordpress
I hope this isn't just the result of typo on my end, but if it is, I'm not seeing it. I'm adding a custom post type to my site. Actually I'm adding three. Two of them I'm trying to set custom capabilities for a new class of users. In my admin panel I cannot get this to register when adding the function block of code be...
You probably cannot see the new CPT items in your menu, because you have indicated that they require specific caps, yet you have not assigned those same caps to any role - including your own. Add the following to your code: <code> function my_cpt_add_caps() { foreach ( array( 'administrator' ) as $role_name ) { $role =...
Conflict between Capabilities and Menu Visibility with Custom Post Types
wordpress
Is there a way to print a hierarchy of posts/pages/custom post types based on page template? EG. I am often asked to review another web site and I'd like a way to 'see' all the pages that are assigned to the 'Newsletter' PHP template and all the pages assigned to the 'Product Info' PHP template. Is there a plug-in like...
To get all posts ordered by their template you need two functions: one for the query, and one to add a custom order. Get the posts <code> function get_posts_by_template() { add_filter( 'posts_orderby', 'orderby_template' ); $query = new WP_Query( array( //'meta_key' =&gt; '_wp_page_template', 'post_type' =&gt; 'any', '...
Generate Catalog Of Posts Based On Template
wordpress
I am trying to create a Windows Store App using IdeaPress ( https://github.com/ideanotion/ideapress/issues ), which relies on the JSON API Plugin ( http://wordpress.org/extend/plugins/json-api/other_notes/ ). Unfortunately requesting recent_posts returns just content up to the <code> &lt;!--more--&gt; </code> tag. I'd ...
You can try this to show the full post content only in the JSON API: <code> function remove_more_wpse_96740($content) { if(get_query_var('json')){ global $post; $content = preg_replace('/&lt;!--more(.*?)?--&gt;/','',$post-&gt;post_content); } return $content; } add_filter('the_content', 'remove_more_wpse_96740',1); </c...
JSON API not showing full content
wordpress
I created a custom post type with a custom taxonomy. I have about 1500 posts all of which are assigned to some sort of taxonomy term...some being assigned to 200+ terms. I noticed that from the dashboard, it takes an extremely long amount of time to view the custom post types, most of the time resulting in a 504 Gatewa...
The CPT and taxonomy terms are created via plugin. I was able to lessen the query by adding the following to my plugin: <code> add_action( 'pre_get_posts', 'nwtd_lpfs_custom_admin_query' ); function nwtd_lpfs_custom_admin_query( $query ) { if( !is_admin() &amp;&amp; !$query-&gt;is_main_query() ) { return; } if( is_post...
WordPress dashboard, viewing CPT results in 504
wordpress
NEW EDIT I solved it, as written in answer, the problem where that variables are 'forgotten' (not so techy I know, sorry for this) when <code> function </code> starts. EDIT: I found the problem is this: <code> 'name' =&gt; _x( $plurcpost, $singcpost ), </code> if I use text instead of a variable everything works proper...
Ok, I solved it, maybe instead of asking I should drink 1 more coffe or sleep something more, anyway the solution is to move this part: <code> $singcpost = of_get_option('custom_posts_name_s_n1'); $plurcpost = of_get_option('custom_posts_name_p_n1'); $desccpost = of_get_option('custom_posts_name_d_n1'); $imgcpost = of_...
Custom Post not working as expected
wordpress
If I set the permissions to the CSS file in my theme to 444 and then attempt to edit it in the Appearance Editor, WordPress is not prevented from editing the file and in fact change the permissions to 644 while it makes the edit. Why does WordPress change a file's permissions? How do I make the site more secure and pre...
Per the link provided in my comment to your question , if you wish to prevent the editing of files by WordPress, just disable the file editor. To do that add the following to your site's <code> wp-config.php </code> file: <code> define('DISALLOW_FILE_EDIT',true); </code> Or to disable the file editor and the plugin and...
Why does WordPress change a file's permissions?
wordpress
Can I specify a template to use with the_permalink()? Why I need this: when they click a link from a certain page, I want to show that user a different template (extra content) on the linked page.
The <code> the_permalink() </code> function links to the single post view for the given post-type. As per the Template Hierarchy , the page used to render the single post view is <code> single.php </code> . So, if you want to modify the template used to render the page when clicking <code> the_permalink() </code> , cre...
Can I specify template to use with the_permalink?
wordpress
Auto-generated excerpts just take the first x characters from the post content and cut that off at a certain point. When there is a <code> table </code> or <code> pre </code> element in that part, the excerpt looks rather useless most of the time. How can I hide the content of these elements from my auto-excerpts?
To filter the content only when an auto-excerpt is generated you have to chain the hooks: Hook into <code> get_the_excerpt </code> and register a filter for <code> the_content </code> . In the second filter remove both elements and their content before the excerpt can see it. Sample: <code> add_filter( 'get_the_excerpt...
How to hide and content from auto-generated excerpts?
wordpress
I'm building a plugin that has a meta box. Some of the fields in the meta box are required. Is using Jquery the only method for achieving this? Can I require that a field is filled in using php? Thank-you.
You can use Javascript to create a first-line convenience warning, but that is not a secure solution. You will need to interrupt the post save to truly create a required field. <code> function req_meta_wpse_96762($data){ $allow_pending = false; if (isset($_POST['meta'])) { foreach ($_POST['meta'] as $v) { if ('your_req...
How to make a meta box field a requirement
wordpress
Hello I have a question which is maybe more PHP question than WordPress, but could be interesting in a WordPress context in case someone wants to add properties to an WP object. I have created a custom taxonomy and I'm using an option to add order to each terms. To get that order in my theme, i use those two functions ...
<code> $term_object-&gt;order </code> tells you <code> $term_object </code> is an object. <code> array_replace() </code> expects an array, not an object. Not sure why it works, maybe PHP is casting the object to an array. <code> array_replace( $term_objects, (array) $term_object ); </code> … could fix the warning.
array_replace throwing php_warning but working anyway
wordpress
I want to open javascript error message when some one clicks on "Move to Trash" link in Publish box in wp-admin
Put the following in your <code> functions.php </code> : <code> if (! empty($GLOBALS['pagenow']) &amp;&amp; 'post.php' === $GLOBALS['pagenow']) add_action('admin_footer', 'trash_click_error'); function trash_click_error() { echo &lt;&lt;&lt;JQUERY &lt;script&gt; jQuery(function($) { $('#delete-action a').unbind(); $('#...
Add javascript confirmation popup on "Move to Trash" link
wordpress
In the media library every attachment post has an "Attached to" column. I've developed a plugin that adds author profile and a facebook like banner image. I now discovered that the attachment posts, that are used as profile pictures, are not marked as "attached to". I used a wordpress console plugin to get <code> WP_Po...
Attachments are attached to a parent post. So when you get an attachment object, look into <code> $attachment-&gt;post_parent </code> . If that is <code> 0 </code> , the file is not attached. The parent post ID refers always to another post in the <code> posts </code> table, never to an user. To attach the file to a us...
Set attached to state
wordpress
I wonder if anyone could advise me further on my problem. Part of my plugin stores log files for debugging purposes. I have successfully displayed them in a (div#log) in my admin page using jquery and wp_localise_script. I have a button to delete these logs but I am unsure how to process this. I have a feeling that aja...
Ajax in WordPress works by sending an HTTP post to /wp-admin/admin-ajax.php (by default) that then fires the corresponding hook. So, you attach some jquery to an event triggered by your delete button, which then posts to admin-ajax.php, which has an action, say, delete_my_options(), which actually runs the php to delet...
Using jQuery to delete data stored in wp_options
wordpress
Im currently encountering a problem i display user wp favorites posts fine, but the issue is i wont display them, once users are logged out it says " no posts have been made" while each user has their own posts also once im logged in i can display my favorite posts in my profile but once i visit another profile it disp...
As I understand the plugin (I took just a short glimpse, to be honest) you have to specify a user ID for the <code> wpfp_get_users_favorites() </code> function. Otherwise the currently logged-in user's ID is taken. Here is everything in a single line: <code> wpfp_get_users_favorites($GLOBALS['bp']-&gt;displayed_user-&g...
Wp favorite posts get user favorites in profile using buddypress
wordpress
I want multiple loops on my homepage, however only the first loop shows up. My homepage looks like this: <code> &lt;?php /* Template Name: Home */ get_header(); ?&gt; &lt;!--Four Columns--&gt; &lt;hr&gt; &lt;div id="content" class="twelve columns"&gt; &lt;div class="post-box"&gt; &lt;?php get_template_part('loop', 'lan...
Because you used <code> query_posts </code> your <code> loop-land </code> template is clobbering the main query. query_posts </code> . In <code> loop-land </code> do this instead: <code> $land = new WP_Query($query_string . '&amp;caller_get_posts=1&amp;posts_per_page=9'); if($land-&gt;have_posts()) : while($land-&gt;ha...
Put multiple custom loops on same page
wordpress
I want to be able to change the list-style-type, for example: <code> list-style-type: circle; list-style-type: square; list-style-type: lower-roman; list-style-type: lower-alpha; ... </code> In the plugin directory for TinyMCE Advanced There is a screenshot that shows what appears to be a drop-down menu to do just that...
Go to Settings -> TinyMCE Advanced, and simply enable Advanced List Options.
TinyMCE Advanced list type drop-down
wordpress
I have a function which redirects user to certain page: <code> wp_redirect('http://address/page'); </code> Usually I would just use: <code> &lt;?php _e("&lt;!--:en--&gt;english permalink&lt;!--:--&gt;&lt;!--:de--&gt;german permalink&lt;!--:--&gt;"); ?&gt; </code> But this is specific situation and I can't use it this w...
Are we talking permalinks here or any URL? If any, create an <code> array( 'en' =&gt; 'en_url', 'de' =&gt; 'de_url' ); </code> and get the URL by accessing the array using <code> qtrans_getLanguage() </code> index. If you're translating internal permalink use the <code> qtrans_convertURL() </code> function.
qTranslate in functions.php
wordpress
I am trying to get all published posts titles by author id 2 most recent by post date for the last days. Here is my query: <code> "SELECT post_title FROM $wpdb-&gt;posts WHERE post_status = 'publish' AND post_author = 2 ORDER BY post_date DESC LIMIT 3 " </code> This displays most recent 3 posts instead posts of last 3 ...
You are asking for the last three posts ordered by post date, not for the posts from the last three days-- <code> ORDER BY post_date DESC LIMIT 3 </code> . <code> post_date </code> has a time component to it . It is not just marked with a date. Even so, that <code> LIMIT </code> would restrict the query to last three i...
wpdb query problem to access previous 3 days posts
wordpress
Is keeping <code> wp-admin/install.php </code> and <code> wp-admin/install-helper.php </code> a security leak on the newer versions of wordpress? By default file permission on those files are 644. If there is any leak, what kind of please?
No, there is no security risk. Both files do sanity checks before anything happens. If WordPress is already installed: <code> install-helper.php </code> returns just a blank page. <code> install.php </code> says WordPress is installed and you should log in: You can forbid access to both files with a simple rule in your...
Should I remove install.php and install-helper.php?
wordpress
I have created a meta box that allows users to add an additional name/id to their post. From what I can tell it is adding the meta information correctly because when I edit a post that has a custom name/ID it shows up in the input box by default as it should. So my issue is that I am trying to pull the custom ID/name a...
Make sure you include the third argument to <code> get_post_meta </code> , a Boolean that determines whether or not it returns a single item or an array of items. The default is false, which is an array, so set it to true: <code> &lt;?php $value = get_post_meta ($post_id, 'newtheme_section_id', true ); ?&gt; </code>
Trying to retrieve post meta
wordpress
(or add comma to all items but the last one...) Most of the information I have found relates to using a counter within a <code> foreach </code> loop. In this particular situation I am using Advanced Custom Fields and I am within a standard loop, not a <code> foreach </code> loop. I need to add a comma to the end of eac...
There is nothing 'standard' about a <code> while </code> loop and in this case it makes things harder, since you need a total count of all the items in loop in order to know if you are on the last item or not. It is not obvious how to get that total count with a function like <code> has_sub_field </code> but there is a...
Remove comma from last item output from loop
wordpress
I'm writing a custom post type plugin. Part of it I'm outputting to the template via shortcodes. But other parts need a custom post template, and I figured out how to use the template hierarchy for CPT's. But the custom template is in the theme, and I'm thinking the plugin should be self-contained, at least to start wi...
So what's the best practice here? I would say a combination of letting the theme handle it and providing a default with your plugin. You can use the <code> single_template </code> filter to switch out the template. In your callback, see if the theme provided a template for the post type, if it did, do nothing. <code> &...
Custom Post Type Plugin: Where Do I Put The Template?
wordpress
I am using custom meta box in wordpress post page. this box contains a custom Copy button. Now, I want to open a popup window on clicking 'copy' button. Also I need to show content of parent window in this popup.
Maybe you can open a thickbox with javascript. A example with check for the height and width of the thickbox. <code> &lt;script type="text/javascript"&gt; &lt;!-- var viewportwidth, viewportheight; if (typeof window.innerWidth != 'undefined' ) { viewportwidth = window.innerWidth-80, viewportheight = window.innerHeight-...
Wordpress Admin: open popup window on a custom button
wordpress
Can I list all files uploaded by users in Network sites? In Multisite each user can manage their files with their own blog but the Super admin can't monitor all the uploaded files...how can i do that?
You have to run through each blog and fetch the recent attachments with: <code> $args = array ( 'post_type' =&gt; 'attachment', 'numberposts' =&gt; 30 ); $attachments = get_posts( $args ); </code> Dashboard widgets are registered on <code> wp_network_dashboard_setup </code> in multi-site and <code> wp_dashboard_setup <...
Listing of all uploaded files in network sites
wordpress
Im running a specific wp_query to show the thumbnails in a slider of a specific category. <code> &lt;?php $the_query = new WP_Query ('showposts=2', 'category_name=Events'); ?&gt; </code> This doesnt appear to be working, am i missing array at the beginning somewhere <code> &lt;?php $the_query = new WP_Query array('show...
Use either: <code> $the_query = new WP_Query('posts_per_page=2&amp;category_name=events'); </code> or <code> $the_query = new WP_Query(array( 'posts_per_page' =&gt; 2, 'category_name' =&gt; 'events', // this is the category SLUG )); </code> // EDIT Please note that <code> category_name </code> actually is the category ...
creating wp query with posts with specific category
wordpress