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

jepper on "Removed category from permalink, now custom posts displays as archive"

$
0
0

Hi,

In an attempt to remove slugs for a custom post type I've followed this guide:

http://ryansechrest.com/2013/04/remove-post-type-slug-in-custom-post-type-url-and-move-subpages-to-website-root-in-wordpress

With some assistance of a helpful forum member here I've got it to work for my website. However the changed permalink (without category) and the old link now lead to an archive page. (is_archive = true)
I've set all the flags correctly, for example has_archive = false.

With some is_type hackery (as in fast and ugly) in single.php I've got a normalish website flow back but i'm running into trouble with custom comment fields.

This is the declaration code:

function register_cpt_product() {

    $labels = array(
        'name' => _x( 'Producten', 'product' ),
        'singular_name' => _x( 'Product', 'product' ),
        'add_new' => _x( 'Add New', 'product' ),
        'add_new_item' => _x( 'Add New Product', 'product' ),
        'edit_item' => _x( 'Edit Product', 'product' ),
        'new_item' => _x( 'New Product', 'product' ),
        'view_item' => _x( 'View Product', 'product' ),
        'search_items' => _x( 'Search Products', 'product' ),
        'not_found' => _x( 'No producten found', 'product' ),
        'not_found_in_trash' => _x( 'No producten found in Trash', 'product' ),
        'parent_item_colon' => _x( 'Parent Product:', 'product' ),
        'menu_name' => _x( 'Producten', 'product' ),
    );

    $args = array(
        'labels' => $labels,
        'hierarchical' => false,

        'supports' => array( 'title', 'editor', 'comments' ),
        'taxonomies' => array( 'category' ),
        'public' => true,
        'show_ui' => true,
        'show_in_menu' => true,
        'menu_position' => 20,

        'show_in_nav_menus' => true,
        'publicly_queryable' => true,
        'exclude_from_search' => false,
        'has_archive' => false,
        'query_var' => true,
        'can_export' => true,
        'rewrite' => array('slug' => '/','with_front' => true)
        //'capability_type' => 'post'
    );

    register_post_type( 'product', $args );
}

and this the flow specific code:

function custom_post_type_link($permalink, $post, $leavename) {
    global $post;

    //var_dump($post);

    if (!gettype($post) == 'post') {
        return $permalink;
    }
    switch ($post->post_type) {
        case 'product':
           $permalink = get_home_url() . '/' . $post->post_name . '.html';
           //$permalink = "je-moeder.html";
           //var_dump($permalink);
           return $permalink;
           //break;
    }

    return $permalink;
}
add_filter('post_type_link', 'custom_post_type_link',10,3);

function custom_pre_get_posts($query) {
    global $wpdb;

    if (is_main_query() ) {
      $name = $query->get('category_name');
      $name = str_replace(".html", "", $name);

      $post_type = $wpdb->get_var( $wpdb->prepare( 'SELECT post_type FROM ' . $wpdb->posts . ' WHERE post_name = %s LIMIT 1', $name ) ); 

      if($post_type == "product"){
          //$query->set('name', $name );
          $query->set('post_type', "product");
          $query->set("product", $name ); //parser ignores query vars it does not recognize
          $query->set('category_name', "");
          $query->is_single = true;
        }
   }

    return $query;
}
add_action('pre_get_posts','custom_pre_get_posts');

I can't find similar help topics anywhere.

The custom post type is nothing special, no strange plugins running.

Anybody got an idea whats going on, and possibly how to fix this?

Cheers!

Jasper


gagan_mathur on "How to add custom filter options in online shopping site?"

$
0
0

I am working on a online shopping site for Laptops. Now I want to add some custom filter option in my site for example filter by brands, filter by processor, filter by operating system, filter by price, filter by hard disk capacity etc. Just like in famous online shopping site like "www.flipkart.com" and "www.snapdeal.com". So, can anyone help me in adding custom filter options?

vmattaur on "2 videos displayed in sidebar"

$
0
0

I've started with a Blank-Theme supplied by Chris Coyier. I've placed static videos in the sidebar.php page.
1. Both video's only show in Safari, Opera
2. Only top video plays in Chrome
3. No videos play in Firefox

Harmarassoc.com

Code:
<table>
<td style="width:100px">

<aside>
<?php if (function_exists('dynamic_sidebar') && dynamic_sidebar('Sidebar Widgets')) : else : ?>
<!-- All this stuff in here only shows up if you DON'T have any widgets active in this zone -->

<nav>
<?php wp_nav_menu(array('menu' => 'Main Nav Menu')); ?>
</nav>

<div class="widget industry-news">

<h4>Industry News</h4>

<p class="date">March 3, 2014<h5>Salt in NJ's Tap Water!</h5>United Water says sodium levels in drinking water rise every winter, but because there has been so much snow this year, sodium levels are 3 to 4 times higher than usual. An 8-ounce glass of water has about 28 milligrams of sodium, about the same as 8 ounces of diet soda. Water treatment facilities and home filters cannot remove sodium from water.</p>

<video controls height="125" width="195">
<source src="../../../wp-content/themes/water/movies/Salt.mp4" type="video/mp4" />
<source src="../../../wp-content/themes/water/movies/Salt.WebM" type="video/WebM" />
<source src="../../../wp-content/themes/water/movies/Salt.avi" type="video/avi" />
<source src="../../../wp-content/themes/water/movies/Salt.m4v" type="video/m4v" />
<source src="../../../wp-content/themes/water/movies/Salt.mov" type="video/mov" />
<source src="../../../wp-content/themes/water/movies/Salt.wmv" type="video/wmv" />
</video>

</div> <!-- END Industry News -->

<div class="widget industry-news">
<p class="date">April 2, 2012<h5>Dr. Oz talks about family drinking water!</h5>This video doesn't endorse any particular water filtration system but more importantly talks about why it is important to filter you home drinking water.</p>

<video controls height="140" width="195">
<source src="../../../wp-content/themes/water/movies/OzWater.mp4" type="video/mp4" />
<source src="../../../wp-content/themes/water/movies/OzWater.WebM" type="video/WebM" />
<source src="../../../wp-content/themes/water/movies/OzWater.avi" type="video/avi" />
<source src="../../../wp-content/themes/water/movies/OzWater.m4v" type="video/m4v" />
<source src="../../../wp-content/themes/water/movies/OzWater.mov" type="video/mov" />
<source src="../../../wp-content/themes/water/movies/OzWater.wmv" type="video/wmv" />
</video>

</div> <!-- END Industry News -->
<?php endif; ?>

</aside>
</td>
</table>

KarlN on "TinyMCE inserting unnecessary characters into image SRC URLs"

$
0
0

I am using the WP_editor function to add some content to a custom database table, the only problem I have come across is with images, TinyMCE is adding some unnecessary characters which is preventing the images from being displayed.

Example:

src="\"http://localhost:8888/wordpress/wp-content/uploads/2014/04/dscn7122-300x225.jpg\""

Should be:

src="http://localhost:8888/wordpress/wp-content/uploads/2014/04/dscn7122-300x225.jpg"

clsimco on "Help please...Script loading format breaks page functionality"

$
0
0

Thanks for reading, and in advance, your help.

I'm really a a novice but am learning as I go and have encountered this problem when trying to get an Isotope gallery to work on a page on my site. As a result of trying to solve that I have encountered a couple of oddities.

In order:

Live site is : clsimco.com
Page with Isotope is: clsimco.com > About > Gallery

Problem is: Script loading function written into the theme (bootstral-WP) allows scripts to load and things to work correctly but when you check developer tools there are 404 errors for those same scripts that are working on the pages. Eg: drop-down menus and modals etc. work.

I then added a page for Isotope Gallery and using existing loading function Isotope will not work.

I investigated and came up with this info:
functions.php enqueues the scripts like this

<code>
function bootstrapwp_scripts_loader() {

    if (is_singular() && comments_open() && get_option('thread_comments')) {

        wp_enqueue_script('comment-reply');

    }

    wp_enqueue_script('bootstrap-js', get_template_directory_uri() . '/assets/js/test-js/bootstrap/js/bootstrap.min.js', array('jquery'), '1.0', true);
    wp_enqueue_script('demo.js', get_template_directory_uri() . '/assets/js/bootstrapwp.demo.js', array('jquery'),'1.0',true);
</code>

etc.etc. You see the forward slash / before the start of the complete ed url.

Footer Template has the following code:

<code>
 <?php wp_footer(); // js scripts are inserted using this function ?>
    <script src="//use.edgefonts.net/cardo:n4,i4,n7:all;pontano-sans:n4:all;meddon:n4:all.js"></script>
	<script src="<?php echo get_template_directory_uri(); ?>assets/js/bootstrapwp.demo.js" type="text/javascript"></script>
	<script src="<?php echo get_template_directory_uri(); ?>assets/js/test-js/jquery-1.8.3.min.js" type="text/javascript"></script>
	<script src="<?php echo get_template_directory_uri(); ?>assets/js/test-js/bootstrap/js/bootstrap.min.js" type="text/javascript"></script>
</code>

Note the lack of the forward slash / at the beginning of the url

You can View Source on the home page and gallery page to see an view my comments to help

Where the REAL problem lies and is where I am at is this:

Something seems at odds in the script loading.
As a result I do not seem to be able to use the same script loading to get the Gallery page to work with isotope AND have the menus work. Or if the menus work Isotope does not work.

My workaround for the moment is to have separate footer templates with different coding so the Gallery Isotope will work, but the menus do not, and have another footer template for the rest of the site and it works fine but produces 404's.

Any ideas much appreciated. Im stumped

andym33 on "Redirect to homepage when login and log out"

$
0
0

I'm trying to find out how I can do a redirect to my home page every time a user logs in and logs out.

Could anyone help me with this, thanks in advance.

marcoamarelo on "Using double slashes over protocol description in siteurl option"

$
0
0

Hi everybody! I have a site with WordPress that needs provide content over http and https at the same time. I know this practice is not recomended by WordPress over https, but unfortunately I have no choice. I found many ways to implement my site over both protocols, but one was especialy interesting. I just replace the protocol in siteurl e home options by double slashes like //. So, it works, but I wish know if there is any consequences of this hack. I tryed to set it by WordPress, but there is a filter which blocks this change. So I changed it in the database.

Jessica on "How To Replace The WP-Amin Login Page With A Custom Login Page"

$
0
0

I am trying to figure out how to do the following:
Either be able to add text to the WP-Login Page above and below the logo,
Or
Create a custom login page that will be used instead of the default login page.

I have been looking for tutorials on how to do this and I have not found exactly what I am looking for. The wordpress codex seems to allude to how to create a custom login page but I am a little confused by it.

Can anyone help me figure this out?

Thanks in advance for your time.


T.oby on "use jquery get function"

$
0
0

Hi, I would like to use the javascript jquery get function in the following simple example:

<script type="text/javascript" src="/wp-includes/js/jquery/jquery.js"></script>
<script type="text/javascript">
$.get('http://www.w3schools.com/images/w3schoolscom_gray.gif').done(
  function() {
        alert("image exists");
    }).fail(function() {
        alert("image does not exist");
    })
</script>

I assume here that the jquery library is in '/wp-includes/js/jquery/jquery.js' of the wordpress root folder which seems to be the case for my wordpress installation. However I think I am missing something because when opening the page nothing comes up.

Thanks for any help!

Toby

balothenorthface on "Custom review works for published, not drafts"

katiejallred on "Multiple Downloads, Subscribe Once"

$
0
0

Basically I'm trying to replicate the functionality seen here: http://www.holycityhospitality.com/good-food-catering/resources/

Basically the user clicks on the div, the user gets a lightbox asking for an email, they subscribe to an email list (but not really, since MailChimp does double opt-in), and then for the rest of the time they're on the website they can click and open any div including PDF's or JPEG's without having to re-enter their email address.

Any help? We are using mailchimp and wufoo forms currently, but the process we have is rather bulky compared to this. I would really like it if the user never had to enter their email again after having entered it once. Obviously there are multiple downloads and I want to show them all off and not hide them.

meinevergreen on "Frontend of my Plugin"

$
0
0

Hi,

i just resently started writing my first plugin for wp. a small event-manager for my clubs website (none of those event-manager plugins ready to use is matching our needs).

so i coded some admin pages for my plugin. connect it to the wp database. so far thats all good to me. but i still don't know how i realize my frontend of the plugin.

plugin frontend needs:
- user has to fill up some data in my special forms
- data needs to be send by form to the next page

question:
- how can i send those data via method post/get to the next page to go on?
- add_shotcode seems good for small plugin-snippets, but my plugin will include a qouple of functionality. is there a alternative to add_shortcode?

hope you understand my issue. :-)

thanks!
janek

balothenorthface on "Maximize Heavy Content Page Loading"

blazeblaze on "How to hide part of a page enclosed with div tags from logged in users?"

$
0
0

Hello!

I have an introduction to my site on a static page, but I would like to hide it once a user is logged in.

I've little experience in codding. I've tried to use the "if user logged in function then... else", but I was unable to get it work.

Could you help me by providing possible solution? What code could I use, where to put it?

Regards!
Tom

luchiabloomfield on "Displaying all pages in one page (including their own templates)"

$
0
0

Hi,

I've spent a couple of hours searching for this answer, so I apologise if it's already been asked and answered before.

I've got a page template that calls all the pages in the menu order, which works fine. The only problem is none of the individual page templates are showing.

This is my existing code:

<?php get_header(); ?>

<?php
	/*
		Template Name: Main Page Template
*/?>

<?php query_posts( array('post_type'=>'page', 'posts_per_page' => 1000, 'orderby' => 'menu_order', 'order' => 'ASC') ); ?>
<?php if(have_posts()): while(have_posts()): the_post(); ?>

    <?php
        global $post;
        $slug = $post->post_name;
        locate_template(
            array(
                "template-$slug.php",
                'home_page.php',
                'thepies_page.php',
                'theteam_page.php',
                'thegirls_page.php',
                'stockists_page.php',
                'index.php',
                'contact_page.php'
            ), true
        );
    ?>
<?php endwhile; endif; ?>

Hopefully someone can help me, thank you.


Gandora on "Make plugin out of javascript slider"

$
0
0

Hello everyone,
I need help with making a plugin that applies a javascript to images/divs.

The script is some kind of slider. Here's an image of a big picture of which only a part is shown and it's thumbnail.
Sample Picture

So, apart from not having been able to figure out how to add a js-script (and where to place it) I would like to be able to choose the big picture on the wordpress dashboard/admin page, in the plugin menu from the media library (and maybe have some automatic resizing for the thumbnail? Or should the library just contain a thumbnail picture which has to be chosen as well?).

Here are my php-file in the plugins folder, and the script I want to apply:

Php-File
JS-Script

I copy pasted amost of the PHP code and adapted it a little, so I know that the 'add_action' call should not be done for the 'admin_menu'. But I also don't know what I should replace it with.

Any help is highly appreciated, since I'm struggling with wordpress for two weeks now.

hjmatt on "Post Counts On One Line For Categories Widget With Span"

$
0
0

Hi,

I can see this question has been asked many times before, but what I want is a variation on code that I know works.

Over here there is a solution to get the posts counts next to the category titles in the default categories widget.

add_filter('wp_list_categories', 'cat_count_inline');
function cat_count_inline($links) {
$links = str_replace('</a> (', ' (', $links);
$links = str_replace(')', ')</a>', $links);
return $links;
}

What I would like is a variation on that solution to incorperate a span class for positioning purposes. In terms of HTML/CSS. I need the output the same as this one for woocommerce product category listing:

<li class="cat-item cat-item-24">
<a href="http://domain.com/product-category/cleaning/">Cleaning</a>
<span class="count">(0)</span>
</li>

It's that <span class="count"> that I need.

Regards,
Matt

flo80 on "Store raw post HTML in Wordpress database"

$
0
0

I've integrated my Wordpress database with ASP.NET where I directly request the content from the Wordpress database. So the rendering of the HTML is NOT done by Wordpress, but first requested by ASP.NET and then rendered to the browser.

The problem is that Wordpress adds tags like <p> and <br/> to my posts's content when they are rendered to the frontend. Since in my case this rendering is not done by Wordpress, I need to be able to store the content of a post as raw HTML in the Wordpress database.

I however do want Wordpress editors to still work on the 'View' tab, instead of having them work on 'Text' tab in the HTML.

How can I do this?

almerika on "Hide buy button on products with specific tags WP E-commerce"

$
0
0

Hi.
Using WP E-commerce and Storefront Elegance theme for an online store. Trying to use a product tag as a condition to hide the buy-button and quantity update (on the single product page) for some products that only can be bought in the physical store (can't be shipped).

I've tried with css and it works fine but only on one specific product (post-1928) and not on a whole product tag.

Here's the css:
.post-1928.wpsc-product.type-wpsc-product .wpsc_quantity_update {
display: none;
}
.post-1928.wpsc-product.type-wpsc-product .productcol fieldset legend {
display: none;
}
.post-1928.wpsc-product.type-wpsc-product input.wpsc_buy_button {
display: none;
}

Here's the test-product: http://www.olsonsab.se/produkter/tillbehor/testprodukt-2/
Here's the product tag: http://www.olsonsab.se/etikett/demoex/

I've also tried a php code in the wpsc-single_product.php that hides the buy button if you're not logged in.

<?php if((get_option('hide_addtocart_button') == 0) && (is_user_logged_in()) && (get_option('addtocart_or_buynow') !='1')) : ?>

That example works good but I don't know what to put in instead to use the function for products with a specific tag. The tag is "demoex" (term-134).

Would really appreciate some help here. I've been searching for days.

balothenorthface on "use jquery append function"

Viewing all 8245 articles
Browse latest View live




Latest Images