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

prasanjitkayako on "jQuery error"


Tunjaness on "Displaying post according to category of custom post type"

$
0
0

Hi Guys. Been through pretty much the entire internet trying to find a solution to this issue hanging over me and I sincerely apologise if this has been asked before. I have a parent page that displays 3 custom post types namely CDJ's, Sound and DJ Mixers. These post types should lead a user to respective areas. For example when I click on DJ Mixers, it should take me to a page containing all custom post types that fall under the DJ Mixers category. I have tried using post types to display the content and it displays all custom post types that fall under DJ's custom post types. I have been using one template to display all three custom post types. I need this to work like, click on either CDJ's, DJ Mixers and Sound and then get directed to the respective site area.

This is what I have thus far on the page that will display the section:

<?php

                            // Get data
                            $cat_id = get_cat_ID($currentcat);
                            $args = array(
                                'cat' => $cat_id,
                                'post_type' => 'game-species',
                                'post_status' => 'publish',
                                  'posts_per_page' => -1,
                                  'caller_get_posts'=> 1
                            );
                            $loop = new WP_Query( $args );
                            $count = 0;
                            $liFlag = 0;
                            $flagCount = 0;
                            $length = count($loop->posts);
                            $template = '';

                            while ( $loop->have_posts() ) : $loop->the_post();
                                $count++;

                                if ( $count % 9 == 1) {
                                    echo '<li>';
                                    $flagCount++;

                                    if ($flagCount === 3) {
                                        $liFlag = 1;
                                    }
                                }

                                $tim = get_template_directory_uri().'/library/timthumb.php?src=';
                                $thumb = get_field('game_image');
                                $img = $tim.$thumb.'&w=300&h=300';

                                ob_start(); ?>

                                <section class="eight col promo">
                                    <img src="<?php echo $img; ?>" alt=""/>
                                    <section class="content">
                                        <h1><?php echo truncate( 3, get_the_title() ) ?></h1>
                                        <p>
                                            <?php echo truncate( 3, get_field('game_description') ) ?>
                                        </p>
                                        <a class="readmoreBtn" href="<?php echo get_permalink(); ?>"></a>
                                    </section>
                                    <div class="hover"><span class="icon"></span></div>
                                </section>
                                <?php
                                if ( $liFlag === 1 || $length+1 === $count ) {
                                    echo '</li>';
                                    $liFlag = 0;
                                };
                                $template .= ob_get_clean();
                            endwhile;

                            echo $template;

                            ?>

legion_x on "Get normal an custom posts in one stream"

$
0
0

Hello,

I would like to get certain normal posts together with certain custom posts. Currently i get them via:

<?php
                    $args = array(
                        'category_name' => 'work, travel',
                        'posts_per_page' => 100
                    );
                $query = new WP_Query($args);
                ?>

AND

<?php
                $args = array(
                    'post_type' => array(LEXICON, EVENT),
                );
                $custom_query = new WP_Query($args);
                ?>

seperately. What is the best way to get one stream with the categories work, travel as well as the categories EVENT, LEXICON merged together?

Thank you in advance!

Madrid90 on "Website not responsive on large screens"

$
0
0

Hi guys,

I'm having a problem with a website I'm helping out with. It works perfectly on screens smaller than 320 pixels, like the iPhone 4, but not on larger screens.

You can see the difference on this link:

http://www.responsinator.com/?url=www.elmadrid.dk

I have tried using several different media queries to fix the width problem, but nothing happens...

Any suggestions? Thanks in advance.

neptuna on "JQuery Accordion wtih posts"

$
0
0

Hi,

I am new to Wordpress and I don't know any programming language. I am trying to add accordion effect to my posts on category pages.

I add the following code:

function my_scripts_method() {
    if ( !is_admin() ) {
        wp_enqueue_script('jquery-ui-accordion');
        wp_enqueue_script(
            'custom-accordion',
        get_template_directory_uri() . '/js/accordion.js',
        array('jquery')
    );
    }
}
add_action('wp_enqueue_scripts', 'my_scripts_method');

into the function.php and then create a .js file

jQuery(document).ready(function($) {
    $( "#accordion" ).accordion({
        collapsible: true,
                active: false
    });
});

then I edit the post.php

<div class="wrap">

		<?php if ( is_single( get_the_ID() ) ) : // If viewing a single post. ?>

			<header class="entry-header">

				<h1 <?php hybrid_attr( 'entry-title' ); ?>><?php single_post_title(); ?></h1>

				<div class="entry-byline">
					<?php hybrid_post_author( array( 'text' => __( 'Written by %s', 'saga' ) ) ); ?>
				</div><!-- .entry-byline -->

			</header><!-- .entry-header -->

			<div <?php hybrid_attr( 'entry-content' ); ?>>
				<?php the_content(); ?>
				<?php wp_link_pages(); ?>
			</div><!-- .entry-content -->

			<footer class="entry-footer">
				<?php hybrid_post_terms( array( 'taxonomy' => 'category' ) ); ?>
				<?php hybrid_post_terms( array( 'taxonomy' => 'post_tag', 'before' => sprintf( '<span class="sep">%s</span> ', _x( '&middot;', 'post meta separator', 'saga' ) ) ) ); ?>
			</footer><!-- .entry-footer -->

		<?php else : // If not viewing a single post. ?>

			<header class="entry-header">

				<?php the_title( '<h2 ' . hybrid_get_attr( 'entry-title' ) . '><a href="' . get_permalink() . '" rel="bookmark" itemprop="url">', '</a></h2>' ); ?>

				<div class="entry-byline">
					<time <?php hybrid_attr( 'entry-published' ); ?>><?php echo get_the_date(); ?></time>
					<span class="sep"><?php _ex( '&middot;', 'post meta separator', 'saga' ); ?></span>
					<?php comments_popup_link( false, false, false, 'comments-link' ); ?>
				</div><!-- .entry-byline -->

			</header><!-- .entry-header -->

			<div <?php hybrid_attr( 'entry-summary' ); ?>>
				<?php the_excerpt(); ?>
			</div><!-- .entry-summary -->

		<?php endif; // End single post check. ?>

	</div><!-- .wrap -->

</article><!-- .entry -->

I think that the post.php code checks if there is single post or not and if it is single it shows the full text and if there are multiple posts it shows them partially.

I want it to show the multiple posts with accordion effect so I add

<div id="accordion"> code </div> just after <?php else : // If not viewing a single post. ?>

The problem is that it applies the accordion effect only the first post and the rest are not affected. I tried to place the div part to different sections but no luck. I can not get into the loop.
If I add the <div id="accordion"> code </div> to whole post.php it adds the accordion to the single posts as well but still only to the first post.

I am not a native so I hope I could express myself clearly.
Any help would be appreciated.

mintmind on "How can I set different comments_per_page values for each pages?"

$
0
0

I am currently setting comments_per_page value for 30.
But I want to show 20 comments only for the first page.
Please teach me how to manage this.

garywiz on ""Default Image to Use" does not work as documented"

$
0
0

The settings page says that "Default Image to Use" should be ... "Full URL including http:// to the default image to use if your posts/pages don't have a featured image or an image in the content.

However, that is NOT the way it works. The default image is ADDED to the images for the page, so when you have a featured image, there are two og:image metatags, not one. Facebook (and others) therefore often choose the wrong image.

I looked at the code and confirmed this, and fixed it as per below, which I believe is what is intended and desirable. Here is the section that selects images after I changed it:

// Only find images if it isn't the homepage and the fallback isn't being forced
 if ( ! is_home() && $options['wpfbogp_force_fallback'] != 1 ) {
	 // Find featured thumbnail of the current post/page
	 if ( function_exists( 'has_post_thumbnail' ) && has_post_thumbnail( $post->ID ) ) {
		 $thumbnail_src = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'large' );
		 $link = $thumbnail_src[0];
		 if ( ! preg_match( '/^https?:\/\//', $link ) ) {
			 // Remove any starting slash with ltrim() and add one to the end of site_url()
			 $link = site_url( '/' ) . ltrim( $link, '/' );
		 }
		 $wpfbogp_images[] = $link; // Add to images array
	 }

	 if ( wpfbogp_find_images() !== false && is_singular() ) { // Use our function to find post/page images
		 $wpfbogp_images = array_merge( $wpfbogp_images, wpfbogp_find_images() ); // Returns an array already, so merge into existing
	 }
 }

 // Make sure there were images passed as an array and loop through/output each
 if ( ! empty( $wpfbogp_images ) && is_array( $wpfbogp_images ) && $options['wpfbogp_force_fallback'] != 1) {
	 foreach ( $wpfbogp_images as $image ) {
		 echo '<meta property="og:image" content="' . esc_url( apply_filters( 'wpfbogp_image', $image ) ) . '"/>' . "\n";
	 }
 } elseif ( isset( $options['wpfbogp_fallback_img'] ) && $options['wpfbogp_fallback_img'] != '') {
	 echo '<meta property="og:image" content="' . esc_url( apply_filters( 'wpfbogp_image', $options['wpfbogp_fallback_img'] ) ) . '"/>' . "\n";
 } else {
	 // No images were outputted because they have no default image (at the very least)
	 echo "<!-- There is not an image here as you haven't set a default image in the plugin settings! -->\n";
 }

Jack Holloway on "Active link under every image in concrete category of my blog"

$
0
0

My blog contains about 1000 images, each article features about 10 images. I wanted to add an active active one link (www.google.com for instance) after each image on my blog in every post and category. I made it in functions.php by inserting such thing:

add_filter('the_content', 'superlink');
function superlink($content){
$url = 'google.com';
$content = preg_replace ('|<img.*?>|iu', '$0'.$url, $content);
return $content;
}

It works properly. But the thing is, I want to make this link appearing in only one category, so I made up this one:

add_filter('the_content', 'superlink');
function superlink($content){
if ( is_single() && in_category('1234'){
$url = 'google.com';
$content = preg_replace ('|<img.*?>|iu', '$0'.$url, $content);
}
return $content;
}

...it doesn't work. Where I have made an error? Hope you can help me out.

Best,

Jack


weezieb on "Deleted users in phpMyadmin but they're not deleted in dashboard"

$
0
0

I recently updated a site I hadn't been editing in a while. It had accumulated 37,000+ users- mostly spam. Because it was a newly updated site we decided to delete all of the subscribers and only keep the administrators and authors. I manually deleted the 37,000+ subscribers in phpMyAdmin. They no longer show up in the users>subscribers- it says no subscribers found. But in the top bar it still shows them in parenthesis by subscribers. And I have a newsletter plugin that wants me to upgrade because of this large number. How can I get that to the correct new subscriber number?

mahowswp on "How to use implement plugin output in regular wordpress search"

$
0
0

Hi everyone,

I am a newbie in developing wordpress plugins. I indeed created successfully a new plugin but I am now wondering how to integrate the plugin output in wordpress search.
There are some tutorials but all of them do not reflect my development case:
I do not use the regular wordpress tables for my plugin. I am using own tables in the wordpress database. That is why I do not found the answer on how to implement plugin outputs in regular wordpress search.

Can you help?

Greetz
Maho

TerrellAnderson on "How to add div blocks after certain set of post?"

$
0
0

I am using a special loop. A loop that allows me to break the post down into different styles. The first post is styled a certain way, the next 4 a certain way and so on. Below is the code i use for the post.

<?php if (have_posts()) : ?>
<?php $count = 0; ?>
<?php while (have_posts()) : the_post(); ?>
<?php $count++; ?>
<!--First Post -->
<?php elseif ($count <= 1) : ?>
<-- First Post Style & Content -->

<!--Next Four Post -->
<?php elseif ($count <= 5) : ?>
<-- Next Four Post Style & Content -->

<!--Next Six Post -->
<?php elseif ($count <= 10) : ?>
<!--Next Six Post Style & Content -->

<?php endif; ?>
<?php endwhile; ?>
<php else : ?>
<?php endif; ?>

Now, my question is. How do I break the loop to add a special div after the first five post and continue the loop after the special div? I'm also going to want to add another special div after the next six post, each special div will have different content.

The first Post has the align left css so that the next four post will align next to it. If you take a look at the photo below, the large gray area is what I'm trying to accomplish.

http://i.stack.imgur.com/jlekz.png

simes on "list posts alphabetically in tag archive"

$
0
0

I am trying to have my archive page for tags deliver an alphabetized list of posts. I am using code suggested elsewhere in these pages thus:

function wpsf_orderby( $query ) {
    if ( is_admin() || ! $query->is_main_query() )
        return;
 // do conditional checks here and return on false.?

    if ( is_category( ) ) {
	remove_action( 'pre_get_posts', __FUNCTION__ );
	add_filter( 'posts_orderby', function() { return ' post_title ASC'; } );
	}
}

add_action( 'pre_get_posts', 'wpsf_orderby' );

But I keep getting the error

Fatal error: Call to a member function is_main_query() on a non-object
relating to the line if ( is_admin() || ! $query->is_main_query() )

Any clues? I have a parent category used in the code above, plus child categories and I also have tags assigned to each post, some of which are the same for different posts. I am using a child theme based on twentyfourteen with this code added into my functions.php file with a call to the function in tag.php, also in the child theme folder.

Naisai on "Cannot delete double profile fields! (BuddyPress)"

$
0
0

Hi!

I use buddypress and needed a country list for my sign-up form. I found this code on the net (see below) that fixed the problem, it created a "country field". This meaning under User/ Profile field/Primary field . Once i edited the "country field" a new identical field showed up. They dont have a delete button and now I cannot remove any of the fields.

I have tried:
(1) Deleting the code
(2) Deleting buddypress pluging incl. files. And then reInstall the plugin.

Thank you for any feedback. I know nothing about codes.
-------------------------------------------------------------------------------------------------

/*
If you are using BP 2.1+, this will insert a Country selectbox.
Add the function to bp-custom.php and then visit .../wp-admin/users.php?page=bp-profile-setup
*/

function bp_add_custom_country_list() {

  if ( !xprofile_get_field_id_from_name('Country') && 'bp-profile-setup' == $_GET['page'] ) {

		$country_list_args = array(
		       'field_group_id'  => 1,
		       'name'            => 'Country',
		       'description'	 => 'Please select your country',
		       'can_delete'      => false,
		       'field_order' 	 => 2,
		       'is_required'     => false,
		       'type'            => 'selectbox',
		       'order_by'	 => 'custom'

		);

		$country_list_id = xprofile_insert_field( $country_list_args );

		if ( $country_list_id ) {

			$countries = array(
				"United States",
				"Afghanistan",
				"Albania",
				"Algeria",
				"Andorra",
				"Angola",
				"Antigua and Barbuda",
				"Argentina",
				"Armenia",
				"Australia",
				"Austria",
				"Azerbaijan",
				"Bahamas",
				"Bahrain",
				"Bangladesh",
				"Barbados",
				"Belarus",
				"Belgium",
				"Belize",
				"Benin",
				"Bhutan",
				"Bolivia",
				"Bosnia and Herzegovina",
				"Botswana",
				"Brazil",
				"Brunei",
				"Bulgaria",
				"Burkina Faso",
				"Burundi",
				"Cambodia",
				"Cameroon",
				"Canada",
				"Cape Verde",
				"Central African Republic",
				"Chad",
				"Chile",
				"China",
				"Colombi",
				"Comoros",
				"Congo (Brazzaville)",
				"Congo",
				"Costa Rica",
				"Cote d'Ivoire",
				"Croatia",
				"Cuba",
				"Cyprus",
				"Czech Republic",
				"Denmark",
				"Djibouti",
				"Dominica",
				"Dominican Republic",
				"East Timor (Timor Timur)",
				"Ecuador",
				"Egypt",
				"El Salvador",
				"Equatorial Guinea",
				"Eritrea",
				"Estonia",
				"Ethiopia",
				"Fiji",
				"Finland",
				"France",
				"Gabon",
				"Gambia, The",
				"Georgia",
				"Germany",
				"Ghana",
				"Greece",
				"Grenada",
				"Guatemala",
				"Guinea",
				"Guinea-Bissau",
				"Guyana",
				"Haiti",
				"Honduras",
				"Hungary",
				"Iceland",
				"India",
				"Indonesia",
				"Iran",
				"Iraq",
				"Ireland",
				"Israel",
				"Italy",
				"Jamaica",
				"Japan",
				"Jordan",
				"Kazakhstan",
				"Kenya",
				"Kiribati",
				"Korea, North",
				"Korea, South",
				"Kuwait",
				"Kyrgyzstan",
				"Laos",
				"Latvia",
				"Lebanon",
				"Lesotho",
				"Liberia",
				"Libya",
				"Liechtenstein",
				"Lithuania",
				"Luxembourg",
				"Macedonia",
				"Madagascar",
				"Malawi",
				"Malaysia",
				"Maldives",
				"Mali",
				"Malta",
				"Marshall Islands",
				"Mauritania",
				"Mauritius",
				"Mexico",
				"Micronesia",
				"Moldova",
				"Monaco",
				"Mongolia",
				"Morocco",
				"Mozambique",
				"Myanmar",
				"Namibia",
				"Nauru",
				"Nepal",
				"Netherlands",
				"New Zealand",
				"Nicaragua",
				"Niger",
				"Nigeria",
				"Norway",
				"Oman",
				"Pakistan",
				"Palau",
				"Panama",
				"Papua New Guinea",
				"Paraguay",
				"Peru",
				"Philippines",
				"Poland",
				"Portugal",
				"Qatar",
				"Romania",
				"Russia",
				"Rwanda",
				"Saint Kitts and Nevis",
				"Saint Lucia",
				"Saint Vincent",
				"Samoa",
				"San Marino",
				"Sao Tome and Principe",
				"Saudi Arabia",
				"Senegal",
				"Serbia and Montenegro",
				"Seychelles",
				"Sierra Leone",
				"Singapore",
				"Slovakia",
				"Slovenia",
				"Solomon Islands",
				"Somalia",
				"South Africa",
				"Spain",
				"Sri Lanka",
				"Sudan",
				"Suriname",
				"Swaziland",
				"Sweden",
				"Switzerland",
				"Syria",
				"Taiwan",
				"Tajikistan",
				"Tanzania",
				"Thailand",
				"Togo",
				"Tonga",
				"Trinidad and Tobago",
				"Tunisia",
				"Turkey",
				"Turkmenistan",
				"Tuvalu",
				"Uganda",
				"Ukraine",
				"United Arab Emirates",
				"United Kingdom",
				"Uruguay",
				"Uzbekistan",
				"Vanuatu",
				"Vatican City",
				"Venezuela",
				"Vietnam",
				"Yemen",
				"Zambia",
				"Zimbabwe"
			);

			foreach (  $countries as $country ) {

				xprofile_insert_field( array(
					'field_group_id'	=> 1,
					'parent_id'		=> $country_list_id,
					'type'			=> 'option',
					'name'			=> $country,
					'option_order'   	=> $i++
				));

			}

		}
	}
}
add_action('bp_init', 'bp_add_custom_country_list');

catacaustic on "Customizer not showing control"

$
0
0

I'm having trouble trying to make a new customizer class. I've followed the tutorials as well as the Codex page, and as far as I can see I'm doing everything correctly, but I can't get my customisation section to show.

For more details, the section shows up when the customizer is loading, but it gets hidden as the section doesn't contain any controls, even though I've got them added in the code.

The code is here -> http://pastebin.com/zuzXkzQj

I've done the standard things, and from what I can see the section, setting and control are all being added to the customizer object, so I'm feeling a bit lost as to why it's not showing up.

If anyone has any ideas, I'd love to hear them!

dpipitone on "Display Feature Image Instead of Maps on Archive Pages"

$
0
0

As an inexperienced php coder, I am seeking help.

I am using a theme, named Blessing, by Thememakers, in which the Events List page (archive of all events) displays a map for each event.

I am able to assign a Featured Image for each event, but when I try to edit the code for the event list, replacing the map loop with one to display the featured image, some featured images display, but it seems to get the ID’s mixed up. They are all displaying the incorrect images, as if they are swapped for one another.

Page is here:
http://martinacenter.com/retreats-and-events/events-list/

This is the code I have put in place:
			<?php if (!$hide_event_place) : ?>
                           <div class="gmaps">
                           <div class="bordered">
                                 <figure class="add-border">
                                      <img src="<?php echo ThemeMakersHelper::get_post_featured_image($post->ID, 574, true, 258); ?>" alt="<?php the_title(); ?>" />
                                 </figure>
                           </div><!--/ .bordered-->
                           </div>
                         <?php endif; ?>

Screenshot of the entire edited php file here:
http://snag.gy/X5B6b.jpg

Anyone have ideas why the wrong feature image is being displayed?

Thank you!


chickspirit on "WooCommerce Product Image to External Link in New Window"

$
0
0

I have an external link product and would like the featured image on the single product page to link to the external page in a new window.

Out of the box the image, when clicked, opens in a lightbox.

The section of code I have to adjust is in the product-image.php

<div class="images">

	<?php
		if ( has_post_thumbnail() ) {

			$image_title 	= esc_attr( get_the_title( get_post_thumbnail_id() ) );
			$image_caption 	= get_post( get_post_thumbnail_id() )->post_excerpt;
			$image_link  	= wp_get_attachment_url( get_post_thumbnail_id() );
			$image       	= get_the_post_thumbnail( $post->ID, apply_filters( 'single_product_large_thumbnail_size', 'shop_single' ), array(
				'title'	=> $image_title,
				'alt'	=> $image_title
				) );

Specifically I need to change this line:
$image_link = wp_get_attachment_url( get_post_thumbnail_id() );

I changed it to this:
$image_link = esc_url( $product->get_product_url() );
which accomplished the image opening the external link when clicked. However it's opening in the same window and I'd like it to open in a new window.

I tried this:
$image_link = esc_url( $product->get_product_url(), array('target' => '_blank', 'rel' => 'new_window') );
But now it just kind of refreshes the page and takes me nowhere.

Suggestions? Thank you!
Page I'm trying this on.

IanExperior on "How can I access the back end of an old wordpress"

$
0
0

A friend has who has all access to our word-press website, he's disappeared off he face of the earth and now I need access. How might I go about doing this or is it impossible? All I know is the website and website email.
Username/login/passwords are needed asap

massa974 on "Connect to an external database"

$
0
0

Hi guys,

So here's the thing : I was recently hired as a Wordpress trainer for students who have never used it. I accepted the job because the training program felt entirely under my scope of skills.

But when I met the students, I learned that there's a mandatory part of the training that I have no idea how to deal with :

On a Wordpress based subdomain, they need to connect to an external database which is linked to a Joomla install, to gather and display data from this external database.

Again, this is way out of my scope of skills, so I'd definately like some insights from you guys. (detailed if possible)

Please forgive me if this sounds like I want you to make my job, but since my employer here seems to see my incapacity in this field in an infavourable light, some help would be awesome.

Thanks !

doppiots on "Limits of number of taxonomie"

$
0
0

I want to migrate/convert an existing e-commerce site into wordpress platform with a ecommerce plugin (probably woocommerce).
Actually the site have a lot of number of product (about 170.000) with many attribute (writer, publisher, genre, series) and all items are updated every week many times from a external file.
These are the numbers of items updates (more or less):
- product (titles od books): 170000
- genre (custom category): 350
- writers (custom attribute -> taxonomy): 130000
- publisher (custom attribute -> taxonomy): 3000
- series (custom attribute -> taxonomy): 20000
Now the problem: when i import data the process works but writers are not totally loaded and import stop at 52490 items and wp_term_taxonomy has 52875 record.
Why? Is a limit of wordpress or a php?
Perhaps wp load all taxonomie in memory and is is a system limit?
Thanks

thamaraiselvam on "Where can i find wordpress auto update code flows?"

Viewing all 8245 articles
Browse latest View live




Latest Images