Quantcast
Channel: WordPress › Support » Forum: Hacks - Recent Topics
Viewing all 8245 articles
Browse latest View live

TLCJohn on "How to remove "Archives for" from the page title"

$
0
0

Hi there All

Please can someone guide me in the right direction - I have been looking all over the place via Google, but I am getting nowhere. And the wife tells me "Google is your friend" :( Not today!

I am trying to remove the words "Archives for" from the page title on the following web site page http://www.tlc-online.co.uk/website-design/

I would like to put some php code in the child theme's - functions.php to stop this from happening, but I am lost as how to write it. If I make the changes to the themes files, when I update the theme I will loos the php changes and the problem will come back again.

The site has been built in Ultimatum framework.

Thanks in advance for any help you can give.

Kind regards
John


WebTechGlobal on "postbox-container-3"

$
0
0

Sorry had to remove a comment. I went and commented on the wrong post.

marcelotorres on "Customize native gallery search"

$
0
0

Hi,

I need to customize the search of the gallery. I've got the script for this, is already working on wp-admin/upload.php, but I need to also work in the search for media gallery. Anyone have any idea to solve this?

Follows the code I'm using:

function atom_search_where($where, $query){
	global $wpdb;

    //if we are not on admin or the current search is not on attachment return
    if(!is_admin() || (!isset($query->query['post_type']) || $query->query['post_type'] != 'attachment'))
        return $where;

    //  if current query is the main query and a search...
    if( is_main_query() && is_search() )
    {
        //  explictly search post_tag taxonomies
        $where .= "OR (post_type = 'attachment' AND t.name LIKE '%".get_search_query()."%')";

    }

    return $where;

}

function atom_search_join( $join, $query){

	global $wpdb;

    //if we are not on admin or the current search is not on attachment return
    if(!is_admin() || (!isset($query->query['post_type']) || $query->query['post_type'] != 'attachment'))
        return $join;

    //  if current query is the main query and a search...
    if( is_main_query() && is_search() )
    {
        $join .= "INNER JOIN {$wpdb->term_relationships} tr ON {$wpdb->posts}.ID = tr.object_id INNER JOIN {$wpdb->term_taxonomy} tt ON tt.term_taxonomy_id=tr.term_taxonomy_id INNER JOIN {$wpdb->terms} t ON t.term_id = tt.term_id";
    }

    return $join;
}

add_filter('posts_where','atom_search_where', 10, 2 );
add_filter('posts_join', 'atom_search_join', 10, 2 );

Sorry my english

WebTechGlobal on "postbox On Multiple [views] in a single [page]"

$
0
0

If you look at the TablePress plugin which makes use of postboxes. You will see that the menu of tabs is the same menu as in the Wordpress admin menu. I want to improve on this and I'm almost done but I need a little help now please.

My CSV 2 POST plugin has a menu of tabs per page. So I have five pages and on each page is any number of tabs/views. Each view currently has it's own post boxes, they can be moved, docked and even hidden as Screen Options are in use.

But even though the ID's of each postbox are unique (checked source many times). There is always a box or sometimes two that seem to share settings between views. Or settings are being overwritten when the box on one view is moved causing the box on the other view to go to default place.

The Screen Options tab will cause the boxes on view A to be displayed if all the boxes on view B are hidden. Again ID values are all unique so I'm just stuck.

There are 2 class and many methods involved so I'm hoping someone can just tell me if Wordpress has limitations and these post boxes can only be used on a single page view or is there a common value that I might be missing causing this?

Thanks for any help on this. If I can get it working it will make any plugin I create a lot more enjoyable to use and far more integrated with WP.

sh3nka7a on "Querying most commented in the last week"

$
0
0

Hello, im trying to show the most commented 5 post in the last week, here is my code
$args = array(
'post_type' => 'post',
'post_status' => 'publish',
'orderby' => 'comment_count',

'order' => 'DESC',
'date_query' => array(
array(
'year' => date('Y'),
'week' => date('W'),
),
),
'posts_per_page'=> 5,
);

$the_query = new WP_Query($args);

while ( $the_query->have_posts()) : $the_query->the_post(); ?>
That returns me over 300 posts, tho they are ordered by comment cound, how to fix that

xymalf on "Amazon API"

$
0
0
$amazon = new Zend_Service_Amazon('AMAZON_API_KEY', 'US', 'AMAZON_SECRET_KEY');
$results = $amazon->itemSearch(array(
    'SearchIndex'   => 'Books',
    'Keywords'      => 'php',
    'ResponseGroup' => 'Small,ItemAttributes,Images,SalesRank,Reviews,' .
                       'EditorialReview,Similarities,ListmaniaLists'
    ));
foreach ($results as $result) {
    echo $result->Title . '';

[Moderator Note: Please post code & markup between backticks or use the code button. Your posted code may now have been permanently damaged by the forum's parser.]

The Amazon Zend Framework is as above but what URL do you have to call before the framework? Also how do you input all your form data [fields] into the script?

anne3nidad on "Integration"

$
0
0

Hi,

Our team is planning on building integration components. We'd like to know what you guys need, like do you need to integrate user CRUD, some Entity CRUD or what.

Your feedback is very much appreciated.

Thanks!

SeacatDesigns on "Plugin jQuery and CSS Overload?"

$
0
0

Honestly, I don't know if this is the right section to ask this. Today I ran into a couple plugin conflicts that made me start thinking about this. I wound up having to do kind of a hack where the plugin files only appear in the head of the home page because it was causing display issues with other plugins. But to the point... loading a jquery script, plus all of the wordpress plugins .js and .css files, they all load in the head whether or not the wordpress or jquery plugin is used on that page, and I'm wondering if this is bad practice as far as site speed goes, or does minimizing them all reduce file size enough that its not an issue? Some appear to be minimized and some aren't, mainly the CSS files usually arent so that you can customize them.

So what do you guys usually do about this? Is there a need for the plugin files to appear only on the pages theyre used? Do you minimize everything once the site is complete? Is there a plugin that manages this?


asidre on "WP_Query ignoring the posts_per_page argument."

$
0
0

I have a custom post type which i want to use pagination
hence i have the code set up like below:

global $wp_query;
$paged = ( get_query_var('paged') ) ? get_query_var('paged') : 1;
$args = array(
	'post_type' => 'cpt',
	'posts_per_page ' => 5,
	'offset' => 0,
	'orderby' => 'title',
	'order' => 'ASC',
	'paged' => $paged,
	'post_status' => 'publish'
);

$wp_query =new WP_Query($args);
print_r($wp_query->query_vars);

then the loop:

<?php if($wp_query->have_posts()) : ?>
<?php while($wp_query->have_posts() ): $wp_query->the_post(); ?>
<?php the_title(); ?>
<?php endwhile; ?>
<?php endif; ?>

Result of the query_vars:

Array ( [post_type] => cpt [posts_per_page ] => 5 [offset] => 0 [orderby] => title [order] => ASC [paged] => 1 [post_status] => publish [error] => [m] => [p] => 0 [post_parent] => [subpost] => [subpost_id] => [attachment] => [attachment_id] => 0 [name] => [static] => [pagename] => [page_id] => 0 [second] => [minute] => [hour] => [day] => 0 [monthnum] => 0 [year] => 0 [w] => 0 [category_name] => [tag] => [cat] => [tag_id] => [author] => [author_name] => [feed] => [tb] => [comments_popup] => [meta_key] => [meta_value] => [preview] => [s] => [sentence] => [fields] => [menu_order] => [category__in] => Array ( ) [category__not_in] => Array ( ) [category__and] => Array ( ) [post__in] => Array ( ) [post__not_in] => Array ( ) [tag__in] => Array ( ) [tag__not_in] => Array ( ) [tag__and] => Array ( ) [tag_slug__in] => Array ( ) [tag_slug__and] => Array ( ) [post_parent__in] => Array ( ) [post_parent__not_in] => Array ( ) [author__in] => Array ( ) [author__not_in] => Array ( ) [ignore_sticky_posts] => [suppress_filters] => [cache_results] => 1 [update_post_term_cache] => 1 [update_post_meta_cache] => 1 [posts_per_page] => 10 [nopaging] => [comments_per_page] => 50 [no_found_rows] => )

ultimately I want to properly get the max_num_pages variable, however this is not possible because it brings 10 posts by default and I cannot control this value.
Somehow it seems to be overriding the posts_per_page argument before the sql executes.

If I do
$posts = get_posts($args);
instead of
$wp_query = new WP_Query($args);
$posts = $wp_query->posts

it returns 5 posts correctly. But there is a dilemma which i cannot get the max_num_pages value from it.

Thanks in advance for any tips.

robbiehenry on "Need Help with a Survey"

$
0
0

I have this site that I have taken over as the webmaster. For the homepage book an appointment form, I need to add a survey question upon submit of which location.

Refer to this dev site...
http://isis.zarumedia.com/
[ password redacted ]

Right now I have the added the last survey question of Which Fertility Location Do you want to visit

The issue that I am having is I am unable to figure out what variable is holding this last value and How I can take this variable and email it off with all of the other inputted data.

All help is appreciated.

[ 1,040 lines of PHP code redacted. That is too much to post here, please use pastebin.com instead. ]

jasperg on "Create a list of posts with topic heddings"

$
0
0

I hope this question makes sense.

I am designing a page for a second hand bookshop, It will be linked to in a weekly email newsletter containing that weeks books added to the store, so subscribers can keep updated on rare books that are available.

At the moment this is sent out as a pdf organised in broad categories. eg history, archaeology, antiquarian etc. With about 50-70 books on it.

The website I am building use a custom taxonomy to allow browsing of book categories.

For my weekly updates page I really need to have all books listed on one page with a heading for each category.

So using;

$args = array(
	'date_query' => array(
		array(
			'column' => 'post_date_gmt',
			'after' => 'Monday 1 week ago',
		),
	),
	'posts_per_page' => -1,
	'post_type' => 'product',
);

writing a loop that gets all books added after last monday if fine. But after reading http://wordpress.stackexchange.com/a/14309/53985 it seems that taxonomies are not a good way of listing posts like this. It seems I can do it but will have to;

  1. Get the top level taxonomies.
  2. for each taxonomy find all books added 'after' => 'Monday 1 week ago'
  3. If there are any new books in that taxonomy publish the title and the list of books.
  4. repeat for all taxonomies.

I am not sure exactly how to do this, and I am even less sure it is a good idea. Seeing as the list will go out to subscribers, it will probably be the most visited page on the site and peak the usage of the website as a whole each day the email is sent out (as everyone checks for new arrivals on the same day) and using complicated multiple loops may slow the page down???

So my question. Is this a good way of doing it? Will it be ok as there will only be ~50 posts to go through each time? or should I be looking at some other method?

Maybe I should add a custom meta field "Topic" to each book listing that is the same as each top level taxonomy and use this field to sort my book list? Would this be an improvement? Would that make it faster / easier? If I do this, and order the books by my Topic field. Would it be possible echo out the topic each time a new category starts as a title for each set of books, or would I have to echo the topic in each post, so people can see what category it belongs to?

Thank you for taking the time to read this. I know it is a rather complicated question, and I really appreciate any advice anyone can give me.

totland on "How to duplicate Vimeo shortcode"

$
0
0

I use the standard Vimeo shortcode for embedding Vimeo videos (http://en.support.wordpress.com/videos/vimeo/), and really like the responsive markup it produces.

I also have my own video player that I would like to embed in the EXCACT same way, by simple pasting http://www.mydomain/v/12345 in the text editor (12345 is the id of the video). Should parse out the id, insert an iframe with a slightly different url (say http://www.mydomain/v/player?id=12345) etc. Basically the same stuff that happens with the Vimeo shortcode.

Do I have to edit core files, and in that case which and what, or could I add something to my functions.php file?

All help is much appreciated!

HarroH on "Hack wp_head"

$
0
0

Hi All,

I'm trying to affect the wp_head to change to that one of another page. However, the normal workaround of wp_query is not working here. Any suggestions how I can get the wp_head of another page by its slug or ID?

I have this now:

$page_for_head = get_page_by_path( $redirect );

$temp_query = $wp_query;

$page_args = array(
	'post_type'		=>	'page',
	'page_id'		=> 	$page_for_head->ID
);

$wp_query = new WP_Query( $page_args );

while ( have_posts() ) : the_post();

	wp_head();

endwhile;

$wp_query = $temp_query;

But this just returns the wp_head of the main page. Thanks in advance.

jackovok on "How can I disable the default jQuery loading of WordPress 3.9.1?"

$
0
0

Hi

I don't wish to use jquery 1.11 but it comes default in WordPress 3.9.1, along with jQuery Migrate.
I dont want them. How can I get rid of that?

I dont want to see the following lines:

<script type='text/javascript' src='http://172.17.15.172/iswp/wp-includes/js/jquery/jquery.js?ver=1.11.0'></script>
<script type='text/javascript' src='http://172.17.15.172/iswp/wp-includes/js/jquery/jquery-migrate.min.js?ver=1.2.1'></script>

Functions.php:

// enqueue javascript
if( !function_exists( "theme_js" ) ) {
  function theme_js(){

    wp_register_script( 'jquery',
      get_template_directory_uri() . '/library/js/jquery-1.8.3.min.js',
      array('jquery'), '1.2' );

    wp_register_script( 'easing',
      get_template_directory_uri() . '/library/js/jquery.easing.1.3.js',
      array('jquery'),
      '1.2' );

    wp_register_script( 'transit',
      get_template_directory_uri() . '/library/js/jquery.transit.min.js',
      array('jquery'),
      '1.2' );

    wp_register_script( 'appear',
      get_template_directory_uri() . '/library/js/jquery.appear.js',
      array('jquery'),
      '1.2' );

    wp_register_script( 'mousewheel',
      get_template_directory_uri() . '/library/js/jquery.mousewheel.min.js',
      array('jquery'),
      '1.2' );

    wp_register_script( 'mixitup',
      get_template_directory_uri() . '/library/js/jquery.mixitup.js',
      array('jquery'),
      '1.2' );

    wp_register_script( 'scripts',
      get_template_directory_uri() . '/library/js/scripts.js',
      array('jquery'),
      '1.2' );

    wp_enqueue_script('jquery');
    wp_enqueue_script('easing');
    wp_enqueue_script('transit');
    wp_enqueue_script('appear');
    wp_enqueue_script('mousewheel');
    wp_enqueue_script('mixitup');
    wp_enqueue_script('scripts');

  }
}
add_action( 'wp_enqueue_scripts', 'theme_js' );

davidmaxwaterman on "projects disappeared from all page"

$
0
0

Hi,

Our design department have tasked me with making some changes to their wordpress site - I've not touched it before, but am somewhat familiar with the technologies involved. We're using wp 3.9.1 with the Divi theme and the searchandfilter plugin.

The problem is that I've added some custom taxonomies and now all the projects have disappeared from the 'fullwidth portfolio' part of the 'all' page. I'm hoping someone can tell me what I need to fix it.

I am using the Divi theme and added the custom taxonomies to :

wordpress/wp-content/themes/Divi/functions.php
function et_pb_register_posttypes

I pretty much copied the existing code there for the Categories, but changed it to 'Collections' and also duplicated it for the other taxonomies I want. This made the relevant bits show up in the admin panel for adding/editing projects, and I've had people create some projects and assign some of the taxonomies (I read somewhere that terms need to be assigned before they become active, or something - though I'm probably a bit confused there).

Unfortunately, all the projects then disappeared (they were previously listed when nothing was selected in searchandfilter).

I have noticed that get_categories() on line 2748 of et_pagebuild/et_pagebuild.php returns nothing useful - an array with one 'uncategorized' element in it, while if I actually specify 'taxonomy=project_collection' then I do get the corresponding projects returned.

I also notice that, in the page builder for the 'all' page, there's a 'Fullwidth Portfolio Module Settings' panel with a place to enter 'Include Categories' which has two checkboxes that have no text next to them - that seems to suggest I've not 'done enough' somehow. I would expect one for each of the taxonomies I've added (?) and I should include all of them.

I kind of feel like I'm 'close', but I'm confusing something...like taxonomies and terms.

Can anyone point me in the right direction?

Thanks!

Max.


themarcthomas on "Multiple groups of grandchildren break WordPress Walker class"

$
0
0

'm currently integrating Foundation 5's accordion and WordPress via a walker class. The original was made by AWshout here: https://gist.github.com/awshout/5375157

The side menu on the left is an accordion thing which is working fine until you add a third level of child page. I currently have a Walker class (not sure if you’re familiar with them but they allow WordPress menus to be styled better.)

class Section_Nav_Walker extends Walker_Nav_Menu {

    /**
     * @see Walker_Nav_Menu::start_lvl()
     *
     * @param string $output Passed by reference. Used to append additional content.
     * @param int $depth Depth of page. Used for padding.
    */
    function start_lvl( &$output, $depth = 0, $args = array() ) {
        $output .= '<div class="content" data-section-content><ul class="side-nav">';
    }   

    /**
     * @see Walker::end_lvl()
     *
     * @param string $output Passed by reference. Used to append additional content.
     * @param int $depth Depth of page. Used for padding.
     */
    function end_lvl( &$output, $depth = 0, $args = array() ) {
        // close .side-nav .content and .section
        $output .= '</ul></div></div>';
    }

    /**
     * @see Walker_Nav_Menu::start_el()
     *
     * @param string $output Passed by reference. Used to append additional content.
     * @param object $item Menu item data object.
     * @param int $depth Depth of menu item. Used for padding.
     * @param object $args
     */
    function start_el( &$output, $item, $depth = 0, $args = array(), $id = 0 ) {

        $class_names = $value = '';

    $classes = empty( $item->classes ) ? array() : (array) $item->classes;
    $classes[] = 'menu-item-' . $item->ID;
    $classes[] = ( $depth == 0 ) ? 'title' : '';
    $classes[] = ( $args->has_children ) ? 'has-dropdown' : '';
    $classes[] = ( in_array('current-menu-item', $classes) && !in_array('active', $classes) ) ? 'active' : '';

        $class_names = join( ' ', apply_filters( 'nav_menu_css_class', array_filter( $classes ), $item, $args ) );
        $class_names = $class_names ? ' class="' . esc_attr( $class_names ) . '"' : '';

        $id = apply_filters( 'nav_menu_item_id', 'menu-item-'. $item->ID, $item, $args );
        $id = $id ? ' id="' . esc_attr( $id ) . '"' : '';

    // create sections
    $section_class = ( $depth == 0 && in_array('active', $classes) ) ? 'section active' : 'section';
    $section_class = ( $depth <= 1 && in_array('active', $classes) ) ? 'section active' : 'section';
    // $section_class = 'section';
    $output .= ( $depth == 0 ) ? '<div class="' . $section_class . '">' : '';

    // if top level use p.title else use li in dropdown
        $output .= ( $depth == 0 ) ? '<p data-section-title' . $id . $value . $class_names .'>' : '<li' . $id . $value . $class_names .'>';

        $attributes  = !empty( $item->attr_title ) ? ' title="' . esc_attr( $item->attr_title ) . '"' : '';
        $attributes .= !empty( $item->target ) ? ' target="' . esc_attr( $item->target ) . '"' : '';
        $attributes .= !empty( $item->xfn ) ? ' rel="' . esc_attr( $item->xfn ) . '"' : '';

    // if top level and has dropdown do not use url
    if ( $depth == 0 && $args->has_children ) {
        $attributes .= ' href="#"';
    }
    // else use url
    elseif ( !empty( $item->url ) ) {
        $attributes .= ' href="' . esc_attr( $item->url ) . '"';
    }

        $item_output = $args->before;
        $item_output .= '<a'. $attributes .'>';
        $item_output .= $args->link_before . apply_filters( 'the_title', $item->title, $item->ID ) . $args->link_after;
        $item_output .= '</a>';
        $item_output .= $args->after;

    // close .section if there is no dropdown
    $item_output .= ( $depth == 0 && !$args->has_children ) ? '</div>' : '';

        $output .= apply_filters( 'walker_nav_menu_start_el', $item_output, $item, $depth, $args );
      }

    /**
     * @see Walker::end_el()
     *
     * @param string $output Passed by reference. Used to append additional content.
     * @param object $item Page data object. Not used.
     * @param int $depth Depth of page. Not Used.
     */
    function end_el( &$output, $item, $depth = 0, $args = array() ) {
        if ( $depth > 0 ) {
            $output .= "</li>";
        }
    }

    /**
     * Traverse elements to create list from elements.
     *
     * Display one element if the element doesn't have any children otherwise,
     * display the element and its children. Will only traverse up to the max
     * depth and no ignore elements under that depth.
     *
     * This method shouldn't be called directly, use the walk() method instead.
     *
     * @see Walker::start_el()
     * @since 2.5.0
     *
     * @param object $element Data object
     * @param array $children_elements List of elements to continue traversing.
     * @param int $max_depth Max depth to traverse.
     * @param int $depth Depth of current element.
     * @param array $args
     * @param string $output Passed by reference. Used to append additional content.
     * @return null Null on failure with no changes to parameters.
     */

    function display_element( $element, &$children_elements, $max_depth, $depth, $args, &$output ) {
        if ( !$element ) {
            return;
        }

        $id_field = $this->db_fields['id'];

        //display this element
        if ( is_object( $args[0] ) ) {
           $args[0]->has_children = ! empty( $children_elements[$element->$id_field] );
        }

        parent::display_element($element, $children_elements, $max_depth, $depth, $args, $output);
    }
}

The problem is that there’s something in that file that can’t work out how to cope with more than one set of grandchildren in a list and that’s when the menu breaks. What I need ideally is something that can cope with a menu like this:

  • Parent
    • Child
      • Grandchild
    • Child
      • Grandchild

Any ideas what I might need to change in that file? Have tried a bunch of stuff but every time I just end up reformatting bits – I think that I need to add something that navigates back up a level before closing the list.

I’d really appreciate a hand, Marc

xymalf on "Wordpress plugin - Amazon products"

$
0
0

My first question is are variables used in forms Global and can you get their values with the GET_$ command?

My second question is how do I call the amazon_api.php file and then save the results in a table so they can be posted.

I would also like to add a buy now with embedded affiliateid - is all this possible?

shazdeh on "urlencode_deep function and wrong URL"

$
0
0

This seems like a bug with urlencode_deep function:

print_r( urlencode_deep( array( 'width' => '80%' ) ) );

The result of that is:

Array
(
    [width] => 80%25
)

Notice the extra 25 in the parameter.

The why:
I'm using add_query_arg function which in turn uses urlencode_deep function on all the parameters from the URI passed to the function. The problem is urlencode_deep function messes up one of parameters sent, so this:

http://site.com/?width=80%

Which is valid URL, inside the add_query_arg function becomes:

Array
(
    [width] => 80%25
)

Any idea why?

rajika4ever on "How to get Data To Wordpress Tinemce listbox from database"

$
0
0

i am developing a WordPress shot-code plugin. i have added a listbox in tinymcs and i need to load data to tinymcs from wordpress database. i can not hard code the listbox values since all my shortcodes values are saved in wordpress database.

is there any possible way to do this ?

erpatton on "Active Directory - Grant/Restrict Access to Content"

$
0
0

Hello WordPress gurus! We have a client who is wanting to be able to restrict/grant access to pages on a WordPress site for certain groups in their Active Directory. Do you know of any plugins that already do this or a combination that can be used as a base to piece together functionality for this? I've worked with WordPress a few times before, but I mostly get .NET and Umbraco project requests from clients, so I'm not as familiar with what can be done in WordPress.

Viewing all 8245 articles
Browse latest View live




Latest Images