question
stringlengths
0
34.8k
answer
stringlengths
0
28.3k
title
stringlengths
7
150
forum_tag
stringclasses
12 values
$paged for pagination is awlays returning 1, so no matter what page i click "1" is always highlighted and it always shows the same posts. i have tried a million different combinations of things to fix and nothing works :( <code> &lt;ul&gt; &lt;?php wp_reset_query(); $paged = (get_query_var('paged')) ? get_query_var('pa...
See Pagination Parameters under WP_Query in Codex: Since Wordpress 3.0.2, you do get_query_var( 'page' ) instead of get_query_var( 'paged' ). The pagination parameter 'paged' for WP_Query() remains the same.
Pagination not working
wordpress
what is the last <code> $count </code> in this example? <code> printf( _n( 'You have published %s post.', 'You have published %s posts.', $count, 'myplugin' ), $count ); </code> i guess the first one is to fill each %s, so what is the second $count? Thanks
The <code> _n </code> ( see Codex ) function accepts four arguments. The first two are texts to be translated (the first is singular, the second plural), the third argument is a number (in this case <code> $count </code> ). When <code> $count </code> is 1 the first string is used, otherwise the second string is used. S...
printf and _n in this example?
wordpress
I want to add contact form to my page. I found http://en.support.wordpress.com/contact-form/ article where (see below) there is button for adding contact form but I don't have this in my Wordpress installation. Do I have to add some plugin or what? I use wordpress 3.3.1.
If you are self-hosted, you won't have that button, as that is for Wordpress sites hosted by wordpress.COM See The difference between WordPress.com, WordPress, and WordPress.org Search for plugins for self-hosted Wordpress: http://wordpress.org/extend/plugins/search.php?q=contact+form&amp;sort= http://wordpress.org/ext...
Add contact form
wordpress
I have a Multi-Site install running on the current version of WordPress (3.3.1). The problem I'm having is the ID's are being stripped out of my tags in the editor. When I am logged in as a "Super Admin", the ID's are NOT stripped out. When I am logged in as an "Admin", the ID's are stripped out. Here is an example of ...
Turns out this has something to with the way a Multi-site intall handles unfiltered_html capabilities between Super Admins and Admins. The problem was resolved using the Unfiltered MU plugin , however, beaware of the warning stated on the plugin page.
ID's being stripped out of editor for Admin user in Multi-Site
wordpress
I want to add inline css code inside a page of my blog. This css code calls an image as background of a div. Is this possible? and how to do that? I have tried to add the image as a Media resource, and got a URL for it, but using this URL does not seem to work. Example of code that I paste to my page html: <code> &lt;p...
cant you just give that link a class? why touch your template files?.. anyhow i see no reason why you can't to that... the css should work.. The only change i would do when editing a template file is using php to get the folder url (where you image is) like so: <code> &lt;style type="text/css"&gt; .specialLink a { widt...
How to add inline css code with background image in page html code?
wordpress
I've been wandering around on the web for the last couple of hours wondering if there's a way to allow users to build their own RSS feed by selecting categories within WordPress, that could then be subscribed to by email. Seems to present two problems: Allowing people to build a personalized feed from categories. Enabl...
This is a really cool idea. I don't think part 2 should be handled inside WordPress: there are plenty of RSS to email providers. They're going to be way better at that than a plugin (or theme) is likely to be. BUT we can create RSS feeds. Step one: set up a class to wrap everything up. There are a few class constants a...
Allow users to create their own feed from selected categories?
wordpress
In anticipation of a major upgrade, I moved the webroot from <code> site_v1 </code> to <code> site_v2 </code> . The public url for the WP 3.3.1 install is still example.com/ (no change). I did a tar copy from the /site_v1 dir to the new /site_v2 dir. The WP installation is working well from its new Linux path of /site_...
Sorry if you have tried this already, but I go for the simplest answer first ;) In dashboard, Settings -> Media -> Uploading Files section to set path. Screenshot: https://skitch.com/mrsdrwife/8myu1/media-settings-elitemom.net-wordpress
Setting image upload absolute path?
wordpress
I need to change the number of posts queried for specific categories 'Recipes' or 'Product Reviews'. The below code works great for this, I have it in functions.php: <code> function change_number_of_posts($query) { if ($query-&gt;is_category &amp;&amp; ( $query-&gt;is_category('recipes') || $query-&gt;is_category('prod...
The function <code> cat_is_ancestor_of </code> takes two arguments (two category IDs). To check if category of ID 61 is ancestor of category with 54: <code> cat_is_ancestor_of(54,61); </code> I'm not sure if there is a better way of doing this, but you can get the current category's ID with the <code> get_queried_objec...
How to Check if a Child Category is Being Queried
wordpress
Using budypress and I'm trying to disable comments on comments' comment, meaning depth 2. The structure would go like this. Main Comment. Someone made a comment &lt;-- Reply is possible Another person made a comment of this reply &lt;-- No1 can comment this Any ideas? Thanks in advanced.
NVM, shame on me, I just realized I can control the depth in the wp options. Settings -> Discussion -> Enable threaded (nested) comments 2 depth
disable reply comments on depth equals 2
wordpress
I try to save inline javascript(Google analytics code) in wp-options table. But i can't figure out what validation function i shall use. I have tried esc_js when saving to the database. But i can't figure out what to use when i shall echo it in the head section.
You can use <code> addslashes() </code> and <code> stripslashes() </code> to prepare any data for database entry. These are native PHP functions, not wordpress functions, so they do not necessarily need to be hooked anywhere specific in the wordpress load to work.
Data validation for inline javascript
wordpress
I have created a hierarchical custom post type in wordpress called "films." It is hierarchical so it can have children elements. When a "film" is clicked, wordpress automatically uses the template called 'single-films.php'. That is great, but I wish to use a different template when one of the film's children pages is c...
If, from within <code> single-films.php </code> you filter based on the parent post you should have little issue with this. For example: <code> if( $post-&gt;post_parent != 0 ) { // not top level } else { // top level page } </code> If you need to know how deep the page is, that's a different matter, but that's also do...
Wordpress Custom Post Type Children Template
wordpress
I realize I've asked similar in the past, but I've currently running in some difficulties editing/removing the admin nav menu advanced menu properties. (without using jQuery) <code> add_filter( 'manage_nav-menus_columns', 'cor_wp_nav_menu_manage_columns'); function cor_wp_nav_menu_manage_columns() { return array( '_tit...
After some struggling extending <code> Walker_Nav_Menu_Edit </code> and using <code> preg_replace </code> on the property fields, I've ended with this solution: <code> // removes the `nav-menus.php` 'advanced menu properties' column add_filter( 'manage_nav-menus_columns', '__return_empty_array', 200 ); add_action( 'adm...
Difficulties filtering manage_nav-menus_columns
wordpress
I have a function in my functions file where i output Google Analytics code. <code> function mytheme_trackingcode(){ $mytheme_option = mytheme_get_global_options(); $tracking_code = $mytheme_option['tracking_code_head']; if($tracking_code){ echo '$tracking_code'; } } add_action('wp_head', 'mytheme_trackingcode'); </cod...
<code> '$tracking_code' </code> ist just a string. It closes <code> &lt;head&gt; </code> automatically. So, no, it doesn’t come after the <code> head </code> , you just failed to use source view . Firebug and similar tools show just the rendered DOM, that’s not good enough. Fix: <code> echo $tracking_code; </code> .
wp_head function outputs after
wordpress
When I use wp_list_categories(), it results in the number of posts in a category being shown, how do I hide the number? For example: I have xyz category, it has 3 posts, the result will be: <code> xyz(3) </code>
By default <code> wp_list_categories() </code> doesn't show post count, because <code> show_count </code> is set to <code> false </code> , check arguments passed into <code> wp_list_categories() </code> .
Remove the number of posts displayed in wp_list_categories()
wordpress
When I write a post and schedule it for later publishing, WordPress will allow me to preview the post as if it was already published but I need to be logged in as administrator (or anyone who is authorized to preview the post). Is there a way, possibly a query string parameter, to make the post previewable by anyone, i...
Draft previews Take a quick look at this chunk of core code in query.php which [Checks] post status to determine if post should be displayed. http://core.trac.wordpress.org/browser/tags/3.3.1/wp-includes/query.php#L2658 <code> if ( ! is_user_logged_in() ) { // User must be logged in to view unpublished posts. $this-&gt...
How to make scheduled post preview visible to anyone?
wordpress
I have a client which is in need of an entirely new website. One of the features of their existing website that they wish to keep is a student book exchange, where: students can sign-up and post any number books that they have to sell set a price for their own books take their books down from the website once their boo...
Custom Post Types (there are several plugins in the repo for that) Custom Meta Boxes/Fields - a good library is the »RW Meta Box« set of classes Extend the search - stackexchange-url ("there are several answers that show you how to do this in the [tag:search] archive"). Role Management: IMHO »Members« does the job best...
Wordpress Book Exchange Plugin Equivalent?
wordpress
I am using the following code, to output the content from a page with the id of two. This is in my custom template file which is selected in the page. It works fine locally but online it does not work, it outputs nothing, the id is based of this url <code> http://www.goodmorningmoon.ca/wp-admin/post.php?post=2&amp;acti...
have you tried get_page() ? <code> $page_id = 123; // 123 should be replaced with a specific Page's id from your site, $page = get_page( $page_id ); // You must pass in a variable to the get_page function. echo '&lt;h3&gt;'. $page-&gt;post_title .'&lt;/h3&gt;';// echo the page title echo apply_filters('the_content', $p...
Trying to output content from page, works locally but not online
wordpress
so i'm back with rewrites... i am looking for a more automated solution. i stumbled across this on the interwebs: <code> /** * Generates all the rewrite rules for a given post type. * * The rewrite rules allow a post type to be filtered by all possible combinations &amp; permutations * of taxonomies that apply to the s...
As I find myself googling about rewrites again, a full year later I will post the solution that was provided to me by the tutorial's author. The solution was to set the desired <code> query_var </code> when registering the taxonomy. <code> register_taxonomy( 'product_cat', 'product', array( 'query_var' =&gt; 'product-c...
Auto generate rewrite rules for multiple taxonomies
wordpress
In my plugin code, I am pulling the table id from two tables. The id is being pulled from one table but not from the other and I get errors in both instances. The queries work on mysql when I use them. any thoughts? code is below and output below that. The id gets pulled from the wp_shclass table but not the wp_shinstr...
Deleting the tables and recreating them solved the problem. The problem was in how I had created the tables
plugin code is pulling information from database in one instance and not in other. What is wrong?
wordpress
hi does any one know how can i add other meta box and save the data in a different custom fields, using the code below. <code> &lt;?php function add_meta_boxes() { add_meta_box( 'repeatable-fields', 'Audio Playlist', 'repeatable_meta_box_display', 'post', 'normal', 'high'); } add_action('admin_menu', 'add_meta_boxes');...
<code> function add_meta_boxes() { add_meta_box( 'repeatable-fields', 'Audio Playlist', 'repeatable_meta_box_display', 'post', 'normal', 'high'); add_meta_box( 'wpa-45985', 'Wordpress Answers Metabox', 'wpa_meta_box_display', 'post', 'normal', 'high'); } add_action('admin_menu', 'add_meta_boxes'); </code> just define a...
add meta box using function.php
wordpress
Here you see the parent menu selected in the horizontal navbar. I already have that working. I need a sidebar like they have with the same parent indicated plus children when they exist . At the moment I have some great code thanks to stackexchange-url ("Michael's feedback at WordPress Stack Exchange on an earlier ques...
With the help of a partner developer I went for a CSS solution. The solution has been added to question above. It just hides all page items at first with <code> display:none </code> and then shows the items I need. The pages list is loaded with needed indentations using <code> wp_list_pages('title_li='); </code>
Menu with parents, children and or siblings pages display
wordpress
I'm using wp-postratings on my site and I want to include it on the buddypress profiles of my members so other users can rate them. I place the function on the profile page but it doesn't do anything when a rating is clicked. Any ideas on what I can add to make it work?
It's likely that it will not be as easy as adding something small to make it work. Plugins like WP-Postratings store their data on a post-by-post basis. But BP members are not posts. So you would have to intercept the way in which the plugin stores its ratings data natively, and save it to users instead. Moreover, you'...
Using wp-postratings to rate user on profile pages
wordpress
I would like to display a custom subtitle for the different type of archive pages. I can easily know what type of archive page I'm in (date, category, etc.) but I have found nothing online that tells me how to get meaningful information for each of the specific, archive page types. I have the following function: <code>...
How about using the <code> single_cat_title() </code> function regardless of what type of archive it is? For example: <code> function get_the_subtitle() { if( is_archive() ) { $subtitle = 'Blog posts for '; } if( is_category() || is_tag() ) { $subtitle .= single_cat_title( '', false ); } if( is_author() ) { $curauth = ...
Archive subtitles for different types of archives
wordpress
I am working on a private site where the comments need to be hidden. I know how to remove the comments feed from the header, but can anyone give me some instructions on how to disable the comments feed altogether. Because all you need to do is add /feed/ to the single post and then you can see the comments feed. I trie...
Something like this should work. <code> function wpse45941_disable_feed( $comments ) { if( $comments ) { wp_die( 'No feed available' ); } } add_action('do_feed', 'wpse45941_disable_feed',1 ); add_action('do_feed_rdf', 'wpse45941_disable_feed',1 ); add_action('do_feed_rss', 'wpse45941_disable_feed',1 ); add_action('do_f...
Disable Comments Feed
wordpress
I have a WP installation on my local machine and trying to get my hands dirty with plugins. I wish to clone a project from github which has this plugin code. However, i dont have the permissions inside plugins to do this as a normal user without su priveleges. (of course i can become root and do this but i dont think t...
Best thing to do is check the WP docs themselves for correct file/folder permissions and how to change them, if needed: http://codex.wordpress.org/Changing_File_Permissions Typically, all files should be owned by your user (ftp) account on your web server, and should be writable by that account. On shared hosts, files ...
Problem with permissions in wp-content/plugins
wordpress
I'm looking to modify the output of the_excerpt when there isn't an excerpt specified and the post is password protected. I already can modify the password protected form to whatever I want, but the_excerpt is outputting "There is no excerpt because this is a protected post.". The code for this lies in wp-includes/post...
Simple way would be to check output in template (or small wrapper): <code> $excerpt = get_the_excerpt(); if( 'There is no excerpt because this is a protected post.' == $excerpt ) { // stuff } else { echo $excerpt; } </code> Another way would be to use <code> gettext </code> filter (which is used inside <code> __() </co...
the_excerpt - want to modify password protected output
wordpress
I want to hide wordpress signs from my site. So I don't want other people know that I built the website via WordPress. So I decided to remove <code> wp- </code> prefixes from all wordpress folders and files. And I also removed <code> wp- </code> prefixes from file contents with Notepad++. So my question is what problem...
Editing core is extremely bad practice. At best you will break updates, at worst random thing would be completely broken all over. See stackexchange-url ("Steps to Take to Hide the Fact a Site is Using WordPress?") for better alternatives.
What problems maybe happen if I remove "wp-" prefix from wordpress folders and files?
wordpress
Is a way to pass my own parameters to the function in <code> add_filter </code> or <code> add_action </code> . For example take a look in the following code: <code> function my_content($content, $my_param) { do something... using $my_param here ... return $content; } add_filter('the_content', 'my_content', 10, 1); </co...
By default this is not possible. There are workarounds if you do it the OOP way. You could create a class to store the values you want to use later. Example: <code> /** * Stores a value and calls any existing function with this value. */ class WPSE_Filter_Storage { /** * Filled by __construct(). Used by __call(). * * @...
Passing a parameter to filter and action functions
wordpress
I want to grab the 5 most recent posts that have thumbnails.
You should be able to call posts with a featured image with the following code: <code> $thumbs = array( 'posts_per_page' =&gt; 5, 'meta_query' =&gt; array(array('key' =&gt; '_thumbnail_id')) ); $query = new WP_Query($thumbs); </code> The code checks each post for the custom field _thumbnail_id, which is where the thumb...
How do I check if a post has a post thumbnail in WP_Query?
wordpress
Original question How do I get menu items using slug and not ID I need to get a specific menu, but I can't use ID, since the menu ID on my dev is not the same as on my staging and prod server. WP doc says that <code> wp_get_nav_menu_items </code> can be used with menu slug. But how do I know what slug is created? I tes...
So, based on your comment: <code> wp_nav_menu </code> is what I'm using now. But now I have to add 'home' menu item depending on certain criteria I'm going to propose a solution that will allow you to add a "Home" menu item to any menu, based on arbitrary conditions, using the <code> wp_nav_menu_items </code> filter ( ...
how do I add "home" menu item conditionally to custom menus?
wordpress
I can hook custom function to each of <code> trash_post </code> , <code> edit_post </code> , <code> private_to_publish </code> etc. to meet some of my requirements, but I need also to check for more possible transitions like 'pending to draft' , 'private to draft' and so on. Something similar to this inexistent functio...
See this Codex page. In general the hook is <code> {old_status}_to_{new_status} </code> . (Untested) but in your case, the hook would be <code> pending_to_draft </code> : <code> add_action('pending_to_draft','wpse45803_pending_to_draft'); function wpse45803_pending_to_draft($post){ //Do something } </code> You might wa...
How can I run custom function when post status is changed?
wordpress
1. My shortcodes I've developed multiple shortcodes for my own theme, I'm loading them in functions.php like this <code> require_once (MY_URL . '/bartag_shortcode.php') </code> . Here's an exemplary bartag shortcode from WordPress Codex: <code> function bartag_func( $atts ) { extract( shortcode_atts( array( 'foo' =&gt;...
Inspect the global variable <code> $shortcode_tags </code> : <code> print '&lt;pre&gt;' . htmlspecialchars( print_r( $GLOBALS['shortcode_tags'], TRUE ) ) . '&lt;/pre&gt;'; </code> Output: <code> Array ( [wp_caption] =&gt; img_caption_shortcode [caption] =&gt; img_caption_shortcode [gallery] =&gt; gallery_shortcode [emb...
Organizing shortcodes. How to display all of them and their attributes?
wordpress
I need to duplicate a list of thumbnails elsewhere on a page and have set up a few different custom thumbnail sizes in my functions.php file. If I use: <code> the_post_thumbnail('photo-small'); </code> Then the thumbnail gets displayed correctly, if I use: <code> echo get_post_thumbnail('photo-small'); </code> Nothing ...
You're using <code> get_the_post_thumbnail() </code> and not the nonexistent <code> get_post_thumbnail() </code> function, right? As JohnG said, you have to pass the ID of the current post to <code> get_the_post_thumbnail() </code> (the <code> the_post_thumbnail() </code> function already handles that for you). The Fun...
get_the_post_thumbnail('thumbnail-name') always returns empty string
wordpress
I have create a custom post type in my WordPress attached with a custom taxonomy. The post collect date from the from end of the web site by using wp_insert_post(). This is my Custom post registration code: <code> $labels = array( 'name' =&gt; 'Films', 'singular_name' =&gt; 'Film', 'add_new' =&gt; 'Add new', 'add_new_i...
Where is the code that catches an processes the <code> $_POST </code> data? Is it in a template file? Or is it in a function that is run on a hook? If it's the latter, and if <code> taxonomy_exists() </code> is returning <code> false </code> as you suggest here (stackexchange-url it's possible that you're checking befo...
WP insert post and custom taxonomy
wordpress
I have a conflict issue with 2 custom post types. I have a template file archive-media.php and have created the related 'media' custom post type. This all works well, however in the sidebar I have a list of events from a second (events) custom post type, which also works perfectly in every respect, including on this pa...
It's still early for me, but you need to check for <code> if( $events_query-&gt;have_posts() ) : </code> rather than <code> if( have_posts ) : </code> as the latter will be checking against the current post type and not your custom query.
Custom Post Type Query issue
wordpress
I use this code for my custom paging : <code> global $wpdb, $table_prefix, $current_user; get_currentuserinfo(); $umail = $current_user-&gt;user_email; $paged = $wpdb-&gt;get_results("SELECT * FROM {$table_prefix}comments WHERE comment_author_email = '$umail'"); $page = isset($_GET['page']) ? (int) $_GET['page'] : 1; $...
Instead of the loop at the bottom, use WordPress's <code> paginate_links() </code> : <code> $pagination = paginate_links(array( 'total' =&gt; $pages, 'current' =&gt; $page )); echo $pagination; </code> You can play around with some of https://codex.wordpress.org/Function_Reference/paginate_links to get the appearance t...
Custom paging function
wordpress
I am using this Query to pull in the latest 3 post <code> &lt;?php $query = 'posts_per_page=3'; $queryObject = new WP_Query($query); // The Loop... if ($queryObject-&gt;have_posts()) { while ($queryObject-&gt;have_posts()) { $queryObject-&gt;the_post(); the_title(); the_content(); comments_template(); } } wp_reset_post...
Did you try <code> $query = 'posts_per_page=3&amp;cat=3'; </code> ?
Add category to my get_post query
wordpress
In NextGEN Gallery, I am able to add a dropdown menu that lets users filter a gallery to only show images that are tagged with a specific ngg_tag, simply by adding this to view/gallery.php in the NextGEN Gallery code: <code> the_widget('Taxonomy_Drill_Down_Widget', array( 'title' =&gt; '', 'mode' =&gt; 'dropdowns', 'ta...
There aren't really any good filters/hooks that are going to allow you to place the custom drop down control where you'd like. What you should do instead is create a new template from an existing one, then add your widget code in. I'm going to edit "gallery.php", but you must edit album.php or whichever gallery types y...
NextGEN Gallery: Adding drop-down menu widget to gallery view without modifying plugin code
wordpress
In the Wordpress control panel, when writing a new post, I would like to disable the Header 1 and Header 2 from the text formatting combobox, because I already use them on my theme (h1 for blog name and h2 for post titles), and would like to keep all headers inside a post with h3 or higher. Is that possible? It doesn't...
you can change lots of things about the tinyMCE editor at the tiny_mce_before_init filter. http://codex.wordpress.org/TinyMCE_Custom_Buttons the following will restrict your blockformats to p,h3,h4 and blockquote <code> function wpa_45815($arr){ $arr['theme_advanced_blockformats'] = 'p,h3,h4,blockquote'; return $arr; }...
Disable h1 and h2 from rich text editor combobox
wordpress
I need to amend the labels for name and email fields in the comments form in my localized (Czech) Wordpress this way: <code> Emailová adresa =&gt; Email Webová stránka =&gt; Web </code> What I did is that I've opened <code> wp-content\languages\cs_CZ.po </code> in poEdit, located the strings and compiled the new versio...
i think you need the gettext filter. lifted directly from the codex, here is an example: <code> add_filter( 'gettext', 'theme_change_comment_field_names', 20, 3 ); /** * Change comment form default field names. * * @link http://codex.wordpress.org/Plugin_API/Filter_Reference/gettext */ function theme_change_comment_fie...
How to localize built-in strings in a future-proof manner?
wordpress
I have <code> wp_nonce_field </code> in my code but it's creating two instances to the html code for some reason, one where I'd expect it and another at the start of the entry. Is this correct or am I doing somehthing wrong. It's creating a validator error. One thing I'm doing a bit different is that the form is being ...
If you're going to add the nonce field to an HTML string, you have to specify that you don't want it echoed. That's the fourth parameter; see https://core.trac.wordpress.org/browser/tags/3.3.1/wp-includes/functions.php#L1952 <code> $formDisplay .= wp_nonce_field( 'contact-form', '_wpnonce', true, false ); </code>
wp_nonce_field displaying twice
wordpress
I have the following code in my functions.php file. It works, but I am wondering if this is best practice for including styles in wordpress. Also do I need to register the style with wp_reister_style, since it works without and why do I need to do so? <code> &lt;?php function mrskitson_load_styles(){ if (!is_admin()){ ...
Two problems: You only need to provide the script path once , either in the <code> wp_register_style() </code> call, or in the <code> wp_enqueue_style() </code> call, but not both . (In fact, in this context, it would be fine to omit the <code> wp_register_style() </code> call entirely, and just use the <code> wp_enque...
Proper use of wp_enqeue_style
wordpress
Can I modify widgets in a child theme? When I change the footer, I don't need extra steps -- it just works. What about widgets? Example: A widget of a theme I am using makes use of google maps. I'd like to add some options to google maps options array. My idea is to just copy the widget to the appropriate directory in ...
Widget are not part of hierarchical parent/child theme relation, so you would need to follow more generic development process: Optionally disable widget registration in parent theme (if possible to do cleanly - with hooks or otherwise). Extend (as in widget's PHP class) or fork (copy and modify the code) widget in chil...
Widget modifications in a child theme
wordpress
<code> function get_nb_offres( $typeOffre ) { global $type_bien_correspondances; $args = array( 'post_type' =&gt; 'annonces', 'meta_query' =&gt; array( 'relation' =&gt; 'OR' ) ); foreach( $type_bien_correspondances[$typeOffre] as $typeBien ) { $args['meta_query'][] = array( 'key' =&gt; 'type_de_bien', 'value' =&gt; $ty...
Afaik , there's no <code> relation </code> key for <code> meta_query </code> . Use <code> compare </code> instead and maybe also specify a <code> type </code> to speed things up with skipping types that are out of scope. EDIT <code> $args = array( 'post_type' =&gt; 'product', 'meta_query' =&gt; array( // Used to set tw...
Meta_query with relation 'OR' killing server CPU
wordpress
After doing a Wordpress upgrade I notice that there are some files that have an old creation date. Am I safe to delete these on the assumption that they were part of the previous release and so aren't needed for the latest release? I've used windiff to compare two different downloaded releases (i.e. not my live site) a...
For several versions already core updates are partial (differential). Only changed files are downloaded and overwritten so it is not safe to assume that those that weren't are not used. However, you can compare downloads of two full releases to see which file aren't used any more.
Getting rid of files not used by latest upgrade
wordpress
I would like to remove trailing (0, 0) from the /forums page (forums being the 'forums base') in bbpress. The site is also using buddypress and bbpress got installed as a part of 'group forums'. Here's how the /forums page looks like at the moment: General Forums <code> General (0, 0), Methodology (0, 0), Implementatio...
From my understanding, these are produced by the function <code> bbp_list_forums() </code> , as called in the template file <code> bbpress/loop-single-forum.php </code> . You should be able to copy that template into your theme and change the call to <code> bbp_list_forums() </code> as follows: <code> &lt;?php bbp_list...
How to remove ( 0, 0 ) from forum page in bbpress
wordpress
Im using this code to insert links into my blog: <code> $linkdata = array( 'link_name' =&gt; $title, 'link_url' =&gt; $url, 'link_catetory' =&gt; 3, // my cat id ); $link_id = wp_insert_link( $linkdata ); </code> Links are inserted, but not in the correct category, I missed something?
I would guess <code> link_catetory </code> should be <code> link_category </code> . :)
wp_insert_link not working
wordpress
Is it possible to display a warning in the admin section when posting if the excerpt section hasn't been filled out to stop a post being published without an excerpt? Does anyone know of a plugin that has this facility?
Writing your own plugin will help you understand WordPress better, subsequently enjoying it even more, beside you look like you are quite capable with some tiny bit of PHP, no? When saving a post, the <code> save_post </code> hook is pulled on. This passes along the <code> $post_ID </code> and the <code> $post </code> ...
Show validation warning if no Excerpt is added
wordpress
I have the latest wordpress version installed. When I upload an image in the control panel for a post, I then go to edit it (crop an image for the thumbnail the way I want or rotate or do any kind of editing) and instead it shows a broken image. The actual images are uploaded, I just can't seem to use the wordpress ima...
Check the permissions on the file as it sits on the server. Try loading the image URL into a browser and see what error displays. Sometimes I can duplicate the image and reupload and it works. Just some things to try.
Wordpress Uploader Editor shows broken image
wordpress
I have created a custom taxonomy for a custom post type called "portfolio" like so: <code> function jvs_portfolio_categories_init() { register_taxonomy( 'project-category', 'portfolio', array( 'label' =&gt; __( 'Project Categories' ), 'query_var' =&gt; true, 'hierarchical' =&gt; true ) ); } add_action( 'init', 'jvs_por...
This function fixed the issue: <code> function change_posttype() { if( is_archive() &amp;&amp; !is_admin() ) { set_query_var( 'post_type', array( 'post', 'portfolio' ) ); } return; } add_action( 'parse_query', 'change_posttype' ); </code> Then I just removed the paged and <code> query_string </code> function in my code...
Pagination throws 404 error on custom taxonomy archive pages
wordpress
This should be a simple task, however I am having no such luck. I am using a theme that has a homepage slider which spans across the entire content area. I have been asked to reduce the size of the slider and move the sidebar up next to it. I've attempted to call the sidebar in different and seemingly logical locations...
The best way is to move <code> &lt;div id="side"&gt; </code> outside of <code> &lt;div id="content"&gt; </code> , so that you can properly position it next to the slider ( <code> &lt;div id="lof-container"&gt; </code> ). Alternatively, you could do it with <code> #maincontent { overflow: visible; } #side { margin-top: ...
Move wordpress sidebar on homepage up to new position
wordpress
I have this code calling a list of custom post events. It calls them in the right order, but when the event is passed, it stil displays the event. Any ideas what's wrong with the code? <code> $args2 = array( "post_type" =&gt; "gig", "meta_key" =&gt; "_gigswhen", // Change to the meta key you want to sort by "meta_query...
You can't use <code> date() </code> with no parameters. See http://php.net/manual/en/function.date.php . Try this for your <code> meta_query </code> argument: <code> 'meta_query' =&gt; array( array( 'key' =&gt; '_gigswhen', 'value' =&gt; time() 'compare' =&gt; '&lt;' ) ) </code>
How to eliminate custom posts where the "date" value is expired?
wordpress
I'm curious if it is possible, in a plugin/custom code, to take an URL that has been generated by the currently running WordPress site &amp; parse it to retrieve the $blog_id and $post_id? ie. taking a string like "myblog.mysite.com/2012/03/16/whatever/" and determining that this is post #6 ("whatever") on blog #2 ("my...
As Weston mentioned, if you're within WordPress and you know what blog the URL came from, then ask WordPress for the blog ID. But if you're really, really sure there's no better method in this case than parsing a URL, then here you go: <code> $url = 'http://myblog.mysite.com/2012/03/16/whatever/'; $domain = parse_url( ...
Easiest way to simulate WordPress's URL resolution to retrieve post ID, etc?
wordpress
I would like to be able to display all the posts in a certain category on a page so that all posts are on that one page and there is no pagination. If possible, I would also like to display a short preview of the posts - all posts will have a thumbnail and a short paragraph at the start. I've tried various different pl...
I found a plugin-solution eventually to the my second option. I now use Posts per cat and set it to some silly number so that all of the posts in the category display on one page; it turns out that's all I needed! Thanks and Regards
Show posts of category in a page
wordpress
My plugin uses publish_post hook to get the post data and do some processing: <code> add_action('publish_post', 'publish_post'); function publish_post($post_id) { global $post, $blog_id; $author = get_userdata ($post-&gt;post_author); $title = $post-&gt;post_title; //some processing here... } </code> I notice that for ...
This hook is called like this: <code> do_action("{$new_status}_{$post-&gt;post_type}", $post-&gt;ID, $post); </code> My guess is that you should be using data passed as second <code> $post </code> argument, rather than global. So: <code> add_action('publish_post', 'publish_post', 10, 2 ); function publish_post($post_id...
post_title is empty on global $post object
wordpress
I update my permalink structure to /post/%post_id%/%postname%, but if someone uses a URL like /post/1234 instead of the full URL of /post/1234/bingo-rulz, WordPress shows the post without giving a 301 to the full URL. Isn't this poor SEO? Sites like tumblr and stackexchange auto 301 to the full URL. Any hacks/code/plug...
Think I found a solution... Since anything after the %post_id%/ _ _ will redirect to the full slug, a simple RewriteRule in the .htaccess file appears to do the trick. I had to place it above other RewriteRules and this is working for me. RewriteRule ^post/(\d*)/?\z$ http://noahcoad.com/post/ $1/a [R=301,L]
Auto 301 to full post permalink? (using /posts/%post_id%/%postname%)
wordpress
If there is a long string in PHP like this: <code> &lt;?php $text = "Some ... very very... long string"; </code> Can it be localized by GetText wrapping it in <code> __() </code> , e.g. <code> &lt;?php $text = __("Some ... very very... long string", "domain"); </code> ? I've heard that GetText doesn't support multi-lin...
<code> __() </code> and the other l18n functions will handle any string you give them, including line breaks. In my experience, poEdit recognizes them just fine, but if you're having issues, you may consider using UNIX line break escapes <code> \n </code> instead of actual line breaks inside the strings; in this case, ...
How to translate multi-line strings?
wordpress
i am creating a new plugin,i got this error Fatal error: Call to a member function query() on a non-object in my ajax page. how to solve this error. this is my code: <code> if (isset($_REQUEST['ckballvalue'])) { $allvideos=$_REQUEST['ckballvalue']; $now = date("Y-m-d H:i:s", time()); global $wpdb; $insert_video =$wpdb-...
The problem is that you are not loading WordPress, so none of it's included framework is defined (in this particular case the <code> global $wpdb; </code> object and it's methods). WordPress has built in way of handling ajax requests. In particular you should send the data to the url: <code> admin_url('admin-ajax.php')...
Fatal error: Call to a member function query() on a non-object in my ajaxpage
wordpress
I dream of a wordpress dashboard that would be mostly Wysiwyg and let the user edit a site based on a given theme. In fact this is something I know is technically possible as I have seen it in this tool: http://visualwebsiteoptimizer.com/features.php (see the video; it is not a wordpress tool, but it shows how one can ...
Just found this: http://www.spiderwebpress.com/ apparently they call this a "WYSIWYG theme platform". http://www.pagelines.com/
Any Wysiwyg tool to edit wordpress site based on given theme?
wordpress
Whenever I write plugins that use Admin Panels, I include some form of pagination using the <code> paginate_links </code> method and I have always been able to style them in a nice way using the suggestions on this blog post . Recently, however, I have been unable to find the secret sauce to make this work. I'm guessin...
Fantastic, once again researching my question has provided an answer. For those interested, surround your pagination links in <code> &lt;div class="tablenav"&gt;&lt;div class="tablenav-pages"&gt;LINKS&lt;/div&gt;&lt;/div&gt; </code> to get better looking number links. (moved to answers as suggested by SickHippie)
Admin Panel pagination link styles
wordpress
Below is the code from my author.php file. The problem is that <code> next_posts_link </code> and <code> previous_posts_link </code> only generate links based on the number of posts in the blog authored by the author in question, not the number of posts in the query ( which includes pages and events). I have used WP_Qu...
I got it working, first by implementing the solution I described in the edit above, and then by adding the code below ( from stackexchange-url ("this question") ) to functions.php. By the way I actually still had a problem at that point with a 404 on the last page which seemingly is caused by having 'posts_per_page' se...
next_posts_link and previous_posts_link problem
wordpress
I am new to theme development. I am trying to create a custom metabox that has the ability to upload a image. I am doing this on a page not a post. I want to output the images (multiple) onto the page in a unordered list. I have attempted to use WP alchemy, and I can only get as far as getting the metabox to show up bu...
That's pretty advanced and it doesn't sound like you are all that comfortable with WP yet, no offense. You can definitely do this with WP Alchemy (I have and do), but you really have to get down and dirty with some Javascript to 1. launch the media uploader and 2. to hijack the send to editor function. some good reads:...
Upload multiple images in a custom metabox
wordpress
I'm using <code> do_shortcode </code> function to add shortcode in my template. But i would like to check if that shortcode exists before display them. I mean like this <code> If (shortcode_gallery_exists) { echo do_shortcode('[gallery]'); } </code> Can anyone help me? Thanks
#23572 introduced shortcode_exists() into 3.6.
How to check if a shortcode exists?
wordpress
I have been trying to work out the most effecient way to use functions in WordPress. I have a big slow function big_slow_function() that ideally is only run once. But I need to use the boolean that is returned by this function throughout my theme files (in header.php, page.php, sidebar.php, footer.php, loop-page.php, f...
<code> function my_big_function() { static $result; // Function has already run if ($result !== NULL) return $result; // Lot of work to determine $result $result = TRUE; return $result; } </code> Also see: stackexchange-url ("stackexchange-url
How to call a function only once (global variable scope)
wordpress
I am not sure if it is clear from the title what I want to achieve here so let me try to clarify this. I wanna make use of Wordpress's menu system and need to adjust it to my needs, which means that I need it to go from here : <code> &lt;ul&gt; &lt;li&gt;item1&lt;/li&gt; &lt;li&gt;item2&lt;/li&gt; etc. &lt;/ul&gt; </co...
You could use a stackexchange-url ("custom walker") or just stackexchange-url ("filter the menu title"). It depends on the position you need for your extra content: Should it appear before or inside the link? Example with a walker Update: Actually, this cannot work: the parent function creates the <code> &lt;li </code>...
insert element inside wp menu list item
wordpress
I am using the Advanced custom fields plugin to add a upload image option to a page, but I am wondering if there is a way so that, when I output it to a theme with <code> &lt;img src="&lt;?php the_field('add_image'); ?&gt;"/&gt; </code> it is not full size, it is cropped or set to one of the wordpress preset media size...
In Advanced Custom Fields the field editing screen where you add in the required fields and assign them to post edit screens did you choose image URL or Attachment ID for the image field? It sounds like you've got it set as image URL which will just return the URL to the originally uploaded file as you've discovered. O...
Advanced Custom Fields
wordpress
I'm using WordPress to build my photography portfolio. So far I've created a Custom Post Type called <code> session </code> for each photo session, and I've managed to list all the sessions with each thumbnail in the home page. Now, however, I have to create the content of each <code> session </code> . I'd like to keep...
Attachments are post objects, with <code> post_parent </code> set to the ID of the post they belong to (ie your 'session'). The WP Codex page on <code> wp_get_attachment_image() </code> has an example almost exactly like what you're trying to do: https://codex.wordpress.org/Function_Reference/wp_get_attachment_image#Di...
Creating my own portfolio custom-type
wordpress
Is there a php function which can add/remove tags of posts? If not how would I do this? I am looking for something like this: <code> add_tag($post_id, 'tag-name'); remove_tag($post_id, 'tag-name'); </code>
The key function you're looking for here is <code> wp_set_post_tags() </code> . To add the tag 'awesome' to post 98, <code> wp_set_post_tags( 98, array( 'awesome' ), true ); </code> Note that the <code> true </code> parameter means that this tag will be added to the existing post tags. If you omit this value, it defaul...
how to programmatically change post tags
wordpress
I'm developing a wordpress theme that uses a static page as front page. My wordpress is configured to use "Home" page as its front_page and "Blog" page to show the blog posts. When i try to use the loop on my "Blog" page to list the posts i get a odd behavior, the loop runs fine but any method to get the post informati...
Just before the snippet i posted i was doing something like <code> $posts = array(); </code> , it seems that wordpress keeps the collection of the posts to be used on the loop in a variable of the same name, so i was meesing with the data, just changed <code> $posts </code> for <code> $items </code> and now works fine.
The Loop for my theme with static front page is not working
wordpress
Somewhere along the line I have messed up my js enqueue I am not sure how. I have the following in my functions.php file and I am including <code> &lt;?php wp_footer(); ?&gt; </code> in my footer.php before the js files were outputting in the footer no problem, but now it isn't working and I don't know why? <code> func...
I am not sure if you posted code as-is or extracted part of it, but per this snippet - you are hooking function inside itself . Which doesn't seem like it will work nicely. :) Also <code> init </code> hook should not be used for enqueue, on front-end hook to use is <code> wp_enqueue_scripts </code> , see stackexchange-...
JavaScript enque stopped working
wordpress
We're looking to create a network of BuddyPress sites that share a common design, a common theme and some common content, but the same userbase across all network sites. Each user will 'belong' to a network site, so whilst people can browse the London, New York and Sydney editions, they will need to 'belong' to one of ...
BuddyPress is compatible with a WordPress Multisite setup. There are several different ways to set it up. By default, BuddyPress data is stored in a networkwide way. Generally, that means that, within the network of sites, only one site is dedicated to BuddyPress features/content - you might think of this as the "commu...
Is it possible to have a network of BuddyPress sites, a-la WordPress MU, with single-sign-on?
wordpress
I am building an event manager. One of the template files I have is events-single.php which displays single events. At the bottom of this I have next and previous events using <code> next_post_link </code> and <code> previous_post_link </code> . The problem is that those functions proceed through the events in order of...
Take a look here: stackexchange-url ("specify meta_key / meta_value condition for prev_post_link and next_post_link") Which ultimately leads to this plugin, which accesses the get_adjacent_post function mentioned above: Ambrosite Next/Previous Post Link Plus And looks like it would fit your needs by allowing you to spe...
Adjust query on single
wordpress
I have a custom menu that I can call just fine using wp_nav_menu. Is there a way to have the menu name displayed inside an h3 tag before the menu? Ex. <code> &lt;h3&gt;My Menu Name&lt;/h3&gt; &lt;nav&gt; &lt;ul&gt; &lt;li&gt;Menu Item 1&lt;/li&gt; &lt;li&gt;Menu Item 2&lt;/li&gt; &lt;/ul&gt; &lt;/nav&gt; </code>
If you know the menu's slug, then things are easier, otherwise you can use this function to get the menu at a specified location. <code> &lt;?php function wpse45700_get_menu_by_location( $location ) { if( empty($location) ) return false; $locations = get_nav_menu_locations(); if( ! isset( $locations[$location] ) ) retu...
Display Menu Name using wp_nav_menu
wordpress
I'm looking for a plugin that enables me to reorder pages, posts and custom post types from the normal listing in the WordPress dashboard. The closest plugin I've found is Simple Page Ordering http://wordpress.org/extend/plugins/simple-page-ordering/ however this plugin does not allow post ordering, and also does not e...
I've used the below plugin and it has worked really well for me: Post Types Order It just adds a "Reorder" option in the sub-menu for posts and custom post types and has drag/drop functionality.
Best Plugin to Reorder Post Types
wordpress
I have tried to apply the advice offered by TheDeadMedic in stackexchange-url ("this post") to achieve the following URL structure: example.com/activities = a WP page example.com/activities/type-term = a custom archive example.com/activities/type-term/activity-post = a custom post All URL's work until the lowest one wh...
There's nothing in wordpress to automatically replace <code> %tax_type% </code> in the rewrite slug. You'd have to add some custom code to handle it like in this answer stackexchange-url ("stackexchange-url
Permalinks for custom post-types within custom taxonomies not found
wordpress
I am using Isotope and I currently have each post rendering as a box on my homepage. I am currently trying to edit my (working) query that currently displays all posts with the category slug of 'static'. Within that query i'd like to target 4 specific post ID's and customise the appearance of each of those 4 posts. So ...
After a bit of digging I came up with this IF statement which solves my problem: <code> &lt;?php $flickr_large = 64; $flickr_small = 113; $join = 117; $twtrfeed = 120; if ( $post-&gt;ID == $flickr_large ) : ?&gt; &lt;ul id="cycle"&gt;&lt;/ul&gt; &lt;?php elseif ( $post-&gt;ID == $flickr_small ) : ?&gt; &lt;div id="flic...
Customise the appearance of 4 specific post ID's within the loop?
wordpress
Is there a plugin that allows editing pages/posts without going to admin panel? I've a specific need to disallow access for users to admin panel of wordpress/multisite users. But I want them to be able to change contents of pre-structured pages. is this possible? anyone already thought of this before me??
Have you tried the Front End Editor plugin to allow users to edit the pages on the site? Front-end Editor is a plugin that lets you make changes to your content directly from your site. No need to load the admin backend just to correct a typo. You can edit posts, pages, custom post types, comments, widgets and many mor...
is there a plugin that allow editing pages from within pages without entering admin panel?
wordpress
I've got a pretty straight forward question. When does it become too much data to use add_option, update_option, etc, and instead use a custom DB table? For example, if a plugin stores thousands and thousands of characters of data using add_option, etc, is there a maximum it can handle before it starts to create proble...
For the record, I will never encourage developers to use custom database tables. Yes, they're easy to use, but you lose 100% of the data abstraction provided by WordPress. <code> add_option() </code> / <code> update_option() </code> / <code> get_option() </code> are basic key-value functions. They store data in a MySQL...
When to use custom DB tables or add_option?
wordpress
I am trying to learn more on Theme Development so I've created my own and everything worked fine except when I added <code> functions.php </code> and tried to update it with something simple as: <code> &lt;?php add_theme_support('admin-bar', array('menus')); ?&gt; </code> I get <code> Server 500 ERROR </code> and I can...
Error 500 is very generic and can be caused by numerous underlying issues. Your first step should be locating error log for your hosting account or asking support to help with that. My weak guess would be that your file gets created with file permissions that are not secure enough to hosting configuration.
add_theme_support( 'admin-bar' ) causes fatal error
wordpress
In the Admin area when you edit a post, I'd like to add a custom item to the Publish panel in the top right corner. Is it possible to access this through the Wordpress API? If so, what functions do I need to look at? Any examples would be much appreciated.
You can hook into <code> 'post_submitbox_misc_actions' </code> or <code> 'post_submitbox_start' </code> : <code> add_action( 'post_submitbox_misc_actions', 'wpse_45720_submitdiv_extra' ); add_action( 'post_submitbox_start', 'wpse_45720_submitdiv_extra' ); function wpse_45720_submitdiv_extra() { print '&lt;pre&gt;' . cu...
Is it possible to add an item the Post Publish panel?
wordpress
i would like to customize the design of the registration page of wordpress and also the registration form. Can i create a registration page template? or maybe tell wordpress to use a custom registration page i create.
WordPress handles registration with wp-signup.php (in the root of the installation). There are some hooks in place to allow for additional content (such as a signup header, or additional signup fields), but it doesn't support theming in the same way that other WP pages do. BuddyPress is a pretty heavy-duty solution if ...
What hooks, actions or filters i can use to customize wordpress registration page and form?
wordpress
I want to put the custom metabox I have only on the home page but I am not sure how to go about doing this. I am using the following to add the custom meta box to all the pages. How would I select just the home page, or home.php template or that ID. I am really just not sure of the syntax. <code> &lt;?php $custom_mb = ...
<code> new WPAlchemy_MetaBox(array ( 'id' =&gt; '_custom_meta', 'title' =&gt; 'My Custom Meta', 'template' =&gt; STYLESHEETPATH . '/custom/meta.php', 'exclude_template' =&gt; 'product.php' )); </code> the 'exclude_template' would work for excluding the one's you didn't want. <code> new WPAlchemy_MetaBox(array ( 'id' =&...
wordpress alchemy put custom metabox on certain page only
wordpress
I saw this snippet to remove menus: <code> function remove_menus () { global $menu; $restricted = array(__('Dashboard'), __('Posts'), __('Media'), __('Links'), __('Pages'), __('Appearance'), __('Tools'), __('Users'), __('Settings'), __('Comments'), __('Plugins')); end ($menu); while (prev($menu)){ $value = explode(' ',...
Here is your answer: <code> function remove_menus () { global $menu; if( (current_user_can('install_themes')) ) { $restricted = array(); } // check if admin and hide nothing else { // for all other users if ($current_user-&gt;user_level &lt; 10) $restricted = array(__('Dashboard'), __('Posts'), __('Media'), __('Links')...
remove menus for a specific role?
wordpress
Ok, so i have a Custom Post Type called "Services". This custom post type has a taxonomy called "Areas" and there's 5 terms in that taxonomy. Let's say I have 10 posts on "Services" and there's 5 posts in the term "Painting" and 5 more on the term "Photography". I need to be able to query posts from "Services" but inst...
This is the answer to the question :) <code> &lt;?php $args = array( 'post_type'=&gt; 'services', 'areas' =&gt; 'painting', 'order' =&gt; 'ASC' ); $the_query = new WP_Query( $args ); if($the_query-&gt;have_posts() ) : while ( $the_query-&gt;have_posts() ) : $the_query-&gt;the_post(); ?&gt; </code>
Get Posts by Custom Post Type ,Taxonomy, and Term
wordpress
Hi to all I would like to have a simple plugin, hook, anything that Automatically caches external images. Simple explanation: Actually I'm using this plugin: http://wordpress.org/extend/plugins/cache-images/ But with this I have to click on scan, then choose which images I would like to save then wait and so on... I'm ...
If you look at the Cache Images plugin's thumbnails page on the WordPress plugin directory it looks like this feature already exists within the plugin. In the admin section of your site go to Settings&rarr;Media there should be an option to cache images when posts are saved.
How to Automatically import external images to Upload
wordpress
My titles, site wide, will follow this theme all within a h1 tag: Main title heading / Sub-title text I'm trying to wrap a span tag around all text after and including the '/' so my markup will look like this: <code> &lt;h1&gt;Main title heading &lt;span&gt;/ Sub-title text&lt;/span&gt;&lt;/h1&gt; </code> How do I acco...
its best if you just use custom field type to create a sub title... That way you leave the title un-touched and just add a field where you can insert a value like so (calling field sub title): Then you can fetch your subtitle easily: <code> &lt;?php $sub_title=get_post_meta($post-&gt;ID,'subtitle',true); if($sub_title ...
How to split up the_title and insert a span tag
wordpress
I have the following code for a page. When I select the template Home Page from the drop down menu in the page edit, it doesn't work on my web host, but locally it works fine, so I don't think it is my code. I don't know why its not working though. <code> &lt;?php /* Template Name:Home Page */ ?&gt; &lt;?php get_header...
Might be a difference in query methods. This is a simpler way to query a page's content and can be used multiple times in a template without each query conflicting with each other. <code> &lt;?php $my_query = new WP_Query('page_id=2'); ?&gt; &lt;?php while ($my_query-&gt;have_posts()) : $my_query-&gt;the_post(); ?&gt; ...
Page template not registering on theme
wordpress
I'm building a site and the basic structure on most pages is as follows: <code> &lt;!-- content query --&gt; &lt;!-- recent posts preview query (paginated) --&gt; &lt;!-- related posts preview query (paginated) --&gt; </code> The paginated content is loading on the same page using jQuery, so just that specific section ...
Well, for anyone else looking to solve a similar problem, I found this post, and it led me in the right direction: http://wordpress.org/support/topic/pagination-on-singlephp-causing-301-redirect?replies=9. I added this snippet of code to my functions.php, and I can paginate in custom queries without issue on single.php...
Pagination for custom query on single.php
wordpress
I am looking for a good recommendation for a wordpress theme development book. i have some experience building themes, but I want to learn more, and have trouble reading or understanding the codex sometimes. I don't know that much php, so a php recommendation would also be nice. Thanks in advance.
I can recommend Digging into WordPress (it covers the whole WP dev) and Rockstar WordPress Designer (part 1 and 2), both are available in e-book/pdf format.
A good Wordpress theme development book recommendation
wordpress
I've been searching high and low for an answer. I simply want to remove the Alternate Text, Caption, Description and Link URL-fields from the uploader and gallery view. I seem that every thing else than this Media-thingy can be removed. Thanx for helping out:)
You can do this via a filter. Add the following to functions.php. You can also add your own fields this way... <code> // edit fields in media upload area add_filter('attachment_fields_to_edit', 'remove_media_upload_fields', 10000, 2); function remove_media_upload_fields( $form_fields, $post ) { // remove unnecessary fi...
Removing fields from the Media Uploader/Gallery
wordpress
Lets say I have this menu: <code> Top |___ Sub 1 |___ Sub Sub 1 |___ Sub Sub 2 |___ Sub Sub 3 |___ Sub Sub 4 |___ Sub 2 |___ Sub Sub 1 |___ Sub Sub 2 |___ Sub Sub 3 |___ Sub Sub 4 |___ Sub 3 |___ Sub Sub 1 |___ Sub Sub 2 |___ Sub Sub 3 |___ Sub Sub 4 |___ Sub 4 |___ Sub Sub 1 |___ Sub Sub 2 |___ Sub Sub 3 |___ Sub Sub ...
I have come up with my own solution but I'm not convinced it's the best. <code> $parents = array( $post-&gt;ID ); if( 0 != $post-&gt;post_parent ) { $parents = array_merge( $parents, get_post_ancestors( $post-&gt;ID ) ); } $child_of = end( $parents ); $args = array ( 'child_of' =&gt; $child_of, 'echo' =&gt; 0, 'title_l...
wp_list_pages() but only show children on the branch you are on
wordpress
I'm using this piece of code to generate Related Posts by looking at the tags of posts. The problem is I have use a tag named Featured in order for a post to show up in a slideshow. So posts are showing up as related because of that matching Featured tag, even though they are not alike at all. So is there an easy to to...
The <code> get_the_tags() </code> function returns an array of objects. So, you can step through the this array, and unset the object for the "Featured" tag, perhaps like so: <code> &lt;?php $tags = get_the_tags(); foreach ( $tags as $tag_key =&gt; $tag_object ) { if ( 'featured' == $tag_object-&gt;slug ) { unset( $tag...
Add exception for specific tag
wordpress
I use the following code to load subpages in a sidebar on all pages: <code> &lt;?php $children = wp_list_pages('title_li=&amp;child_of='.$post-&gt;ID.'&amp;echo=0&amp;depth=1'); if ($children) { ?&gt; &lt;ul id="three-menu"&gt; &lt;?php echo $children; ?&gt; &lt;/ul&gt; &lt;?php } ?&gt; </code> It works well on all pag...
possible code: <code> &lt;?php $children = wp_list_pages('title_li=&amp;child_of='.$post-&gt;ID.'&amp;echo=0&amp;depth=1'); if ($children) { ?&gt; &lt;ul id="three-menu"&gt; &lt;?php echo $children; ?&gt; &lt;/ul&gt; &lt;?php } //ends (if($children)// elseif($post-&gt;post_parent) { //if no children, try to get parent ...
Load parent pages when there are no child pages
wordpress
Over the years we've looked after a few Wordpress sites but never anything more than a bit of maintenance. We've never started from scratch in Wordpress or converted an existing site over to Wordpress. But our occasional brush with Wordpress has always been positive. So now we are thinking of converting an existing sit...
Structured, as you named it, data in WordPress is combination of following features: [custom] post type - more accurately described as content type, you can register custom instead of bending generic "post" post type; taxonomies - for organizing posts into groups (native "category" and "tag" are taxonomies); custom fie...
Migrating to Wordpress - but how will it do "structured" data?
wordpress
I'm trying to add a custom "Tweet this" button to my WordPress posts. I'm sticking to the official Twitter guidelines . Here is what I'm actually trying to pull of; I don't want the button, I want a custom look - for me it's only text . This is the code I use: <code> &lt;a href="https://twitter.com/share?url=&lt;?php e...
After sleeping over the problem I decided to the code and tried this: <code> &lt;a href="https://twitter.com/share?url=&amp;text=&lt;?php the_title(); ?&gt;: &lt;?php echo urlencode(get_permalink($post-&gt;ID)); ?&gt; &amp;via=username&amp;count=horizontal" class="custom-tweet-button"&gt;Tweet&lt;/a&gt; </code> All I c...
Permalink doesn't get displayed in Twitter button (Local WordPress problem?)
wordpress
Is it possible to include an image within the auto excerpt? So in the editor you have image then some text and once live it includes the image and not just the text?
Yes, you can do that, but you'll need to tweak the <code> &lt;?php the_excerpt(); ?&gt; </code> function. This is a good article on how to do that: http://aaronrussell.co.uk/legacy/improving-wordpress-the_excerpt/ To sum up the article in case it goes away, put this in your theme's functions.php file: <code> function i...
Include an image within auto the_excerpt?
wordpress
Could anyone help me finding which WP theme has been used in this site? http://www.laquilacittaaperta.it/ I only have found concerning a DM theme but I really haven't been able to find it anywhere thank you Mari0
It appears to be a modified version of DM's CircloSquero theme. DM doesn't seem to have it available anymore, but Theme Forest has it for download here .
which theme is this?
wordpress
in the plugins page, under each plugins' name usually there are buttons/links like "Deactivate | Edit | Settings". Recently on one of my sites the "Edit" (and "Settings") button has disappeared. I have just "Deactivate" or "Activate | Delete". My question is - what could cause this? I am logged in as an administrator, ...
Edit buttons display only when the necessary file permissions are acquired by PHP. http://core.trac.wordpress.org/browser/tags/3.3.1/wp-admin/includes/class-wp-plugins-list-table.php#L380 <code> is_writable(WP_PLUGIN_DIR . '/' . $plugin_file) </code> <code> current_user_can('edit_plugins') </code> will always return fa...
What would cause edit buttons for plugins to disappear?
wordpress
I have made a product page. Wich lists all products site.com/products. At the product page there is a navigation wich lists all the terms in the taxonomy 'kategori'. The taxonomy is set to hierarchical, so i can make parent terms. I list all the terms with: <code> &lt;div class="produkt_nav"&gt;&lt;h3&gt;&lt;a href="/p...
You can use wp_list_categories() where the <code> hierarchical </code> argument is set to true by default , something like this: <code> &lt;div class="produkt_nav"&gt;&lt;h3&gt;&lt;a href="/produkter/"&gt;Produkter&lt;/a&gt;&lt;/h3&gt; &lt;ul&gt; &lt;?php wp_list_categories('taxonomy' =&gt; 'kategori'); ?&gt; &lt;/ul&g...
How to check if a term is parent to another?
wordpress
I'm new to wordpress plugin development, I read the whole documentation this afternoon http://codex.wordpress.org/Plugin_API/Filter_Reference , I tried to write some code, like this in plugin file: <code> add_filter('the_title', 'my_own_function', 10, 2); </code> Function is: <code> function my_own_function($title, $po...
There's only one answer: You always go and read the source code . There are some online tools that help you with this, specifically Adam Brown's Hooks List , which contains links to the source code where you can read what arguments filters and actions take. Be aware that a single filter can have variable amounts of arg...
Couldn't find a documentation for a filter API in plugin development
wordpress