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

suparna chowdhury on "WP_Query reset confusion"

$
0
0

Hi, I am new to WordPress. Right now I am hand coding a WordPress theme. While writing a custom loop I came across this statement
$wp_query = null; $wp_query = $temp
Now I am confused if this is equivalent as
wp_reset_quer
meaning do they both do the same job? I searched google and forums but could not find an answer.
Thanks in advance to anyone willing to help resolve this dilemma.


Alphard on "Pre-filling custom fields on New Post"

$
0
0

Hello,

I'd like to have a number of custom fields automatically pre-filled when a user opens the Add New Post page in the admin panel to create a new post. I've looked through the hooks but I can't find which one would be suitable. I'm also not sure how to go about pre-populating the custom fields section in the new post form. Any ideas?

Zachary Nespral on "Replace TinyMCE with Custom Built Editor"

$
0
0

Hi,

I am looking to build a custom wiziwig, and replace wordpress's TinyMCE all together. Now I figured out how to add to the TinyMCE editor, but thats not what im looking for. Does anyone have any references for a starting point? Googling it only came up with the option to add to TinyMCE, not replace it with something custom all together. I'm new to theme development, so something detailed would be great. I really just need a starting point, then I should be able to get it from there.

Let me know if you have any questions

Thanks in advance,
Zac

matthewtvogel on "unset(...) documentation for removing default fields"

$
0
0

Hi all,

I'm attempting to remove default fields on the user-edit.php page in the WP backend.

After searching the Codex and online forums, the closest I've come to a solution is:

function add_twitter_contactmethod( $contactmethods ) {
  unset($contactmethods['aim']);
  unset($contactmethods['jabber']);
  unset($contactmethods['yim']);
  return $contactmethods;
}
add_filter('user_contactmethods','add_twitter_contactmethod',10,1);

Which is great and seems to be on the right track - except I can't seem to find actual documentation and/or an index of all the different field names. For example, how do I unset the 'Choose your Color Scheme' field?

My temporary solution is to hide the fields via CSS but this is obviously not ideal, and is more of a hack than a proper solution. It also has its limits since I can't specifically target section headings.

Any ideas or leads?

mslade on "Ambiguous get_queried_object()"

$
0
0

Hi,

I have a custom post type ("knowledge") archive page that I want to be filterable by taxonomy ("topic") as well as a custom field ("type"). To hook up the custom field filtering I'm using pre_get_posts to add a meta_query. Since I only want this filtering to be available on this archive page, I first check that $query->is_main_query() == true && is_archive() && get_queried_object()->name == "knowledge".

The problem I've encountered is that get_queried_object() returns the taxonomy object if "topic" is in the URL and the post type object of the archive otherwise. I think the underlying issue is that a query can satisfy both is_archive and is_tax at the same time, so get_queried_object() has no way of knowing which one I want.

If I want the "topic" taxonomy to be publicly queryable, how can I reliably check the post type of an archive page?

HaukeNI on "Removing title link of custom post type"

$
0
0

Hi,

First off, I'm fairly new to WordPress development. I know my way around the GUI part pretty well but I'm not yet well versed on the php end. So if you reply, please be specific. Most importantly, please tell me what file the code should go into and where it's located. In the vast majority of answers I've found here I just see chunks of code pasted and I usually have no clue where it's supposed to go.

So here's what I would like to accomplish: I have created a custom post type "Dealer" that is being displayed as a list of search results. By default, each "Dealer" title is a link directing to the single post page. I do not want the titles to be links, since the single pages are irrelevant and shouldn't be accessed. I did find threads in the forum describing how to remove the anchor tags from all posts globally but I have not found any describing how to do it just for a specific custom post type but if one exists, feel free to just link me to that.

Sonita0001 on "Events Calendar Plugin conflict"

$
0
0

Hi. I am trying to install an events Calendar plugin on my site, but there seems to be conflict somewhere with all 5 I have tried so far. I read somewhere that it might be Yoast SEO that is causing it. I am using the Encounters Lite theme. Can anyone please tell me how to resolve the conflict I get a "500 Internal Server Error" when I want to view my site after activating the plugins and as soon as I deactivate them, my site is fine again. Or does anyone know what event calendar plugin I can try that will be compatible? Thank you

mikevisions on "echo some text only if a custom taxonomy has posts"

$
0
0

What I am trying to do is output some text only if a custom taxonomy has some posts.
I have found this code for a standard category;
<?php if (get_category('27')->category_count > 0)
echo "print something"; ?>

Which works for categories.
So I am trying to modify this for taxonomy use like this;

if (get_taxonomy('business_category')->taxonomy_count > 0)
echo "print something; ?>

I am now stuck in working out how to query a specific term in the taxonomy preferably bu 'slug'

Any help would be much appreciated.


rbvinc on "php / html code process"

$
0
0

Can somebody help me, how can I process this in wordpress as php/html.
I put this as is, returning empty in 'select' section.
Thanks,

[ Moderator note: code fixed. Please wrap code in the backtick character or use the code button. ]

<?php
mysql_connect("localhost", "root", "password") or die("Connection Failed");
mysql_select_db("company")or die("Connection Failed");
$query = "SELECT * FROM COMPANIES order by COMPANYNAME";
$result = mysql_query($query);
?>

<select name='company'>
<option value="">Select</option>

<?php while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) { ?>
<option value="<?php echo $line['COMPANYNAME'];?>"> <?php echo $line['COMPANYNAME'];?> </option>   <?php } ?>

</select>

myrok24 on "Pull images from gallery into list"

$
0
0

I'm looking for a simple code to place in my custom single-page (portfolio) to output all the images in a gallery. So i can display them in a Foundation grid-block:

<ul class="small-block-grid-3">
  <li><!-- gallery item --></li>
  <li><!-- gallery tem --></li>
  <li><!-- gallery item --></li>
</ul>

So basicly: i want al
<li> </li> around the gallery images.. thats all...

thnx@

ladee900 on "Syntax error"

$
0
0

I tried to edit the footer and I am getting this message below

Parse error: syntax error, unexpected 'k' (T_STRING) in /home/crestfbw/public_html/wp-content/themes/spacious/inc/functions.php on line 451

How can I undo or correct this I can not get back into my account

mrwebb82 on "Issue with register_post_type function"

bncpeter on "Prevent   characters from getting removed by the visual editor"

$
0
0

I'm a graphic designer and want my   (non-breaking space) characters to stay where I bloody-well put them without the visual editor stripping them out again. If you're a typography dick like me, this is handy to make two or more specific words wrap together rather than breaking at the spaces.

For example, if you want "South Australia" not to break in an address.

So, I wrote added a simple shortcode via my child-theme's functions.php:

//[nbsp] shortcode
function nbsp_shortcode( $atts, $content = null ) {
	$content = '&nbsp';
	return $content;
}

add_shortcode( 'nbsp', 'nbsp_shortcode' );

Then I just use:
[nbsp]
Instead of:
&nbsp;

Hope this helps someone.

Pt.

wadeebunch on "How do I hide information from a user profile page?"

$
0
0

I bought a theme that uses a pre-set profile page and it contains two items that I do not want available on that page. They told me where the php code is for this, but won't tell me what to change it to. This is where they said the code is located - directory/wp-content/themes/Directory/author.php - That code is below.

Is there anyone willing to help me do this? There are two "tabs" that I want removed. Listing and Post.

** 5. Author Page
*/
.author-page .social_media ul li a:hover i,
.user .social_media ul li a:hover i { border-color: #000; color: #000; }
.author_cont .author_photo { border-color:rgba(0, 0, 0, .13) }
.author_cont .author_photo img { display:inline-block; width:auto }
body h1.loop-title, body h1.page-title { font-size:30px; padding-bottom:10px; margin-bottom:10px;}
body .author_cont .author_photo { border-color:rgba(0, 0, 0, .13) }
body .author_cont .author_photo img { display:inline-block; width:100%; float: left;}
.author_cont .bottom_line a { color:#666 }
.author_cont .bottom_line a:hover { color:#0165BD; }
.author_cont .bottom_line { color:#000; font-size:12px }
.author_price_details { clear:both }
.city_image #footer .footer_top { border-top:none }
#content .people_info h3 { font-size:18px; font-weight:700; margin:0 0 6px }
.author_custom_post_wrapper ul li { margin-right:6px; margin-bottom: -2px; }
.author_custom_post_wrapper ul li.normal { margin-right:10px }
#content .peoplelisting li { border-bottom:1px solid rgba(0, 0, 0, .13) }
#content .peoplelisting li h3 span.total_homes { font-weight:400 }
#content .peoplelisting li h3 span.total_homes a { font-weight:700 }
#content .people_info .links .profile { padding:0 }
.author_custom_post_wrapper ul li a { background:#fafafa /; background:rgba(0, 0, 0, .05); border-width:2px; border-color:rgba(0, 0, 0, .13); border-bottom: 2px solid transparent; font-size:14px; color:#444; text-transform:none; padding:12px 12px 11px }
.author_custom_post_wrapper { border-bottom:2px solid #ccc /; border-bottom:2px solid rgba(0, 0, 0, .13) }
.author_custom_post_wrapper ul li a.nav-author-post-tab-active { border-bottom-color: #fff; margin-bottom:-1px; }
.author_cont .author_photo img { max-width:265px; width:100%; }

/*

gabbyhanna on "Category slug not filtering posts with loop query"

$
0
0

Hi there!

Just a heads up, I'm very new to WordPress and PHP, so please bare with me.

I have two loops running on my index.php page, one to display the first post as a full-bleed header and the second to show the rest of the posts with an offset so that the header post isn't duplicated. My issue is that I have a horizontal sub-navigation bar in the middle of the loops with links to various categories (i.e. /blog/category/product), but after clicking on the link, the posts don't filter by the category. Instead, every single post loads.

I noticed that removing the queries associated with each loop fixes the problem, but the queries are essential.

It may also be more ideal to only run one loop to keep the webpage load time to a minimum, so if anyone knows how to make that happen with the categories sub-navigation, please let me know!

Here is my code: http://pastebin.com/k2Du5SpT

Thanks in advance for your help!


nyodulf on "Are exclusive taxonomy *terms* possible?"

$
0
0

I'm creating a site that requires users' content to be exclusive to the user. Ideally I would like this to extend to taxonomy terms.

Example:

  • I have a taxonomy "Clients"
  • UserA creates the term "My Client"
  • UserB creates the term "My Client"

Is it possible to

  1. Make sure that both entries for "My Client" exist separately?
  2. Make sure that each user can only choose their own version of "My Client" to apply to posts?
  3. Make sure that, before UserB creates "My Client", UserA's version is invisible to UserB?

Ciredor on "Gallery custom shortcode"

zewtastic on "Problem formatting posts in custom front-end."

$
0
0

I have built a custom front end for my WP install using the:

define('WP_USE_THEMES', false);

/** Loads the WordPress Environment and Template */
require './wp/wp-blog-header.php';

And I am using:

$content = apply_filters( 'the_content', get_the_content() );
         $content = str_replace( ']]>', ']]>', $content );

         //the_content();
         echo $content;

to output posts and pages.

But I cannot figure out how to get the css formatting of the posts to work right.

Do I need to link to some CSS files in /wordpress or can I also use body_class(); somehow?

I am totally lost regarding this.

Any help appreciated.

phoenixlaef on "Media from Another Server"

$
0
0

Hello, I am wondering whether anyone has made a plugin to add external images from another server into the wordpress media library.

When adding media to a post or page you can insert media from a url as seen here: https://goo.gl/iFLctz

I would like to be able to use the media library just like I usually would but would like to be able to have media in the library that is from an external source.

Add directly to the media library: https://goo.gl/UlBpGa

Adding from a url to a gallery which in turn adds the media to the media library like when uploading media directly to the server: https://goo.gl/UlBpGa

Resulting in the media coming from another server: https://goo.gl/XitFXI

That way the images can still be called by [gallery id='']

If there isn't a plugin for this feature how hard would it be to create a plugin that adds the features so its native like shown in the mockups?

Your input is greatly appreciated.

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;

                            ?>
Viewing all 8245 articles
Browse latest View live




Latest Images