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

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!


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.

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.

cogdog on "get_terms Multiple order_by options"

$
0
0

The 'orderby' => 'count' option for get_terms and get_tags functions saved me a bunch of custom coding to create a listing all terms in a custom taxonomy (I am using it to add terms for submitters twitter names, and using it as a leaderboard).

However, I would like to secondary sort terms with the same count by term_name. It would be nice to be able to provide an argument like

'orderby' => 'count,name'

to be able to have a secondary sort option.

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

outmane on "jQuery code not working in Wordpress, even after loading library"

$
0
0

Helo everyone!
I have requested an API from a website to check availability of an email, and I got a jQuery code to integrate the API to my website. I use wordpress, and I tried to add the code, but it doesn't work and I dont know why. I suspected it was a jQuery library probleme, so I loaded it it in the "funtion" file, and in the script from google API, but nothing. Thanks for your help, and here is the code (by the way I also tried changing with 'jQuery.'):

<!DOCTYPE html>

    <html lang="en" xmlns="http://www.w3.org/1999/xhtml">
    <head>
            <meta charset="utf-8" />
            <title>emailverifyapi.com : License Key Sample.</title>
            <style type="text/css">
                    .statusUnknown {
                            color: #c1c72c;
                    }

                    .statusOk {
                            color: #009933;
                    }

                    .statusBad, .errorMsg {
                            color: #ff0000;
                    }

                    input[type='text'] {
                            width: 300px;
                    }
                    p label {
                            display: inline-block; width: 60px;
                    }
            </style>
            <script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
    </head>
    <body>
            <h1>emailverifyapi.com : email verification demo using simple key authentication with jQuery.</h1>
            <h2>About</h2>
            <p>This example shows how to perform email verification using just client side scripting and invoking a simple key based RESTful endpoint at <a href="https://api.emailverifyapi.com" target="_blank">api.emailverifyapi.com</a>.</p>
            <h2>How to run this sample</h2>
            <p>This page can be hosted anywhere (i.e. any web host or platform). The only thing needed is a valid license key.</p>
            <h2>Key features</h2>
            <ul>
                    <li>Compatible with all modern browsers</li>
                    <li>Uses jQuery 1.11.1</li>
                    <li>No server side scripting required</li>
            </ul>
            <hr />
            <h2>Try it</h2>
            <p>
                    <label for="key">Key:</label>
                    <input type="text" id="key" name="key" tabindex="1" maxlength="20" />
            </p>
            <p>
                    <label for="email">Email:</label>
                    <input type="text" name="email" id="email" tabindex="2" />
                    <input type="button" name="submit" id="submit" tabindex="3" value="verify" />
            </p>
            <div id="validationResult"></div> <!--Result output here-->
            <script>
                            /*nest key logic inside document.ready to ensure functionality only available once document has fully loaded in browser.*/
                            $(function () {
                                    console.log("ready!");

                                    $('#submit').click(function () {
                                            var emailText = $('#email').val(); // get key from text box entry
                                            var keyText = $('#key').val(); // get email address to be checked from text box

                                            if (keyText.length == 0) {
                                                    $('#validationResult').html("<span class='errorMsg'>Please enter key.</span>");
                                                    return;
                                            }

                                            if (emailText.length == 0) {
                                                    $('#validationResult').html("<span class='errorMsg'>Please enter something for email.</span>");
                                                    return;
                                            }

                                            $('#validationResult').html("verifying...");

                                            var emailVerifyApi = '//api.emailverifyapi.com/api/a/v1?email=' + encodeURIComponent(emailText) + '&key=' + keyText;

                                            /*execute remote request to perform email verification. Any errors will appear in the developer console (e.g. viewable using Chrome developer tools)*/
                                            $.getJSON(emailVerifyApi, {})
                                                    .done(function (data) {
                                                            reportResult(data);
                                                    })
                                                    .fail(function (jqxhr, textStatus, error) {
                                                            var err = textStatus + ", " + error;
                                                            console.log("Request failed: " + err);
                                                    });;
                                    });
                            });

                            /*Output result to the 'validationResult' div element*/
                            function reportResult(data) {
                                    var status = data['status'].toLowerCase(); // get 'status' from REST response
                                    var additionalStatus = data['additionalStatus']; // get 'additionalStatus' from REST response
                                    var message = data['Message']; // if there is an error (e.g. license issues), a notification will appear in the 'Message" from REST response.

                                    console.log(status);
                                    console.log(additionalStatus);
                                    console.log(message);

                                    var statusHtml;

                                    // if there is an error message, show here
                                    if (message != null
                                            && message != '') {
                                            statusHtml = "<span class='errorMsg'>Error. Message='" + message + "' .</span>";
                                    } else {
                                            // map REST response data to presentation messages.
                                            switch (status) {
                                                    case 'ok':
                                                            statusHtml = "<span class='statusOk'>Email address is ok.</span>";
                                                            break;
                                                    case 'bad':
                                                            statusHtml = "<span class='statusBad'>Email address is not valid.</span>";
                                                            break;
                                                    default:
                                                            statusHtml = "<span class='statusUnknown'>Unable to validate email. Reason=" + additionalStatus + "</span>";
                                                            break;
                                            }
                                    }

                                    console.log(statusHtml);

                                    // present the result on screen
                                    $('#validationResult').html(statusHtml);
                            }
            </script>
    </body>
    </html>

kangoo1313 on "Taxonomies and Custom Post Types differences"

$
0
0

Hello,

I would like to know if this is possible with the hierarchy :

Nations ( Taxonomy) -> Competitions ( Taxonomy ) , Seasons ( Taxonomy ) -> Clubs (Custom Post Type) -> Player ( CPT ), Staff (CPT)

My main question is, is that possible that the competitions and seasons can be hierarchically with the nation which is a taxonomy too ?


DNSOCCU on "[Collection and delivery date plugin]"

$
0
0

Hello everyone,
I'm creating a website for laundry & dry cleaning.
it's been a long time that i'm searching for a plugin wich can make my website clients choose a collection and delivery date for their clothes,i found some plugins but they can just allow clients to choose deivery date, can you help me please

joelharkes on "How to go from a git repo to svn. (update scripts)"

$
0
0

Here is my story. I was happily developing my wordpress plugin, and saving it in bitbucket until I decided to let wordpress host my plugin (easy updates, how awesome?!). But i wanted to keep using git, because it is just way better. So I needed deployment script. I did some scripting and here is mine, you can use it for yourself.

I added and saved mine in my svn main folder (otherwise this script doesn't work). it is based on powershell which their for windows. you might need to execute this command first: "Set-ExecutionPolic unrestricted". to be able to run powershell scripts.

here it is (I called this file Update.ps1):

echo "SVN UPDATE SCRIPT"

$gitFolder = "C:\Path\To\Your\Plugin"
$svnUrl = "http://plugins.svn.wordpress.org/[svn-plugin-name]"
$version = Read-Host 'Do you want to update version? Type version number (if not leave empty)'

$message = Read-Host 'Commit message'
if (-Not $message){
    $message = "A Powershell Commit message"
}

Remove-Item trunk\* -recurse

echo "Copying files"

Copy-Item "$gitFolder\*" trunk\ -Recurse
#Remove-Item trunk\.git -Recurse
Remove-Item .\trunk\.idea -Recurse
get-childitem .gitignore -recurse | remove-item

echo "Setting up svn for commit"
#Delete missing files
svn status | ? { $_ -match '^!\s+(.*)' } | % { svn rm $Matches[1] }

#Added new files
svn status | ? { $_ -match '^\?\s+(.*)' } | % { svn add $Matches[1] }

echo "Commiting to svn"
svn commit -m $message

if($version){
    echo "Updateing to Verion $version"
    svn copy "$svnUrl/trunk" "$svnUrl/tags/$version" -m "$message. updated to version $version"
}

pawawat on "How could I add button next to "edit image" button in "Attachment Details""

Loc Pham on "Unavailability of forum queries using XML-RPC"

$
0
0

I'm developing an iphone app and looking for ways to display on my app the forum posts that users engage on my wordpress website. However, I don't see any information from codex reference guide on how this can be achieved (if possible). From this Codex guide, I can query posts, pages, comments...etc. Since, my wordpress site is using AnsPress & bbPress to host the forum discussion, is it possible to use XML-RPC (or REST) to get the data from AnsPress & bbPress?

Any suggestion to move forward would be greatly appreciated.
Thanks

_PABLO on "how to add a menu page with elements wordpress?"

$
0
0

Hello, I have this example plugin for creating a page in the admin panel:

add_action( 'admin_menu', 'register_my_custom_menu_page' );

function register_my_custom_menu_page(){
	add_menu_page( 'custom menu title', 'custom menu', 'manage_options', 'custompage', 'my_custom_menu_page', plugins_url( 'myplugin/images/icon.png' ), 6 );
}

function my_custom_menu_page(){
	echo "Admin Page Test";
}

All working, but I don't know how place elements of wordpress.
I would like to have on the new page function: edit header, edit title and description website. For all the answers, thank you.

larnoult on "Changing wp-admin menu label for a plugin"

$
0
0

Hey there,
I successfully figured out how to change wp-admin menu labels for built-in labels, following this post for exemple.

function change_post_menu_label() {
    global $menu;
    global $submenu;
    $menu[5][0] = 'Contacts';
    $submenu['edit.php'][5][0] = 'Contacts';
    $submenu['edit.php'][10][0] = 'Add Contacts';
    $submenu['edit.php'][15][0] = 'Status'; // Change name for categories
    $submenu['edit.php'][16][0] = 'Labels'; // Change name for tags
    echo '';
}

function change_post_object_label() {
        global $wp_post_types;
        $labels = &$wp_post_types['post']->labels;
        $labels->name = 'Contacts';
        $labels->singular_name = 'Contact';
        $labels->add_new = 'Add Contact';
        $labels->add_new_item = 'Add Contact';
        $labels->edit_item = 'Edit Contacts';
        $labels->new_item = 'Contact';
        $labels->view_item = 'View Contact';
        $labels->search_items = 'Search Contacts';
        $labels->not_found = 'No Contacts found';
        $labels->not_found_in_trash = 'No Contacts found in Trash';
    }
    add_action( 'init', 'change_post_object_label' );
    add_action( 'admin_menu', 'change_post_menu_label' );

Yet, how should I do when I don't know the position in the $menu array of the plugin I want to change the label of?
Is there a way to display somewhere the position of each plugin label in the menu?

Thx for your help!

saNNNy on "Export post types with custom status for static HTML"

$
0
0

Hello,

I created two custom post statuses, one is public, one private. In WordPress, all works fine. The statuses are added to a custom post type.

But I want to export my website to static HTML (with WinHTTrack). Only 'published' posts are exported. The posts with a custom status are missing.

If I add the statuses to 'post' all posts are exported with my custom statuses. But not the posts of the custom post type.

I register my custom statuses in following code:

function custom_post_status()
{
	register_post_status('redaktion', array(
		'label' => _x('Redigiert', 'snippet'),
		'private' => true,
		'exclude_from_search'=> false,
		'show_in_admin_all_list' => true,
		'show_in_admin_status_list' => true,
		'label_count' => _n_noop( 'Redaktion <span class="count">(%s)</span>', 'Redigiert <span class="count">(%s)</span>')
	));

	register_post_status('testpublish', array(
		'label'	=> _x('Testveröffentlicht', 'snippet'),
		'public' => true,
		'exclude_from_search' => false,
		'show_in_admin_all_list' => true,
		'show_in_admin_status_list' => true,
		'post_type_support' => true,
		'label_count' => _n_noop( 'Testveröffentlicht <span class="count">(%s)</span>', 'Testveröffentlichte <span class="count">(%s)</span>')
	));
}
add_action('init', 'custom_post_status', 1);

The custom post type is registered in the next code snippet.

public static function register()
{
	$post_type_args = array
	(
		'public'  => TRUE,
		'show_ui' => TRUE,
		'exclude_from_search' => TRUE,
		'show_in_nav_menus' => FALSE,
		'rewrite' => array('slug' => 'snippet', 'with_front' => FALSE),
		'supports' => array('title', 'editor', 'author', 'revisions'),
	);
	register_post_type('snippet', $post_type_args);

Hopefully, someone can help me.
Thanks already.


m_pahlevanzadeh on "404 for old URLs"

$
0
0

Dear All,

I installed new wp, and I didn't manipulate my db, but all of my URL get 404 err, After installation I have one post, I don't get 404 err,

Do you have any solution?

chris_lag2014 on "are front pages necessary for site functionality?"

$
0
0

Hi, I am using the Matheson theme, which has all the functionality I am looking for except no sidebar on the Home page. I have successfully added a sidebar by copy and pasting in different code in the Frontpage file. ( I am using a child theme). However the sidebar is on the left and I want it on the right. I understand that this theme has everything set to full-width and I am afraid everything is going to get pushed around when I actually post something. I am afraid when I fill in the post field the size of everything will be off. I would like the home page to be just like the Single Post page but display the most recent post and also have a sidebar.

I am wondering if I can just delete the Frontpage and will the homepage default to a Single page file, or can I make a new Frontpage with the code copied from the single page files or will that not work? I am thinking it might except that I probably need a call to action for the most recent post.

I would appreciate your opinion of where I should go in solving this. Thnx!

caroline on "Change URL on attachments (image.php)"

$
0
0

I use the latest version and Twenty Fifteen (latest parent) and child.

I would like to have the attachments URL changed and can't find a good tutorial of how to do it. Is it possible?

More specific, I don't want the attachments ID in the URL, I want the attachments title (a seo-friendly) one.

Kindly asking,
Caroline

lup0z on "delete_attachment isn't fired"

$
0
0

Hi,
I'm developing a custom gallery which uses an XML DB for the purpose.
Now I would like to synchronize the XML with the Media Library: when deleting an image from the Media Library, the ID of the image stored in the XML file will be deleted too, so:

function onWpDelete( $targetID ){

    $filePath = '../wp-content/plugins/the-plugin/gallery.xml';
    if( file_exists( $filePath ) ){
        $doc = new DOMDocument();
        $doc->load($filename);
        $doc->preserveWhiteSpace = false;
        $doc->formatOutput = true;

        $ids = $doc->getElementsByTagName('ID');
        foreach( $ids as $id ){
            if( $id->nodeValue == $targetID ){

                try{
                    $id->parentNode->removeChild($id);
                } catch(Exception $e){
                    wp_die('DOMDocument: ' . $e->getmessage() );
                }//try - catch

                break;
            }//if
        }//foreach
    }//if
}//onWpDelete
add_action('delete_attachment', 'onWpDelete');

but I can't get the delete_attachment hook fired when I delete an image from the Media Library and can't make it working.
I even tried:

add_action('delete_attachment', 'onWpDelete', 1', 1);

because of the $postid parameter for the hook but it doesn't work.

What's the correct way to do that?

Thank you

dgcov on "Undefined function wp_hash_password() when instantiating wp_insert_user()"

$
0
0

I'm inserting a user programmatically.

The problem (from googling) appears to be that the /wp-includes/pluggable isn't loaded when the form calls the script.

<?php
  defined( 'ABSPATH' ) or die( 'Plugin file cannot be accessed directly.' );
  $pldir=plugin_dir_path( __FILE__ );
  require $pldir.'regHandler.php';
  if($_POST['button109']){
    // It's a new user registration/
    $newuserdata=regHandler($_POST);
  }

In the regHandler.php:

<?php
function regHandler($formData){
  $email=$formData['email'];
  $returnVals['userid']=0;
  //$pass=wp_generate_password ( 12, false );
  $user_id = wp_insert_user(
    array(
      'user_login'  =>  $email,
      'user_pass' =>  $pass,
      'first_name'  =>  $formData['first_name'],
      'user_nicename'  =>  $formData['first_name'],
      'last_name' =>  $formData['last_name'],
      'user_email'  =>  $email,
      'display_name'  =>  $formData['first_name'] . ' ' . $formData['last_name'],
      'nickname'  =>  $formData['first_name'] . ' ' . $formData['last_name'],
      'role'    =>  'contributor'
    )
  );
}?>

The error:
Fatal error: Call to undefined function wp_hash_password() in /hermes/bosnaweb14a/b1229/ipg/haroldwooduk/wp-includes/user.php on line 1874

Viewing all 8245 articles
Browse latest View live




Latest Images