question
stringlengths
0
34.8k
answer
stringlengths
0
28.3k
title
stringlengths
7
150
forum_tag
stringclasses
12 values
I hope someone will be able to help me with this, because it's starting to freak me out. Have been searching hours to find a way to put image paths in my stylesheet, but have not been able to. The path must not be absolute or "theme dependant". The only way I have been able to fix my issue, is to do add the following w...
Use a relative path in your stylesheet. If the CSS file is in <code> /style.css </code> : <code> #menu .menu-drop .menu-label { background: url(admin/images/drop1.png) no-repeat right; } </code>
images within style sheet
wordpress
Functions such as get_next_posts_link allow you to get the HTML link to the next page, with few parameters for change (label and max pages). I want to get the URL to the next page so I can add custom classes to the link.
Why build the link yourself, when you can just add the class to the result of <code> get_next_posts_link() </code> ? <code> add_filter('next_posts_link_attributes','example_add_next_link_class'); function example_add_next_link_class($attr) { return $attr . ' class="example-class"'; } </code> Now the link sent back by <...
How do I get the next page of posts link?
wordpress
I'm using a custom field to display images in a slider on each post, but when I update the post after having entered the HTML code in the custom field, the code disappears. I'm assuming that there is some kind of filter that removes HTML code from custom fields when a post is saved. Is there a way to circumvent that wi...
UPDATED ANSWER The correct function to use in context to WordPress and its intended API for this purpose is; <code> esc_textarea </code> Thus your code would reflect something like this; <code> &lt;textarea&gt;&lt;?php echo esc_textarea($images);?&gt;&lt;/textarea&gt; </code> Although <code> htmlspecialchars </code> an...
HTML code in Custom field
wordpress
I'm looking to insert data from another database into my posts, and thought of using shortcodes. An example post: <code> [imdb id="123" name] was born [imdb id="123" birthday] in [imdb id="123" birth_location]. </code> I'd like to cache the results, and not need to run the shortcode actions anymore once it's been retri...
Either way you're going to need to store the data you retrieve from an external database, in your WordPress database, if you don't want to continually run the same query on your external database each time the page is accessed. You can either store the data in your WordPress database using Custom Fields (post meta) usi...
Shortcode Strategy
wordpress
So far I've been handling some translations in Wordpress and tried to read the official gettext documentation but won't get the point of one maybe simple thing: What's the differences between those startings like __(, _e(, etc.? And even more: which others are there beside? Thanks in advance! Frank
<code> __ </code> (double underscore) is the base translate function. It translates a string and returns it as a string. <code> _e </code> does the same as <code> __ </code> , but echo's the result immediately. <code> _x </code> is the contextual translate function. It has a second option to provide context to people d...
What's the point on gettext syntax?
wordpress
I am trying to loop all the latest post from all the categories but it is displaying only a post from single category. Below is the code that I am using. <code> &lt;?php while (have_posts()) : the_post(); ?&gt; &lt;li &lt;?php post_class() ?&gt; id="post-&lt;?php the_ID(); ?&gt;"&gt; &lt;a class="wpn_title" href="&lt;?...
sorry guys, I was suppose to end query_posts with <code> &lt;?php wp_reset_query(); ?&gt; </code> . This solved the issue. Thanks
Display Latest Post from all Categories
wordpress
W3 Total Cache and CDN Sync Tool (w/ WP Super Cache) are two plugins that do a pretty good job of integrating various Content Delivery Networks (CDN's) — including Amazon S3 / CloudFront, CloudFiles, and MaxCDN (among others) — with WordPress. But I am looking for a plugin (free or paid) that integrates Google Storage ...
The WP2Cloud plugin now supports Google Cloud Storage (in addition to Amazon S3).
Plugin that integrates Google Storage with WordPress?
wordpress
I am using the following code: <code> $tolettpe = "Sale";//default if($_REQUEST['tolettype']) $tolettpe = $_REQUEST['tolettype']; else if($_REQUEST['srch_type']) $tolettpe = $_REQUEST['srch_type']; $args = array( 'numberposts' =&gt; $latestcount, 'category' =&gt; $catidstr, 'meta_key' =&gt; 'property_type', 'meta_compa...
<code> meta_compare </code> Possible values are <code> '!=', '&gt;', '&gt;=', '&lt;', or '&lt;=' </code> . Default value is <code> '=' </code> if you want to use <code> LIKE </code> you need to create a meta_query eg: <code> $tolettpe = "Sale";//default if($_REQUEST['tolettype']) $tolettpe = $_REQUEST['tolettype']; els...
get_posts with meta_compare='LIKE' not working
wordpress
I have a website www.mcruiseon.com. I have added .htaccess to get all www.mcruiseon.com to redirect to www.mcruiseon.com/wordpress. But the 'wordpress' still shows up on my html link on browser. Can I hide the fact that the website is hosted under a folder wordpress ?
If understood correctly, you'll have to follow this Codex instructions: Using a pre-existing subdirectory install . If you already have WordPress installed in its own folder (i.e. http://example.com/wordpress ) then the steps are as follows: If that's your case, you'll learn how to make WP work as if it were on the roo...
Hide a subdirectory on my website hosting
wordpress
How do I nest Next and Previous link in a href attribute that has a class and background image in a single post page? I want to make it something like the below which is not working. <code> &lt;a class="next" href="&lt;?php echo $prev; ?&gt;"&gt;Previous&lt;/a&gt; &lt;a class="prev" href="&lt;?php echo $next; ?&gt;"&gt...
EDIT In single.php you should be using: <code> &lt;?php previous_post_link('%link', 'Previous'); ?&gt; </code> and <code> &lt;?php next_post_link('%link', 'Next'); ?&gt; </code> . Then you add this to your functions.php: <code> function filter_next_post_link($link) { $link = str_replace("rel=", 'class="next" rel=', $li...
Nest Next and Previous in a href with class that has a background image
wordpress
i have done this many times but not via a form so i am getting a weird issues when trying to assign a "selected" based on the current post term id... Maybe the use of get_the_category and then get_categories creates a conflict? Any one has any idea as to why this might happen? No matter what the selected item is the la...
OMG - i falied to clean "$selected" value... hope this helps someone if you get confused for a moment like i did <code> &lt;?php $postId = $_POST['postid']; // the value is recieved properly $currentCategory = get_the_category($postId); // the value is recieved properly $currentCategoryId = $currentCategory[0]-&gt;term...
Compare current post Category in select menu
wordpress
We are building an Android app based on a Wordpress mysql database. We were able to get most of the information from the datase to display on to the app. Now all we have left is to retrieve the posts featured image. Is there a way to have the featured image output a URL? Thanks!
The featured image attachment id is stored in the post_meta table, with the meta_key <code> _thumbnail_id </code> . Use that post id to find the post meta with meta_key <code> _wp_attachment_metadata </code> . The value of that is a serialized array with keys <code> thumb </code> , <code> file </code> , <code> width </...
Retrieve featured image
wordpress
For example, i am building a cinema site.. For movies - I am using post - The movies are post there.. For actors - I am using post_type : persoane , Taxonomy : lista. How can i retrive the movies play by bruce willis in http://cinema.trancelevel.com/persoane/bruce-willis/ For example, i have : http://cinema.trancelevel...
I think there are multiple issues here: 1) Because you're using <code> query_posts() </code> the post object's query_vars are inherited by your new <code> query_posts() </code> . I suspect then, that <code> 'post_type' =&gt; 'persoane' </code> is implicitly part of that query posts call. If you switch to using WP_Query...
Retrive post by tags PHP code
wordpress
I am using Simply Exclude to make sure that certain categories do not show up on the home page and in the sites main feed, http://example.com/feed . However, excluding the category from the main feed also excludes posts from the category's feed, http://example.com/category/category-73/feed/ . How do I get it so that th...
It took me a while but I figured it out, I just placed this in mu functions.php file: <code> function remove_se_filters($query) { if($query-&gt;is_feed &amp;&amp; $query-&gt;is_category){ global $wp_filter; foreach($wp_filter['pre_get_posts'][999] as $key=&gt;$filter){ if(strpos($key, 'se_filters') !== false){ unset($w...
Simply Exclude - Category feed exclusion is excluding from category feed instead of just the main feed
wordpress
I would like to add a custom Meta Box with Html content in the screens New and Edit Posts/Pages ( <code> /wp-admin/post.php?post=POST_ID&amp;action=edit </code> ), so that I could display a list of editorial guidelines for my editors to follow. Or, even better, is there a plugin to do this so that I don't have to go in...
Don't know any plugin for that. But it can be solved stackexchange-url ("creating a custom plugin") with the Settings API and a Custom Meta Box . Adding a RichText Editor in the Settings Page <code> /wp-admin/options-general.php </code> <code> &lt;?php /* Plugin Name: Custom Editor in Settings Page */ add_action( 'admi...
How To Create a Meta Box with Html Content with Instructions to Site Editors When Editing a Post or Page?
wordpress
I think this happened when I upgraded to 3.4, or it might have happened more recently. The template drop down list is now missing most of my templates. Pages that were using the templates are still working but when I go to edit the page the drop down says 'Default template' and the template it is currently using is not...
There was a WordPress 3.4.1 update released a little over a week ago. One of the bugfixes mentioned is " <code> Fixes an issue where a theme’s page templates were sometimes not detected. </code> " Have you tried doing that upgrade yet?
Templates have disappeared from drop down lists
wordpress
In <code> wp-admin/includes/update-core.php </code> we find the following line: <code> add_action( '_core_updated_successfully', '_redirect_to_about_wordpress' ); </code> I want to remove this action, so I created a mu plugin with the following content: <code> &lt;?php # -*- coding: utf-8 -*- add_action( '_core_updated...
Don't remove the action but add your own before it. If you remove the action you will never get the message saying it was upgraded successfully. Here you can provide your own info on what to do next. <code> function tp_dont_redirect_to_about_wordpress( $new_version ) { global $wp_version, $pagenow, $action; if ( versio...
How to prevent redirect to 'About' after core upgrade?
wordpress
On a standard WordPress page, I have a <code> WP Query </code> that runs through a post type I created. Along with that query, I am using paginate_links() to generate pagination. While the standard (no permalinks) seems to work fine - when enabling any permalink combination, the subsequent pagination pages do not load....
The issue ended up being the page in which I was accessing the shortcode on was using the same slug - which WP was freaking out about. While I'll need to investigate why it would happen, was easy enough to fix.
paginate_links() on page (shortcode output)
wordpress
the thumbnail support is working for post, but I have another post type called product and it is not working for this. I am trying: <code> add_theme_support( 'post-thumbnails', array( 'post', 'product' ) ); </code> I am also using the multiple post thumbnail plugin.
By default all custom post adds support for Title and editor, if you want more stuff like comments, thumbnail and revisions you have to add it manually in the support argument. Read more about how to register your custom post type here, you can also find the section about support to see what you can add. Here is an exa...
How do you add thumbnail support for custom post types?
wordpress
I've been asked to make some fairly significant changes to our web site, but the site will overall have the same feel. I'm wondering if I should modify the current customized Genesis child theme, or if I should create a new child them. Any thoughts?
I do agree with Aaron's thoughts on "It all depends on the amount of changes required" . Still. I would use a slightly different work-flow. Meaning: Keep my original child theme (old-child) intact. Create a new folder and copy the whole old-child content in it making an exact replica. Do NOT refresh your themes screen ...
New Genesis child theme or revise current Genesis child theme
wordpress
I am new to wordpress and I just created a new blog(free version). Now It seems that code fromat doesn't work. All lines are aligned to the left. Please look at the image below. Thanks.
You need to wrap your code in either <code> code </code> or <code> pre </code> tags. <code> code </code> is for when inline code in a sentence e.g. <code> include("hello.php") </code> whereas <code> pre </code> is for preformatted blocks of text e.g.: <code> function hello_world(){ echo 'hello world'; } </code> For cod...
Wordpress blog code format
wordpress
I have multiple well-established Wordpress sites. I am considering combining them into one Wordpress MU site. I have found that a few of the sites probably do not get as much of my attention as they should. I think this may simply be because they are "out of sight, out of mind." I believe with all sites in one dashboar...
Manually I'm pretty sure I've seen this topic covered by stackexchange-url ("Ipstenu") and/or stackexchange-url ("Andrea") in Multisite support forum . But this demands a in-depth search in the un-friendly search functionality of WordPress.org. And if my memory serves me well, I think the solution is to invert the meth...
How to combine multiple sites to Wordpress MU
wordpress
I use the ALO EasyMail Newsletter. But the plugin is loading lots of Javascript in the head. I have a mobile site and the scripts are loading in all the pages. I think this affects the mobile performance and want to load it only on the newsletter pages. How can i do that and load it only in the <code> /nieuwsbrief </co...
Drop this in your <code> functions.php </code> or a custom plugin. <code> function wpse_57621_alo_tidy() { if ( $page_id = get_option( 'alo_em_subsc_page' ) ) { if ( ! is_page( $page_id ) ) remove_action( 'wp_head', 'alo_em_ajax_js' ); } } add_action( 'wp', 'wpse_57621_alo_tidy' ); </code> It's attached to the <code> w...
Load Javascript from Plugin in One Page Only?
wordpress
The official Facebook plugin does an excellent job of adding appropriate Open Graph meta tags to different pages (Home, Posts, Pages, Archives, etc.) of a WordPress site. The problem is it does many things without my permission. Is there a way to get the functions responsible for adding Open Graph meta data from the pl...
The <code> fb-open-graph.php </code> (latest version's file) right inside the extracted folder of the plugin is (solely) responsible for adding Open Graph meta data to the header of your site. Below is how I've modified the code in the file so that it's fit to be added to your theme's functions.php: <code> /* Facebook ...
Conditionally add apt. Open Graph meta data to different pages on WordPress site
wordpress
Without using a language file, which file would I go to if I wanted to rename profile tabs? For example, instead of the tab saying "Activity" I want it to say "My Activity". Instead of "Groups" I would make it say "My Groups" etc. Thanks
Look at the source, you know that already. :) I didn’t but I bet there is a piece of code looking like this: <code> _e( 'Activity', 'buddypress' ); </code> … or … <code> __( 'Activity', 'buddypress' ); </code> Follow the functions, they are wrappers for the function <code> translate() </code> in <code> wp-includes/l10n...
Rename Buddypress Profile Tab
wordpress
I created a custom post called projects and a taxonomy called tagportfolio , in the admin panel i created 3 tags under this taxonomy to filter my projects portfolio page the three tags is Urban planning and upgrading Urban Design and Landscape Architecture and Interior Design under each tag there is a posts , now i nee...
You're looking for WP_Query <code> echo '&lt;ul&gt;'; //The Arguments $args = array( 'post_type' =&gt; 'project', 'tagportfolio' =&gt; 'urban-design-and-landscape' //should use the slug name not the full name ); // The Query $the_query = new WP_Query( $args ); // The Loop while ( $the_query-&gt;have_posts() ) : $the_qu...
displaying posts from a custom post type tags
wordpress
Is it possible to allow zip files to be uploaded in Wordpress? I have the following code but it doesn't work. <code> function custom_upload_mimes($existing_mimes = array()) { // Add *.EPS files to Media upload $existing_mimes['eps'] = 'application/postscript'; // Add *.AI files to Media upload $existing_mimes['ai'] = '...
Here is a action that works on my site: <code> add_filter('upload_mimes', 'custom_upload_mimes'); function custom_upload_mimes ( $existing_mimes=array() ) { // add your extension to the mimes array as below $existing_mimes['zip'] = 'application/zip'; $existing_mimes['gz'] = 'application/x-gzip'; return $existing_mimes;...
Is it possible to allow zip files to be uploaded in Wordpress?
wordpress
In answering this question: stackexchange-url ("Change language by clicking a button"). It was necessary to obtain a list of languages for which translations were available (i.e. their po/mo files were present in <code> wp-content/languages </code> ). So how can you obtain that list? Clearly by 'available' we can only ...
You can get a list of available languages with <code> get_available_languages( $dir ) </code> . It returns an array with all <code> .mo </code> files where the names does not start with <code> 'continents-cities' </code> , <code> 'ms-' </code> or <code> admin- </code> . To get a readable name for the file use <code> fo...
Obtain a list of available translations
wordpress
I have a site specific plugin that I've written for the main site in my multisite network. Now I realize that the shortcodes that are in the plugin are also useful on the sub-sites, however the sub-sites don't need all the code for custom post types and taxonomies. How do I make just the shortcodes work for sub-sites? ...
<code> if ( is_main_site() ) { include_once CLICK_DIR . '/lib/functions/general.php'; include_once CLICK_DIR . '/lib/functions/post-types.php'; include_once CLICK_DIR . '/lib/functions/taxonomies.php'; } include_once CLICK_DIR . '/lib/functions/shortcodes.php'; </code>
How do I make specific plugin functionality apply to different sites in a network?
wordpress
I am changing the text on the login page using this filter: <code> function filter_register_text() { return "&lt;p class='message register'&gt;Registering for this site will give you access to the admin panel to add new products with images and useful files for others to download and choose open product licenses.&lt;/p...
I think your best bet is to check if the <code> action </code> parameter is set &amp; equal to <code> register </code> : <code> if ( isset( $_REQUEST['action'] ) &amp;&amp; $_REQUEST['action'] == 'register' ) add_filter( 'login_message', 'filter_register_text' ); </code>
How do we check if the user is logging in or registering?
wordpress
I have tried to change mode of .htaccess in wordpress folder to 644. Yet, I get <code> Not Found The requested URL /wordpress/features/ was not found on this server. </code> I keep reading about rearranging my .htaccess to get Permalinks working. Unable to understand. Here are the details of my .htaccess <code> # Comme...
Sounds like to that the Allow Override directive is still set to NONE for your VHOST By default this is disabled, so even if you enable mod_rewrite via <code> sudo a2enmod rewrite </code> your .htaccess will be ignored. You'll want to login to your server (via Terminal / shell) and then ... <code> sudo nano /etc/apache...
Permalinks to Custom does not work (out of box)
wordpress
Earlier, I asked stackexchange-url ("this question") and received a code which should work. Unfortunately, this code is not working. I'm building a themes option panel and want users to be able to choose between Next/Previous links or pagination in my archives and homepage. The code within <code> functions.php </code> ...
1) Move the function to the <code> functions.php </code> file, that's where it belongs. Put it at the end before any closing <code> ?&gt; </code> : <code> function my_theme_navigation() { global $shortname; if( get_option( $shortname . '_next_prev_or_paginate' ) == 'Next' ) : // the block for next-prev navigation previ...
Theme Option not Working Inside a Function
wordpress
Not sure how to ask this, because I'm not exactly sure what I'm asking. I'm looking to use custom URLs (using rewrite rules maybe?) to create 'tabs' for a Custom Post Type. In the past I've used things like a GET session variable to determine what tab the user is on, or JavaScript. I would really prefer to keep it on i...
Create an end point for the permalinks. stackexchange-url ("See example"). Then you can even be more granular and use <code> updates/2012 </code> , <code> updates/2013 </code> and so on. Recommended reading: Codex: <code> add_rewrite_endpoint() </code> A (Mostly) Complete Guide to the WordPress Rewrite API
How to create custom URLs for Custom Post Type sub sections?
wordpress
I've be looking to add a tag cloud under my post that only shows tags pertaining to the post. The tags shown should be in a tag cloud format; the post tags that have more post tagged with it will be displayed in a bigger font. I've tried adding the following code under my posts: <code> &lt;?php wp_tag_cloud( array( 'sm...
First you need to get all the assigned tag id:s by calling wp_get_post_tags because the include parameter in wp_tag_cloud only works with tags id, Not page id . So when you have all the id:s put them in the include parameter within the wp_tag_cloud like this: <code> &lt;?php // Get the assigned tag_id $tag_ids = wp_get...
How do I display a tag cloud under my post that only shows tags from that post?
wordpress
I get this PHP Warning when accessing my fresh WordPress 3.4.1 install (Norwegian language). Warning: fopen(URL_TO_MY_WORDPRESS_PAGE/wp-cron.php?doing_wp_cron=1341476616.7605190277099609375000): failed to open stream: Connection timed out in PATH_TO_MY_WP_FILES/wp-includes/class-http.php on line 923 This is of course w...
The answer is apparently YES, I should worry . After some research, I've found that the warning seems to be related to misconfigurations on the server that WordPress is hosted on (ie. a problem with my server, not WordPress). Common misconfigurations: Server doesn't have DNS, and so it can't figure out who "example.com...
PHP Warning on fresh install (Connection timed out)
wordpress
This is the code I use to display the 4 most recent posts under the category the current post belongs to (right below the current post): <code> &lt;?php if (is_single()) : ?&gt; &lt;?php $count = 0; $aahan_category = get_the_category(); $aahan_category = get_term_by( 'name', $aahan_category[0]-&gt;cat_name, 'category')...
You can use the <code> post__not_in </code> parameter of <code> WP_Query </code> to exclude an array of post IDs from the query. <code> get_the_category() </code> returns an array of term objects, so the <code> get_term_by </code> is redundant. Also <code> is_single() </code> will always be true in <code> content-singl...
Latest posts by category — how to exclude current post?
wordpress
Anybody could help me to make a category page only. Thank you.
You'll want to stick something like this in your theme's <code> category.php </code> file: <code> &lt;?php // fetch the categories with the parent being the current cat $sub_cats = get_terms('category', array( 'parent' =&gt; get_queried_object_id() )); if(!is_wp_error($sub_cats) &amp;&amp; $sub_cats) { foreach($sub_cat...
How to create category page
wordpress
I followed this tutorial to add a menu item to navigation menu to link to external site: http://www.natenewz.com/2009/10/07/hardlink-wordpress-navigation/ I copied the snippet of code to my theme's header.php I created a page with the name having the text that I want to appear in the navigation I added a custom field t...
Are you trying to navigate to an external page or redirect? (Also, bear in mind that was posted almost 3 years ago...in websites and technology in general, that's an eternity!) You could always just add a custom link to the WordPress menu under Appearance-> Menus. Just make sure you add support in the functions.php fil...
add a menu item to navigation menu to link to external url
wordpress
This is what I currently have but its not rendering any results... It was the closest conditional I could think of using to match what Im trying to output but it didnt seem to work. Any ideas?... NOTE: The taxonomy terms that I am listing in the sidebar need to be visible at all times while viewing custom post type que...
<code> is_tax() </code> returns true on a taxonomy archive page, it has nothing to do with whether terms exist in a taxonomy. you just need to add a check for anything returned from <code> wp_list_categories </code> before outputting any markup: <code> &lt;?php $args_list = array( 'taxonomy' =&gt; 'productcategory', 't...
Proper WP conditional tag to check for existing taxonomies to list out terms with wp_list_categories?
wordpress
I'm hoping that I can explain what I'm going for here. On my current project's main page, I'm displaying each post's Featured Image Thumb, along with an excerpt of the post's content. In each of the actual post pages, there is a default WP gallery with 2 to 4 images inside. What I want to do, is make it so that my clie...
Can't recommend Get the Image plugin (by Justin Tadlock) enough. It's among the best out there, very well maintained and neat code — more importantly, it does what you need, while giving you a whole slew of options. How does it pull images? Looks for an image by custom field (one of your choosing). If no image is added...
Display Post Thumbnail Without Being Featured Image
wordpress
I am using custom taxonomies. How to check if current page has <code> tag_ID = "XXX" </code> ? If that is any help the URL form WordPress admin looks like this: <code> http://localhost/website/wp-admin/edit-tags.php?action=edit&amp;taxonomy=company&amp;ta‌g_ID=13&amp;post_type=news </code> Update. Here is code which I'...
All the tags is inside the query, it is possible to check for this via get_query_var(); all objects inside the query. For the tag ID ask with this code: <code> get_query_var( 'tag_ID' ); </code> Also it is possible to check for tags, like <code> get_query_var( 'term' ) </code> and the taxonomy <code> get_query_var( 'ta...
Check if current page has given tag ID
wordpress
If i have pages that point to <code> somefilename.php </code> and want to change the filename to <code> betterfilename.php </code> , can I leave the template comments unchanged without manually changing all the pages? <code> /* Template Name: Some File Name */ </code>
Chris gave me some good insight, and I appreciate the filter func. But I wound up changing the db through phpMyAdmin: <code> UPDATE wp_postmeta SET meta_value = 'new-filename.php' WHERE meta_value = 'old-filename.php'; </code>
How to Rename a Template File?
wordpress
I want to create a custom taxonomy which behaves similar to the post type as a category behaves to a the default posts (on the grounds of /%category%/%postname%/ permalink structure) so that the posts in the custom post types are displayed as www.example.com/custom-post-type/custom-taxonomy-name/post-name Also I want t...
First of all if you want to show taxonomy metabox only to custom post type then register the taxonomy to only that custom post type by passing the custom post type name as argument in register_taxonomy. By doing this the taxonomy metabox appears only to custom post type. If your don't want to show category metabox to c...
Custom Taxonomy specific to a Custom Post type
wordpress
Recently i updated my <code> wordpress </code> to its latest <code> version 3.4.1 </code> and noticed that few of my plugins are only compatible upto 3.3 although they are working correctly for my site even with the latest version. So does that means that i need to disable those plugins and look for the alternatives an...
The compatibility shows just the latest version the plugin was tested on. If WordPress didn’t change the API the plugin will continue working and you don’t have to worry. stackexchange-url ("Test it.") There is no other way to be sure.
Wordpress plugin compatibility explaination when wordpress releases its new version (theoretical)
wordpress
After checking out: http://codex.wordpress.org/Function_Reference/remove_menu_page, I successfully use the following code to hide some stuff from the menu: <code> add_action( 'admin_menu', 'my_remove_menu_pages' ); function my_remove_menu_pages() { remove_menu_page('link-manager.php'); remove_menu_page('tools.php'); re...
Doing this stackexchange-url ("search"), I've found stackexchange-url ("this fine answer") by Chris_O. There's even a jQuery solution I proposed there. Anyway, the function <code> remove_menu_page('edit.php'); </code> only removes the Posts menu. But, as we learn from Chris answer, <code> remove_menu_page('edit.php?pos...
Remove "posts" from admin but show a custom post
wordpress
i'm looking for the action/hook called when saving theme customs colors in the new admin interface? i need to call a custom function to save a set of php generated images. if anyone have clues... :) thanks
The settings are saved via ajax, with the action <code> customize_save </code> . In the <code> wp-includes/class-wp-customize-manager.php </code> class, the callback for this ajax method is the <code> save </code> method ( see source ) This triggers the <code> customize_save </code> action, prior to updating each of th...
WP 3.4 - what action/hook is called when theme customisation is saved?
wordpress
I am woefully late to the party on Custom Post Types and only started using them quite recently, so apologies if my questions seems idiotic, but I can't seem to find an answer to my question. I've set up a custom post type called actors with a couple of custom field values, and (crucially), I'm using standard categorie...
You can force use of your template for categories with the <code> category_template </code> filter: <code> function wpa57439_category_template( $templates = '' ){ if( !is_array( $templates ) &amp;&amp; !empty( $templates ) ) { $templates = locate_template( array( 'archive-actors.php', $templates ), false ); } elseif( e...
Displaying category archive of custom post types
wordpress
This is the code in my searchform.php: <code> &lt;div class="search-box"&gt; &lt;form method="get" class="searchform" action="&lt;?php echo esc_url( home_url( '/' ) ); ?&gt;"&gt; &lt;label for="s" class="assistive-text"&gt;&lt;?php _e( 'Search', 'reddle' ); ?&gt;&lt;/label&gt; &lt;div class="search-input-holder"&gt; &l...
Do not hard code a value in the search field. You will get a lot of nonsense searches because people do not expect that they have to clean up the field before they can actually type something into it. They will just type and hit enter. Alternatives: Use the <code> placeholder </code> attribute. You can stackexchange-ur...
Set default text for the_search_query();
wordpress
Just playing around with <code> Wordpress / Contact Form 7 </code> . Is it possible / do you know how to add custom javascript function on successful email send event ?
simply add you JavaScript function to your page then find the Additional Settings field at the bottom of the contact form management page and use the <code> on_sent_ok </code> JavaScript action hook like so: <code> on_sent_ok: "MY_JavaScript_function_Name();" </code>
Contact Form 7 - add custom function on email send
wordpress
I am creating a WebHosting site using WordPress. It needs a custom feature selection module to add remove amountof disk space etc. In this particular website that I like 1) , there is a custom "instance selection"-module that adds ram space etc. the site is WordPress powered. Is there any plugin or script to get the sa...
The Site you linked is not using Ajax to update its simply a custom designed <code> jQuery UI Slider </code> and if you look at the source of the page more specifically at the included <code> server-order.js </code> you can see that all of the prices are set in an array and there is no Ajax going on there simply JavaSc...
Any plugin or Script to integrate ajax selection module into WordPress page
wordpress
I think I'm nearly there with this, but I can't get the pagination links to show for a directory of authors I'm creating. My code is below, but I don't know how to get the links to navigate between pages of authors to work. Can anyone help me? I've got the feeling this might be of use, but I don't know how to implement...
This should get you really close. I haven't tested it, but it's nearly identical to a setup I've used a few times. <code> /* * We start by doing a query to retrieve all users * We need a total user count so that we can calculate how many pages there are */ $count_args = array( 'role' =&gt; 'Subscriber', 'fields' =&gt; ...
How to display pagination links for WP_User_Query?
wordpress
If I have built a site using an existing theme (i.e. "Twenty-Ten"), but then modified it considerably and want to re-name it entirely, how would I go about doing this without breaking all the links? I know I can simply text-edit the style.css to change the name there, but I'm referring to the root all throughout the in...
You should never use <code> &lt;link&gt; </code> tags for stylesheets. Always use the proper API functions: Better practice Example: <code> function wpse57423_register_stylesheets() { wp_enqueue_style( 'themes_main_stylesheet' get_stylesheet_directory_uri()."/style.css" array() // Use this array if you've deps that nee...
Change the name of the root name of an already built Wordpress theme
wordpress
I'm currently trying to set up some filters for a custom post type within my admin. The custom post type is 'players' and I'm filtering them by another custom post type 'teams'. To create my dropdown list of teams I use get_posts to retrieve all my teams: <code> $args = array( 'numberposts' =&gt; -1, 'post_type'=&gt; '...
That's because <code> esf_admin_posts_filter() </code> will apply itself to your query inside <code> esf_get_teams() </code> too! Adding <code> $query-&gt;is_main_query() </code> to the <code> if </code> conditions inside your filter should prevent this.
get_query stops working after post filter
wordpress
I want to create a custom field, let's say Tickets in which I can store different links for each post. For example: On a post page I have a button called "Buy ticket" which has a specific link, also on another post I have the same "Buy ticket" but with another link and so on ... How can I make this ? Thanks
Lets go with an example... Custom Field Name: <code> buy-ticket </code> Custom Field Value: <code> http://example.com/link-to-ticket/ </code> And you said, you want a button called "Buy ticket" linking to the Custom Field Value. This how you do it: <code> &lt;a href="&lt;?php echo get_post_meta($post-&gt;ID, 'buy-ticke...
custom field with links
wordpress
I want to display the links to all posts of the same category of the current post on that page. I wrote the following code in the single.php file. <code> &lt;?php $categories_of_this_post = get_the_category(); ?&gt; &lt;?php $fist_category_id = $categories_of_this_post['0']-&gt;term_id; ?&gt; &lt;?php $this_post_ID = g...
I've not tested this, but the following is the method you shoulduse. query_posts </code> . <code> $cats_of_post= get_the_category(); if($cats_of_post){ $cat_id = (int) $cats_of_post['0']-&gt;term_id; $related = get_posts(array( 'numberposts' =&gt; 5, 'category' =&gt; $cat_id, 'orderby' =&gt; 'post_date', 'order' =&gt; ...
Displaying links to all posts of the same category on the post page
wordpress
I am using advanced custom fields repeater-field to get the image url like this: <code> &lt;?php the_sub_field('billede'); ?&gt; </code> But I also want to get the attachment ID for the image, to be used for something else. Is this possible? :)
The simplest way to do this is to change your field to return attachment ID instead of URL, and then when you need the URL, use <code> wp_get_attachment_image_src </code> with the ID. The only method I'm aware of to get ID from URL is with a custom SQL query.
How to get both image attachment ID and url
wordpress
I only want one of these shortcodes to display if the custom field value is true. I'm not understanding the logic to do this. So basically, if there is a twitch video and a own3d video I only want the top video (twitch) to display. So on and so forth. Is this beyond the if else statement? I'm adding this code of course...
This is rather a simple PHP question and almost off topic. You can simplify your code drastically: <code> $metas = array ( 'twitch', 'own3d', 'livestream', 'ustream', 'justin' ); foreach ( $metas as $meta ) { $value = get_post_meta( $post-&gt;ID, $meta, TRUE ); if ( $value ) { echo do_shortcode("[livestream type='$meta...
If else with shortcodes
wordpress
I am looking to add content before the post title but not included in the markup of the title itself so adding to <code> the_title </code> doesn't seem to be the right hook for this. Thanks
No, there is no reliable hook. The markup is provided by the theme, and there unlimited variants. You will have to change the theme’s markup directly.
Is there an action_filter hook to add content before the post title?
wordpress
I have a client site that has requested a custom comment format for posts of a specific category. In my loop template, I have this: <code> &lt;div id="gallery-commentlist"&gt; &lt;ul class="gallery-commentlist"&gt; &lt;?php wp_list_comments( 'type=comment&amp;callback=gallery_comment'); ?&gt; &lt;/ul&gt; &lt;/div&gt;&l...
There is apparently some sort of query call that takes place as part of the <code> comments_template() </code> call, just as there is with loop calls. When I put my custom function in the comments template, it works perfectly. I tried putting the entire contents of the comments template into my custom loop-single templ...
WP Custom Comment Callback Not Responding
wordpress
I have been trying to achieve that and I did without the 1 login part I fallowed this post/tutorial , but no matter what I do I can not get it to login ones for both websites. My set up is <code> sitename.com/wordpress1/ </code> and <code> sitename.com/wordpress2/ </code> (in this one I have <code> BuddyPress </code> i...
Install wordpress at sitename.com Setup multisite Create a new site at /wordpress1/ Create a new site at /wordpress2/ Install Buddypress plugin Activate buddypress on /wordpress2/ ( not network wide, just wordpress2 ) Hey presto you have exactly what you want without the nightmarish usertable situation Problems you wil...
2 wordpress blogs with 1 users table and 1 login
wordpress
My custom plugin creates a custom post type, and I want to theme my own <code> "single-my_custom_cpt.php" </code> file. However, I want to store it in my plugin folder, and allow that it be over-written in the websites' active theme folder. For example, single-my_custom_cpt.php exists in <code> /plugins/my-plugin/ </co...
To provide a default template that can be overwritten by a theme hook into <code> template_include </code> like the linked questions suggest. You get the template WordPress wants to use as a parameter. If that is not the file you want – replace it with your plugin’s file: <code> add_filter( 'template_include', 'wpse_57...
How to set a fall back template for a custom post type in a plugin?
wordpress
I am developing a site that I want to hand over to a client once complete. The core page 'content' is manageable, but there are elements of content (common headings, titles etc.) that are shared across multiple pages &amp; sections within the site, and I would like to give the client a single 'admin page' where they ca...
You should build a theme settings page for all the "global" settings like social media url:s, phone number etc.. It could be something like this: Here is a guide how to make a Settings page: How to build a theme options page. Or you can make a settings page with the new Customizer that comes with WordPress 3.4 so you c...
Where can I store common cross-site text (e.g. headings, titles etc.)
wordpress
I'm trying to send an email only upon saving a post as a draft, this doesn't seem to work with the current code: add_action( 'save_post', 'er_send_email_on_post_draft_save' ); function er_send_email_on_post_draft_save( $post_id ) { //verify post is not a revision if ( $post_id-> post_status == 'draft' ) { $post_title =...
<code> $post_id </code> is an integer (just the post id) and not a post object (the whole post with id,status,title ...) so globalize the <code> $post </code> object and check the status from there eg: <code> function er_send_email_on_post_draft_save( $post_id ) { global $post; //verify post is not a revision if ( $pos...
Send email only upon draft
wordpress
I would like to have a metabox for the user to be able to select from a dropdown list one page from the website. I need to save the user choice, so I can use it later. So, my question is how can I create a metabox that will list all my pages?
You can use <code> wp_dropdown_pages </code> . For example <code> add_action( 'add_meta_boxes', 'myplugin_add_custom_box' ); /* Adds a box to the main column on the Post edit screens */ function myplugin_add_custom_box() { add_meta_box( 'myplugin_sectionid', __( 'My Post Section Title', 'myplugin_textdomain' ), 'myplug...
How to create a metabox that will list all my pages in a dropdown selector?
wordpress
So I've created a little jquery cycle based feature rotator that pulls from the post_tags. I added the post tags to my other custom post types like this: <code> register_taxonomy_for_object_type('post_tag', 'reviews'); register_taxonomy_for_object_type('post_tag', 'interviews'); //... </code> When I add a 'featured' ta...
Take a careful look at the arguments for <code> WP_Query </code> . By default, it queries for the post type <code> post </code> . To select your custom post types, you need to change your query a little: <code> $query = new WP_Query( array( 'post_type' =&gt; array( 'reviews', 'interviews' ), 'post_tag' =&gt; 'featured'...
Why does querying on post_tags (which has been applied to custom post types) only return posts?
wordpress
I'm using the approach of having all of my single-views in one <code> loop-single.php </code> and thus have a simple switch statement that will render each single-view based on the post type: <code> switch($post-&gt;post_type) { do_action('basey_loop_single'); default: ?&gt; &lt;?php echo apply_filters('basey_page_titl...
Not quite sure what you're after - something like this? <code> &lt;?php echo apply_filters( 'basey_page_title_news', __( '&lt;h1&gt;News&lt;/h1&gt;', 'basey' ) ) ?&gt; &lt;?php while ( have_posts() ) : the_post(); switch ( true ) : case has_action( "basey_loop_single_$post-&gt;post_type" ) : do_action( "basey_loop_sing...
add_action() in switch statement
wordpress
stackexchange-url ("This question") is almost what Im trying to achieve. Create a filter for posts based on a custom field. My custom field is a date and I would like to create a date filter (monthly) based on this custom field for the post listing admin screen. I'm not using the normal date as this is an historical we...
Add a query variable to store the month So first of all it'll be necessary to create a custom query variable - this will store the month we're after (in 2012/6) format. I'll call it <code> custom_month </code> , but its best practise to prefix it to avoid clashes with other plug-ins: <code> add_filter('query_vars', 'wp...
Filter post listing by meta value which is a date
wordpress
I have a site that uses a custom query to search for posts by country. The search results come back fine, but the pagination at the bottom reflects the total number of posts in the site, instead of the total number of posts in the search results. The plug in that manages this uses global $wp_query to determine the numb...
Firstly, I'd seriously consider opting for another plugin (it hasn't been maintained in over 2 years ), or making use of WP's built-in <code> paginate_links </code> . But, in the quest to provide a solution, give this a go: <code> function wp_page_numbers_custom( $wp_query, $start = '', $end = '' ) { $_backup = array( ...
Replacing global wp_query
wordpress
How do i add the current post/page title in a post query? I've tried this, doesn't work: <code> query_posts( 'posts_per_page=10category_name=&amp;' . $post-&gt;post_title); if (have_posts()) : while (have_posts()) : the_post(); </code>
Your original code has a typo - the ampersand is used to separate arguments, so it should be: <code> 'posts_per_page=10&amp;category_name=' . $post-&gt;post_title </code> However, since this is a new query in addition to the default, a new instance of WP_Query should be used instead of <code> query_posts </code> : <cod...
Page title in post query
wordpress
I have the following code : <code> global $wp; $wp-&gt;add_query_var('akey'); $wp-&gt;add_query_var('sort'); $wp-&gt;add_query_var('paged'); add_rewrite_rule('^activate/([^/]*)/?','index.php?pagename=activate&amp;akey=$matches[1]','top'); add_rewrite_rule('^users/$','index.php?pagename=users','top'); add_rewrite_rule('...
Your regex is a little flaky - you shouldn't specify the start anchor <code> ^ </code> , and some support trailing slashes, others don't - plus I'd opt for a better expression for matching page numbers. And you could certainly trim it down to: <code> add_rewrite_rule( 'activate/([^/]*)/?$', 'index.php?pagename=activate...
wp_rewrite not working on third level url
wordpress
How do I check and see if a value is set in an Advanced Custom Field?
You can see in the docs that you get the values by get_field so do something like this: <code> $values = get_field('field_name'); if($values) { echo 'A value is set'; } else { echo 'A value is not set'; } </code> Change field_name to your wanted field.
Advanced Custom Fields: how do I check to see if a value is set in an field?
wordpress
Is there a way to make an ajax slideshow like this ? Each slide contains an image and description and is loaded via ajax call. I suppose an easy way for an author to make up such slideshow post is to use the following shortcode markup: <code> [slideshow] [slide1] &lt;img src="photo1.jpg"/&gt; &lt;p&gt;desc 1&lt;/p&gt; ...
OK, this turned out to be really simple, flexible and awesome. Your single.php: <code> &lt;div class="post-body"&gt; &lt;?php the_content(); ?&gt; &lt;div class="post-pagination"&gt; &lt;?php wp_link_pages('before=&lt;p&gt;&amp;after=&lt;/p&gt;&amp;next_or_number=number&amp;pagelink= %'); ?&gt; &lt;/div&gt; &lt;/div&gt...
Ajax Slideshow in Post
wordpress
In my site I have a blog where each posts loads single.php like normal wordpress installation. I also have a "shop" custom page where each links also loads single.php but the permalink is different. For normal blog post the permalink goes like this: <code> http://www.mysite.net/2012/07/02/blah-blah-blah/ </code> For cu...
This should help, if you need more info: http://codex.wordpress.org/Template_Hierarchy Simply put, Wordpress looks for template files in the following order for single posts: <code> single-{post_type}.php </code> , <code> single.php </code> , <code> index.php </code> . If you want to override the standard <code> single...
Custom seperate Single.php
wordpress
Thanks for taking the time to check this out. I know it's outdated, but I'm using Wordpress 3.2.1. I have a Custom Home Page - where I created a Page for it and titled it as my Home Page with the custom URL. I was hoping someone on here will know how to target the Custom page (whether by PHP, Javascript, etc), so that ...
Rather than adding a class, just add a second selector to your <code> .current_menu_item </code> style of <code> .home .menu-item-225 </code> . Not ideal, but for a single case, I think it's completely appropriate. (This assumes that you're using <code> body_class() </code> on your <code> &lt;body&gt; </code> element, ...
if is_home(), change class of menu-item-225 of wp_nav_menu
wordpress
I'm worried about too many files created when adding a new image size. All uploaded files will generate the new size, I need a specific image size only for the file set as Fetured image, is there some way to do this? . The thumbnail , medium , etc are ok, but there is no need to create the new size for every file. I th...
Research The question stackexchange-url ("Filter For Featured Image") lead to this answer: stackexchange-url ("How to hook update_post_meta and delete_post_meta?"). Coupled with the a fine global variable ( <code> $_wp_additional_image_sizes </code> ) revealed here: stackexchange-url ("How to get a list of all the poss...
New image size version only for the Featured Image file
wordpress
Is there an easy way of obtaining every registered taxonomy and for each registered taxonomy, get all the terms for that taxonomy, and for each term, get the post count, without actually fetching all of the post data? I would assume it is most definitely possible. I would also assume it requires some massively long dat...
You can do this with just <code> get_terms </code> - this allows you to fetch all (or some) of the terms from one (or more) taxonomies. By default it excludes 'empty' terms, so you'll need to set the arguments appropriately. <code> //Array of taxonomies to get terms for $taxonomies = array('category','post_tags','my-ta...
How to Get All Taxonomies AND All Terms For Each Taxonomy With Post Count Zero
wordpress
I have another post type which isn't the default one. I have four taxonomies attached to that post type. And I have many tags attached to these taxonomies. I would like to create a drop down menu that pull automatically all the tags by their taxonomy. For example: Post type: Culture Taxonomy 1: Books Under that, all th...
<code> wp_list_categories </code> is what you're after. It takes <code> taxonomy </code> as an optional argument. Example taken from Codex: <code> &lt;?php $taxonomy = 'genre'; $orderby = 'name'; $show_count = 0; // 1 for yes, 0 for no $pad_counts = 0; // 1 for yes, 0 for no $hierarchical = 1; // 1 for yes, 0 for no $t...
How can I create an automatic drop down menu with my tags?
wordpress
By using a plugin called "Custom Content Type Manager" , I have implemented in my blog a simple Custom Post Type called "game review" which is simple a post, plus some extra fields which represents the rating of the game for graphics, sound, etc... However, I could not find a plugin which helps in rendering/displaying ...
+1 to putting your post types in a dedicated plugin What you'll want is to do something like what BBPress and Buddypress are doing. In BBPress, default templates are provided. If the theme provides none, the defaults are used. All the themer has to do is add <code> add_theme_support( 'bbpress' ); </code>
Rendering Custom Post Types independently of the theme in use
wordpress
I have found discussions and solutions on hiding or removing the lately introduced Welcome screen . But we DO find the screen, as a whole, very useful and an excellent addition. So, what we are looking for is quite different. We just want to change parts of it on a multisite/subfolders network . To be exact. The wp log...
Whenever we find ourselves in the situation " there must be a way to overcome this hard-code ", jQuery comes to rescue... The Result The Code The following code must be pasted at the end of the active Theme <code> functions.php </code> file. Or it can be used in a stackexchange-url ("custom plugin"), which will make th...
How can we customize the logo and some text on the welcome screen?
wordpress
I have a set of custom theme settings in my functions.php file. In order to arrange some things I want to load jquery ONLY to my functions.php file. What I read in wordpress is this: If it was needed within the admin, you could use the admin_enqueue_scripts action instead, however this enqueues it on ALL admin pages, w...
<code> add_options_page </code> returns the same value as <code> add_submenu_page </code> and can be used in exactly the same way as the code you posted. This will load your scripts only on that page. You can also request the global <code> $pagenow </code> variable if you'd rather do it that way.
Load jquery only for certain pages in the backend
wordpress
I've seen various tutorials on how to modify the menu items of a Wordpress Site's admin, but I'm trying to find a tutorial or way on how to modify the actual admin page labels. Here's what I mean: When you are in the back end and you hover over SETTINGS, and click GENERAL, a page comes up with, of course, the general s...
You can modify the labels using <code> gettext </code> filter hook ex: <code> add_filter( 'gettext', 'theme_change_label_names'); function theme_change_label_names($translated_text){ if (is_admin()){ switch ( $translated_text ) { case 'Site Title' : $translated_text = __( 'New Site Title label', 'theme_text_domain' ); ...
How to change the label text in default setting pages?
wordpress
Example :- 10 users and 2 admin in a site. If the post is published by admins than <code> &lt;?php ?????() { ?&gt; &lt;!-- do this --&gt; &lt;?php } else { ?&gt; &lt;!-- do this if posted by user --&gt; &lt;?php } ?&gt; </code>
This could be simple as: <code> global $post; if ( user_can( $post-&gt;post_author, 'manage_options' )){ // this is an admin } else { // this is not } </code> Assuming the only admins on your site can manage options.
How to check if post/page or taxonomy post is published by admin
wordpress
I have a WP multisite installation with a large number of sites. Thanks to stackexchange-url ("auto-approving comments from registered users") and invite only registration we no longer need to receive email notifications for comments pending moderation. This is good and intended behaviour, but it has introduced a furth...
I haven't tried it. but this plugin looks like it satisfies your alternative option http://wordpress.org/extend/plugins/mu-manage-comments-plugin/ Conveniently shows a list of blogs with spam or unmoderated comments so that the Network Administrator can manage the the comments on network blogs. The list shows counts by...
How can I manage all multisite pending comments in one place?
wordpress
I would like to do the following: I have a index.php file in which I query all posts from the existing post_types. Like the code below. <code> &lt;?php if (is_home()); { ?&gt; &lt;?php global $wp_query; query_posts( array('post_type' =&gt; array( 'movies', 'music', 'featured' ),'showposts' =&gt; 10, 'paged'=&gt;$paged ...
This is because <code> query_posts </code> replaces the original query with a new one (which includes all the listed post types). For stackexchange-url ("other reasons"), you should not use <code> query_posts </code> ! For your purposes you can use the <code> pre_get_posts </code> hook. This is fired before the databas...
show posts only on homepage but using custom post type and taxonomy for query posts via url
wordpress
I am just about finished creating custom columns through the WordPress admin panel. The custom post type I am using is called "slides". I figured out how to add the column titles and all of the column content (because they're WordPress defaults)...what I am missing is how do I add content to the "thumbnail" column? Som...
Chris, I modified the following (and the code is working!): http://pastebin.com/HZWgHrZf . I got it here: http://justintadlock.com/archives/2011/06/27/custom-columns-for-custom-post-types For every column you simply add another case :) Thanks, Josh
Custom Columns WordPress Admin
wordpress
I needed to pass an image to a Pinterest plugin in posts without a Featured Image so I wrote a little function to get the id of the first picture in a post. This code is in the <code> loop-single.php </code> where the sharing buttons are located. <code> if ( has_post_thumbnail()) { $thumb_for_pinterest = wp_get_attachm...
<code> get_children </code> will return an associative array of posts [...] with post IDs as array keys , or an empty array if no posts are found. This statement <code> $attachment_id =&gt; $attachment </code> is the same as the more commonly used <code> $key =&gt; $value </code> . Using this command <code> echo '&lt;p...
Why use foreach to get attachment_id if numberposts is equal to 1?
wordpress
I launched mysql and confirmed this query returns a result: <code> mysql&gt; SELECT * FROM wp_posts WHERE post_parent = 68 AND post_type = 'attachment' AND post_name = 'side-logo-auto2' LIMIT 1; 1 row in set (0.00 sec) </code> In my template, I attempt same thing: <code> &lt;?php if ( have_posts() ) : while ( have_post...
<code> $wpdb-&gt;get_var </code> returns a single variable, but your SQL statement has <code> SELECT * </code> which returns a row of multiple columns. You need to change your SQL statement to <code> SELECT ID ... </code> instead of <code> SELECT * ... </code>
$wpdb-> get_var not returning a result
wordpress
I want to translate this plugin. This plugin already has translations to some languages, and it has .pot file for adding new languages (as far as I understood from description). Although I never had an experience to work with .po .mo So I wonder what are the main points. How to create .po .mo files and how to define th...
The Editor There are others, but this is most used: Poedit, a cross-platform gettext catalogs (.po files) editor. The Formats <code> .mo </code> stands for Machine Object -- compiled export of the <code> .po </code> file which is used by WordPress <code> .po </code> stands for Portable Object -- editable text file with...
How to translate a plugin via .po .mo?
wordpress
I have a custom taxonomy that is pulling in a list of posts assosciated with it. Previously - in the <code> $posts_args </code> array, I set the <code> post_per_page </code> option to <code> -1 </code> but realized pagination should be added to do the large amount of media that will be present with each post. I read ov...
Looks like I was missing <code> 'paged' =&gt; get_query_var('paged') </code> in the initial query.
paginate_links() with Custom Taxonomy
wordpress
Is it possible to make a theme with an option of configuring social icons with links through the custom header control panel? I googled it and found nothing that could help me, any help on that topic will be very appreciated UPDATE What I'm trying to achieve is that in the theme control panel (preferably inside the <co...
I did something similar on my site a while back. I'm sure you can tweak it to fit your needs. Under each article I have an author box with social media icons that link to their accounts. In content-single.php <code> &lt;?php if ( get_the_author_meta('twitter') ) : ?&gt; &lt;a href="http://www.twitter.com/&lt;?php the_a...
Add social icons in a theme through custom admin menu
wordpress
How do I get a custom post by its ID? I want to display a single post from custom post using its ID. I tried <code> 'post_type' =&gt; 'homepage', 'post_id' =&gt; '717' </code> but it didnt work. Thanks
You simply don't need to specify a <code> post_type </code> when calling <code> get_post() </code> . The <code> ID </code> for any sort of post is unique among the whole DB-posts table. So if you're calling a post with ID = 17 <code> $id = 17; $post = get_post( $id ); </code> then you'll simply get this single post. No...
Get Custom post with ID
wordpress
I load 10 posts on my home.php and I have the 'posts_nav_link()' function to acces to latest entries. But when I click on the previous entries, the link redirect me to mysite.com/page/2 and give me a 404 error. Could you help me please Thanks ? <code> &lt;?php if (have_posts()) : query_posts( array( 'post_type' =&gt; a...
Never use <code> query_posts() </code> :). See stackexchange-url ("this answer") for more detailed explanation of why not, and the alternatives. In this instance, remove your <code> query_posts() </code> and instead in a plug-in, (or functions php). <code> add_action('pre_get_posts','wpse57229_change_query_for_main_pag...
Page/2 posts don't load and give 404
wordpress
I'm using this code for a dropdown of categories. On selection of the dropdown the desired category is displayed using the archive template. I cannot for the love of me get the template hierarchy to work. <code> &lt;form&gt; &lt;select name="tag-dropdown" onchange="document.location.href=this.options[this.selectedIndex...
From codex - you should be able to use <code> taxonomy-service-category.php </code> template to display <code> service-category </code> posts.
Archive custom template from search
wordpress
I´m trying to set up a local development environment for me to work on a Wordpress multisite that I´m building. I use Mamp Pro with default ports (Apache: 80, MySQL: 3306), and I also added a new host with the same domain name as the page will have when going live. So, now when I go to http://mylivedomain.com I get to ...
Appart of the default ports and correctly configuring WPMS... In the Advanced Tab: And manually add the subdomains in <code> /etc/hosts </code> 1 file: <code> # BRASOFILO MULTISITE START 127.0.0.1 test1.brasofilo.dev 127.0.0.1 test2.brasofilo.dev 127.0.0.1 cloned.brasofilo.dev # BRASOFILO MULTISITE STOP </code> 1 The f...
WP Multisite development with Mamp Pro and wildcard subdomains, not really working for me
wordpress
I just started working locally with Wordpress. Trying to update theme/plugins I get asked for my FTP credentials and I get really confused...what the heck is my FTP credentials when working locally?
Set file permissions On Mac OS X (Leopard), the Apache HTTP Server runs under the user account, _www which belongs to the group _www. To allow WordPress to configure wp-config.php during installation, update files during upgrades, and update the .htaccess file for pretty permalinks, give the server write permission on ...
FTP credentials on localhost
wordpress
Im trying to make previous_post_link and next_post_link work inside a custom post type, inside a same category (taxonomy) but its not working. It this posible ? Im trying <code> &lt;?php previous_post_link('&lt;div class="posts-next"&gt;%link&lt;/div&gt;', 'Next in category',TRUE); ?&gt; </code>
I'd suggest using a plugin for this. <code> next_post_link </code> and <code> previous_post_link </code> will use the category taxonomy (literally)*, so they will not work as expected with custom taxonomies, which I think you are using here. I've used both Smarter Navigation by Scribu and Ambrosite Next/Previous Post L...
previous_post_link in same taxonomy in custom post type
wordpress
Today I work through a theme to get a better understanding of WordPress and templating. I discovered this: <code> &lt;?php printf( __('Designed by %s', 'Anyword'), '&lt;a href="http://www.example.com"&gt;Blub&lt;/a&gt;' ); ?&gt; </code> I know it shows "Designed by Blub" (Where Blub is linked) But what does the <code> ...
It's used for translate text. The second argument is a kind of namespace (called domain here) to retrieve the translation (for example from a dedicated file or something else). So <code> Anyword </code> here, should be the guy behind the template, or the company or what ever that can be a domain/namespace. edit: The do...
How does printf( __( ) ); work?
wordpress
I am using a sitemaps plugin which in very complex ways sets the timezone of <code> &lt;lastmod&gt; </code> (i.e. last modified time) for posts to GMT. Temporarily, until the plugin developer fixes it, I need to enforce a custom timezone on the plugin . The simple and straightforward way that I've found is to add somet...
http://codex.wordpress.org/Function_Reference/get_gmt_from_date Replace all instances of <code> get_the_date </code> or <code> the_date </code> with <code> echo get_gmt_from_date(get_the_date('Y-m-d H:i:s')) </code> . That's not a quick fix, it's a way to fix your sitemaps. EDIT: WordPress SEO runs it's raw dates from ...
Is it safe to use 'date_default_timezone_set' in plugin file?
wordpress
I store a custom user meta value for my users that is stored as a number like a score. I need a way of telling whether it has decreased or increased from its last value. So when I display it I can show an arrow to show which it's trending. Any ideas? Here is how I get the score and update the user meta. <code> add_filt...
I would solve this creating two extra Custom Fields: <code> _score_last </code> <code> _score_variation </code> The first underscore makes the CF invisible in the Admin area. Drop the following code in your theme's <code> functions.php </code> : <code> if( is_admin() ) { add_action( 'save_post', 'wpse_57217_check_custo...
How to tell whether a user meta value has increased or decreased
wordpress
I'm using the wp super cache plugin with cdn support turned on (aws cloudfront). I'm also using wp tables reloaded. The latter plugin includes a text file via ajax, and that file is being served by the cdn. The plugin doesn't do any sort of jsonp maneuvers, so the file hits access-control-allow-origin issues. Before I ...
The CDN tab of wp-supercache allows you to exclude files and folders. [edited to add] The field <code> exclude if substring </code> allows entry of a comma separated set of strings (eg <code> .php, wp-include, specialpluginjsfilename </code> ). Any file names that match against this set of values is excluded from the C...
Using wp-super-cache and amazon cloudfront - can I serve a file directly (no cdn)?
wordpress