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

No3x on "Serve export file"

0
0

Hi guys, I want to export selected data from a list table of my plugin. The data should be exported to a file. I was not able to create a download by passing id's at the same time.
Thought I can pass the selected id's from the list table to an ajax-function. Well.. this works but the resulting file is not sent to the client since it's a side-request. So this doesn't work. Next I tried to add a template_redirect for a request download/export.xsl but that way I only can pass the id's via GET imho. (That's not so good..)
What's the common way to do so?


Ashley Michèlle on "Display only manual excerpt on index (function)."

0
0

This is my current functions.php custom function:

function custom_excerpt($text) {  // custom 'read more' link
   if (strpos($text, '[...]')) {
      $excerpt = strip_tags(str_replace('[...]', '<div class="readmore"><a class="readmore" href="'. get_permalink( get_the_ID() ) . '"><small>CONTINUE READING</small></a></div>', $text), "<a>");
   } else {
      $excerpt = '' . strip_tags($text) . '<div class="readmore"><a class="readmore" href="'. get_permalink( get_the_ID() ) . '"><small>CONTINUE READING</small></a></div>';
   }
   return $excerpt;
}
add_filter('the_excerpt', 'custom_excerpt');

You can see it in action here: http://ohmybonbon.com.

I would like to see only the manual excerpts displayed, and if there is no manual excerpt, I would like it to only display the 'continue reading' link, rather than an automatic excerpt (as it is currently doing).

I'm sure this is probably incredibly easy, but my brain isn't working. So, of course, help is greatly appreciated!

pkarjala on "Custom Post Type, Admin can't Create"

0
0

I'm a bit new at creating Custom Post Types, but I think I have the basics down. For a theme that I'm writing for a client I'm creating a new Post Type called "Performance Task" that a teacher will be able to write and post about a lesson plan they've created.

However, when I activate the theme, the Administrator account can only access the Categories and Taxonomies for the Post Type; it cannot access any other abilities such as new post, view posts, etc.

I've dug through the documentation and haven't been able to find anything on registering post types that coincides with needing to grant the Administrator role additional access. However, I could also just be doing it completely wrong.

A gist of the php to create the custom post type is at https://gist.github.com/pkarjala/d827a96d029294ed4485

My choice of doing this in a theme vs. a plugin aside, I'd like to learn how to provide the administrator role access to all of the normal functionality that the new post type has: create, publish, delete, etc. I'll eventually be adding a few other custom roles that can interact with this post type, but I think I can get that working correctly. Do I need to re-create the administrator role? Or can I simply add the new capability required to administrator in the theme?

Thank you for your assistance.

photoshopace on "Adding JS to wordpress menu item"

0
0

Trying to customize a wordpress menu list item. The menu was created through the wordpress admin panel. I am unable attach the javascript function show/hide to a specific wordpress menu list item.

I have added a class to the menu list item through the wordpress admin area > screen options > CSS Classes. However this class is not triggering the javascript function show/hide.

What am I missing to in order to attach the javascript function to the wordpress generated navigation menu?

$(document).ready(function(){
$(".hide").click(function(){
$(".webform").hide(500);
});
$(".show").click(function(){
$(".webform").show(500);
});
});

tobbger on "Volume bar bug with built-in audio player"

0
0

I run this blog called Gentle Cuts:
http://www.gentlecuts.net

I have put an audio player beneath the song titles in the posts. Whenever I reload the page the volume bar jumps down beneath the player itself. If I change the width of the browser window or press play, the volume bar jumps to the right position (to the right of the player itself), as it should be.

Does anyone know what the problem with this might be? I'm thinking that this might have to do with the text being bigger than the default theme of the player. Maybe the text exceeds the height of the player and therefore creates this bug?

atlantix on "take data and link to correct page"

0
0

Hello,
I'm thinking how to make a form:
I need to pickup information and than redirect or show information in the same page.
Example:
list of cars.
I choose Volvo, than in the next input I select model s40 than I should be redirected to the page where I will see the information about the car.
any ideas how to build this one?

gecko_guy on "Why does WP strip menu description html tags?"

0
0

Hi,

Does anyone know why WordPress strips the HTML tags from the menu item descriptions?

I know how to overcome this with a couple of filter functions written in the child theme's functions.php, however I have not been able to establish the actual reasoning behind the decision to strip tags in the first place..

I usually assume there is a good reason for excluding what seems to be a very useful and intuitive option from the core functions, and prefer not to interfere with things that I don't know enough about until I feel comfortable that there is no overriding factor in terms of security, or other negative side effects.

brantb15 on "Adding time to Datepicker"

0
0

Hello
How can I add a time, or at the very least a "morning or afternoon" kind of selection to WP's datepicker?


lolhospital on "Adding a Custom Login/Account Info Above Header-Menu"

Creihar on "Category Loop"

0
0

Hi, I have a question regarding the loop categories. I have a list follows.

<ul class = "list-unstyled list-inline" id = "filters">
                        <li> <a href="#" class="btn btn-primary active" data-filter="*"> All </a> </ li>
                         <li> <a href="#" class="btn btn-primary" data-filter=".sport"> 1 - International Dance Sport </a> </ li>
                         <li> <a href="#" class="btn btn-primary" data-filter=".alumnos"> Students </a> </ li>
                         <li> <a href="#" class="btn btn-primary" data-filter=".galas"> Galas </a> </ li>
                         <li> <a href="#" class="btn btn-primary" data-filter=".recomendados"> Recommended </a> </ li>
</ ul>

if clicko shows me a div or another.

<?php query_posts('category_name=videos-sport&posts_per_page=5' ); while ( have_posts() ) : the_post(); ?>
              <div class="col-md-4 sport">
                <a href="#">
                  <div class="embed-responsive embed-responsive-16by9">
                  <?php echo catch_that_video(); ?>
                    </div>
                </a>

              </div>

The problem is not how to add video categories that have something in the

    </ ul> and that something put in the data-filter and in the div.

    I do not know if I explained well. Anyway thanks in advance

DannyPlan on "Custom Menu"

0
0

Hello all,
I am running wordpress 4.1.1 Zinna theme and I have been searching high and low for a more user friendly mobile navigation menu. Since I have not been able to find one and I am thinking one may not exist. Therefore I am considering trying to write a custom menu to replace my "tinynav" menu because I really like this theme other than the mobile menu.
I used a one click install to get up and running and now I'm wondering if I could just download the wordpress 4.1.1 and the Zinnia theme folders, change the CSS for "tinynav" and push it up through an FTP of some kind. Sorry if this is a dumb question, I'm just trying to learn more about web development and solve what seems to be a user experience problem with my theme. Thank you for your time.

If you'd like to visit my site:dannytijerina.com

-Danny

Chris Whiteley on "Conditional Statements in Functions.php"

0
0

I have a snippet of code running to remove a post from a category after a specified length of time, however I would like to exclude an author from this function. I have tried a few things to accomplish this with no success. I am really unsure how to accomplish this.

Here is the code use to remove the post from a category:

function auto_cat_remove() {
    global $post;
    wp_schedule_single_event( time() + 20, 'remove_news_cat_event', array( $post->ID ) );
}

function remove_news_cat_func( $post_id ) {
    global $wpdb;
    $category_id = 598;
    $wpdb->query( $wpdb->prepare( "DELETE FROM $wpdb->term_relationships WHERE object_id = %d AND term_taxonomy_id = %d", $post_id, $category_id ) );

}

add_action( 'wp_insert_post', 'auto_cat_remove' );
add_action( 'remove_news_cat_event', 'remove_news_cat_func' );

blueprint4 on "wp widget need to load as javascript"

0
0

Hi,

I have the theme realia. It currently has a widget named agent that loads into the side bar. The widget works great but my site pulls in data from another site every 3 hours through frame. The widget does not work during these 3 hours(stays stationary). They said to load the widget as a javascript. I have no idea how to do this. They provided me with their code and how they do it and said I need to incorporate it into my code. There code is :

<script charset="UTF-8" type="text/javascript" id="idxwidgetsrc-33317" src="http://demo.idxbroker.com/idx/featuredagent.php?widgetid=33317"></script>

my widget loads using:

<div class="sidebar span3">

                        <div id="agents_widget-2" class="widget our-agents">

            <h2>Contact Realtor</h2>

    <div class="content">
                    <div class="agent clearfix">
                <div class="image">
                    <a href="https://vafha.net/agents/agent name/">
                                                    <img width="274" height="490" src="https://vafha.net/url to agent picure" class="attachment-post-thumbnail wp-post-image" alt="" />
                                            </a>
                </div>
                <!-- /.image -->

                <div class="name">
                    <a href="https://vafha.net/agents/Agent Name would be here/">Agent Name</a>
                </div>
                <!-- /.name -->
                    <div class="phone">Platinum Agent</div>
                <!-- /.phone -->
		<!-- /.agency -->
                <div class="phone">Agent number</div>
                <!-- /.phone -->
                <div class="email"><a>
                </div>
                <!-- /.email -->
            </div><!-- /.agent -->
            </div><!-- /.content -->

    </div>

Thanks for anyhelp

nicolemcin on "Change background color of WP Subscribe Widget"

0
0

Hi all,

I'm having some trouble changing the color of my WP Subscribe Widget. It's a peachy color that doesn't match my theme at all.

I have tried custom CSS, but to no avail. I believe I am using the wrong class.

The URL is http://outsmartinglife.com. If anyone could help me out, that would be great. Thanks a bunch!

odie2 on "Pagination: posts limited only on first page"

0
0

Hello,

According to https://wordpress.org/support/topic/front-page-query_posts-limit-posts-only-on-first-page-1
I found that 5 posts from offset are not displayed on last page - they needs next page.

I have 408 published posts.
So $wp_query->max_num_pages = 41.

But index.php is:

global $query_string;

$front_limit = 5;
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$offset = ( is_paged() ? ( ($paged - 2) * $posts_per_page + $front_limit ) : 0 );
$posts_per_page = get_option('posts_per_page');

$my_query = '&ignore_sticky_posts=1';
$my_query .= '&offset='.$offset;
$my_query .= '&paged='.$paged;

if ( !is_paged() ) :
    $my_query .= '&posts_per_page='.$front_limit;
else :
    $my_query .= '&posts_per_page='.$posts_per_page;
endif;

query_posts( $query_string . $my_query );

So on 41 pages I have 405 posts (41 pages limited to 410 posts, but front page takes only 5 posts and following pages have offset by those 5 taken from front page).
And 3 last posts are missing.

Correctly number of pages should be:

$front_limit = 5;
$total_posts = $wp_query->found_posts;
$posts_per_page = get_option('posts_per_page');

$total_pages = ceil( ( $total_posts - $front_limit ) / $posts_per_page ) + 1;

I have no problem to modify navigation to set max number of pages 42, but page 42 just no exists.

Temporarily I just used trick for last page (41):

if ( !is_paged() ) :
    $my_query .= '&posts_per_page='.$front_limit;
else :
    if ( $paged == $wp_query->max_num_pages ) $posts_per_page += $front_limit;

    $my_query .= '&posts_per_page='.$posts_per_page;
endif;

So page 41 displays up to 15 posts (in my case 13).

But this is not satisfactory result. If someone have an idea, please let me know.

Note: fix for first page posts navigation is

$args = array_merge( $wp_query->query_vars, array( 'showposts' => get_option('posts_per_page')) );
query_posts( $args );

before call of "paginate_links"

Thanks in advance!
Greetings


Steven Gardner (Template Express) on "paging not working"

0
0

I'm building my first plugin that adds some extra homepage templates to my theme. The problem is the paging is not loading older or newer posts and I'm not sure whats wrong.

Can you take a quick look at point me in the right direction.

Thanks

Query Loop on template

$temp = $wp_query; $wp_query= null;
    $wp_query = new WP_Query(); $wp_query->query('showposts=7' . '&paged='.$paged);

    while ($wp_query->have_posts()) : $wp_query->the_post();

Call to navigation function (the function is part of theme not this plugin) at bottom of template
eryn_paging_nav()

eryn_paging_nav() function code:

if ( ! function_exists( 'eryn_paging_nav' ) ) :
/**
 * Display navigation to next/previous set of posts when applicable.
 */
function eryn_paging_nav() {
	// Don't print empty markup if there's only one page.
	if ( $GLOBALS['wp_query']->max_num_pages < 2 ) {
		return;
	}
	?>
	<nav class="navigation paging-navigation" role="navigation">
		<h1 class="screen-reader-text"><?php _e( 'Posts navigation', 'eryn' ); ?></h1>
		<div class="nav-links">

			<?php if ( get_next_posts_link() ) : ?>
			<div class="nav-previous"><?php next_posts_link( __( '<span class="meta-nav">&larr;</span> Older posts', 'eryn' ) ); ?></div>
			<?php endif; ?>

			<?php if ( get_previous_posts_link() ) : ?>
			<div class="nav-next"><?php previous_posts_link( __( 'Newer posts <span class="meta-nav">&rarr;</span>', 'eryn' ) ); ?></div>
			<?php endif; ?>

		</div><!-- .nav-links -->
	</nav><!-- .navigation -->
	<?php
}
endif;

apherit on "HACK"

Drachsi on "Can I add fields to the standard WP "All Users"?"

0
0

I would like All Users" to show registration date and password in the Admin section, seems like something that would be common for Admins.

Regards
Drachsi

kofbd on "I want to filter a custom post type by custom field and only show author posts"

0
0

I am trying to filter custom fields if leads_status has -1 or empty and only author posts will be there. struggling for few days. Thank you.

add_filter( 'parse_query', 'my_admin_posts_filter' );

function my_admin_posts_filter( $wp_query )
{

if ( strpos( $_SERVER[ 'REQUEST_URI' ], '/wp-admin/edit.php?post_type=estate_leads' ) !== false ) {

if ( !current_user_can( 'level_10' ) ) {

$current_user = wp_get_current_user();
$author = $current_user -> ID;

$wp_query->set(
'author' ,$author,

'meta_query', array(
'relation' => 'OR',

array(
'key' => 'leads_status',
'value' => '-1',

),

array(
'key' => 'leads_status',

'compare' => 'NOT EXISTS',
),

)

);

}
}
}

theMikeD on "How is the post_id determined when adding a new post?"

0
0

When a new (post|media|tag|whatever) is added, it's given an ID. How is this ID determined? Is there a counter somewhere?

Viewing all 8245 articles
Browse latest View live




Latest Images